Implement Clear Unassigned Card method to remove all cards/identifiers from the database not assigned to a user. Add procedure to delete cards from the db. #69
96 lines
5.2 KiB
C#
96 lines
5.2 KiB
C#
namespace SQLiteRepository
|
|
{
|
|
internal static class SQLiteProcedures
|
|
{
|
|
public const string GET_LOGS_IN_LAST_X_MINUTES =
|
|
"select * from TimeLogDb where " + nameof(TimeLogDb.SwipeEventDateTime) + " > ? AND " +
|
|
nameof(TimeLogDb.UserId_FK) + "=?";
|
|
|
|
public const string GET_TIMELOGS =
|
|
"select * from " + nameof(TimeLogDb) + " where (" + nameof(TimeLogDb.UserId_FK) + "=? AND " +
|
|
nameof(TimeLogDb.CalendarWeek) + "=? and " + nameof(TimeLogDb.Year) + "=?)";
|
|
|
|
public const string GET_ALL_USERS =
|
|
"select * from " + nameof(UserIdentity) + " ut "
|
|
+ "where "
|
|
+ "EXISTS( select " + nameof(GroupDb.GroupId)
|
|
+ " from " + nameof(GroupDb)
|
|
+ " where " + nameof(GroupDb.GroupName) + " = 'Archived') AND "
|
|
+ "NOT EXISTS( select * from " + nameof(UserGroupJoinDb) + " ugp where "
|
|
+ nameof(UserGroupJoinDb.UserId_FK) + " = ut.Id"
|
|
+ " and " + nameof(UserGroupJoinDb.GroupId_FK) + " = ( "
|
|
+ "select " + nameof(GroupDb.GroupId)
|
|
+ " from " + nameof(GroupDb)
|
|
+ " where " + nameof(GroupDb.GroupName) + " = 'Archived') )"
|
|
+ "order by "
|
|
+ nameof(UserIdentity.LastName) + " collate nocase, "
|
|
+ nameof(UserIdentity.FirstName) + " collate nocase";
|
|
|
|
public const string GET_ALL_USERS_PAGINATE =
|
|
"select * from " + nameof(UserIdentity) + " ut "
|
|
+ "where "
|
|
+ "EXISTS( select " + nameof(GroupDb.GroupId)
|
|
+ " from " + nameof(GroupDb)
|
|
+ " where " + nameof(GroupDb.GroupName) + " = 'Archived') AND "
|
|
+ "NOT EXISTS( select * from " + nameof(UserGroupJoinDb) + " ugp where "
|
|
+ nameof(UserGroupJoinDb.UserId_FK) + " = ut.Id"
|
|
+ " and " + nameof(UserGroupJoinDb.GroupId_FK) + " = ( "
|
|
+ "select " + nameof(GroupDb.GroupId)
|
|
+ " from " + nameof(GroupDb)
|
|
+ " where " + nameof(GroupDb.GroupName) + " = 'Archived') )"
|
|
+ "order by "
|
|
+ nameof(UserIdentity.LastName) + " collate nocase, "
|
|
+ nameof(UserIdentity.FirstName) + " collate nocase "
|
|
+ "limit ? offset ?";
|
|
|
|
public const string GET_ALL_USERS_BY_GROUP =
|
|
"select u." + nameof(UserIdentity.Id) + ", u." + nameof(UserIdentity.FirstName) + ", u." +
|
|
nameof(UserIdentity.LastName) + ", u." + nameof(UserIdentity.HoursPerWeek) + ", u." +
|
|
nameof(UserIdentity.IsContractor) + " from " + nameof(UserIdentity) + " u left join " +
|
|
nameof(UserGroupJoinDb) + " ugj on ugj." + nameof(UserGroupJoinDb.UserId_FK) + " = u." +
|
|
nameof(UserIdentity.Id) + " where ugj." + nameof(UserGroupJoinDb.GroupId_FK) + "=? order by u." +
|
|
nameof(UserIdentity.LastName) + " collate nocase, u." + nameof(UserIdentity.LastName) + " collate nocase";
|
|
|
|
public const string GET_USER_BY_ID =
|
|
"select * from " + nameof(UserIdentity) + " where " + nameof(UserIdentity.Id) + "=?";
|
|
|
|
public const string GET_CARDS_BY_USER_ID =
|
|
"select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?";
|
|
|
|
public const string GET_CARDS_BY_UNIQUE_ID =
|
|
"select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.CardUId) + "=?";
|
|
|
|
public const string GET_UNASSIGNED_CARD_LIST =
|
|
"select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?";
|
|
|
|
public const string CLEAR_UNASSIGNED_CARDS =
|
|
"delete from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?";
|
|
|
|
public const string UPDATE_CARD_USER_ID =
|
|
"update " + nameof(CardUniqueId) + " set " + nameof(CardUniqueId.UserId_FK) + "=? where " +
|
|
nameof(CardUniqueId.Id) + "=?";
|
|
|
|
public const string UPDATE_CARD_LAST_USED =
|
|
"update " + nameof(CardUniqueId) + " set " + nameof(CardUniqueId.LastUsed) + " = ? where " +
|
|
nameof(CardUniqueId.Id) + " = ?";
|
|
|
|
public const string UPDATE_USER_DETAILS =
|
|
"update " + nameof(UserIdentity) + " set " + nameof(UserIdentity.FirstName) + "=?, " +
|
|
nameof(UserIdentity.LastName) + "=?, " + nameof(UserIdentity.HoursPerWeek) + "=?," +
|
|
nameof(UserIdentity.IsContractor) + "=? where " + nameof(UserIdentity.Id) + "=?";
|
|
|
|
public const string SEARCH_USER_LIST =
|
|
"SELECT * FROM " + nameof(UserIdentity) + " where(" + nameof(UserIdentity.FirstName) + " Like ? OR " +
|
|
nameof(UserIdentity.LastName) + " Like ?)";
|
|
|
|
public const string GET_LAST_TIMELOG_DIRECTION =
|
|
"SELECT * FROM " + nameof(TimeLogDb) + " where " + nameof(TimeLogDb.UserId_FK) + " = ? order by " +
|
|
nameof(TimeLogDb.SwipeEventDateTime) + " desc LIMIT 1";
|
|
|
|
public const string GET_TOTAL_USER_COUNT =
|
|
"select Max(" + nameof(UserIdentity.Id) + ") from " + nameof(UserIdentity);
|
|
|
|
public const string GET_USER_CONTRACTED_HOURS =
|
|
"select " + nameof(UserIdentity.HoursPerWeek) + " From UserIdentity where " + nameof(UserIdentity.Id) + "=?";
|
|
}
|
|
} |