public static List <WorkHours> list() { using (var dbContext = new WashingtonRedskinsContext()) { return(dbContext.WorkHours.ToList()); } }
private static Statuses get(uint id) { using (var dbCOntext = new WashingtonRedskinsContext()) { return(dbCOntext.Statuses.Find(id)); } }
public static Registrations get(uint id) { using (var dbCOntext = new WashingtonRedskinsContext()) { return(dbCOntext.Registrations.Find(id)); } }
public static void delete(uint id) { using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Remove(dbContext.Statuses.Find(id)); } }
public static List <Registrations> list(DateTime start, int pageSize, int skip, uint userId) { IQueryable <Registrations> dbRegs; using (var dbContext = new WashingtonRedskinsContext()) { dbRegs = dbContext.Registrations; if (start != null) { dbRegs = dbRegs.Where(r => r.Time > start); } if (pageSize != 0) { dbRegs = dbRegs.Take(pageSize + skip); } if (skip != 0) { dbRegs = dbRegs.Skip(skip); } if (userId != 0) { dbRegs = dbRegs.Where(r => r.UserId == userId); } return(dbRegs.ToList()); } }
public static Users get(uint id) { using (var dbContext = new WashingtonRedskinsContext()) { return(dbContext.Users.Find(id)); } }
public static List <Users> list(int pageSize = 50, int skip = 0, uint userGroupId = 0, uint departmentId = 0) { IQueryable <Users> dbUsers; using (var dbContext = new WashingtonRedskinsContext()) { dbUsers = dbContext.Users; if (pageSize != 0) { dbUsers = dbUsers.Take(pageSize); } if (skip != 0) { dbUsers = dbUsers.Skip(skip); } if (userGroupId != 0) { dbUsers = dbUsers.Where(u => u.UserGroupId == userGroupId); } if (departmentId != 0) { dbUsers = dbUsers.Where(u => u.DepartmentId == departmentId); } return(dbUsers.ToList()); } }
public static List <Statuses> list() { using (var dbContext = new WashingtonRedskinsContext()) { return(dbContext.Statuses.ToList()); } }
public static Departments get(uint id) { using (var dbCOntext = new WashingtonRedskinsContext()) { return(dbCOntext.Departments.Find(id)); } }
public void add() { using (var dbContext = new WashingtonRedskinsContext()) { dbContext.WorkHours.Add(this).State = EntityState.Added; dbContext.SaveChanges(); } }
public static void add(RegistrationsEdits regEdit) { using (var DbContext = new WashingtonRedskinsContext()) { DbContext.RegistrationsEdits.Add(regEdit); DbContext.SaveChanges(); } }
public void add() { using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Users.Add(this); dbContext.SaveChanges(); } }
public List <string> GetUserPrivileges() { IQueryable <string> privileges; using (var dbcontext = new WashingtonRedskinsContext()) { privileges = dbcontext.Privileges.Where(x => x.UserGroupsPrivileges.Where(up => up.Isallowed == 1).Any(r => r.UserGroup.Id == UserGroupId)).Select(p => p.Name); return(privileges.ToList()); } }
public static Breaks get(uint id) { Breaks brk; using (var dbCOntext = new WashingtonRedskinsContext()) { brk = dbCOntext.Breaks.Find(id); } return(brk); }
public static void delete(uint id) { using (var dbContext = new WashingtonRedskinsContext()) { var orig = dbContext.Departments.Find(id); orig.DeletedAt = DateTime.Now; bool a = dbContext.ChangeTracker.HasChanges(); //double check if there was any change detected by EF or not? dbContext.SaveChanges(); } }
public static void delete(uint id) { var orig = get(id); using (var dbContext = new WashingtonRedskinsContext()) { orig.DeletedAt = DateTime.Now; dbContext.Entry(orig).State = EntityState.Modified; dbContext.SaveChanges(); } }
public static void edit(uint id, Users changes) { var orig = get(id); using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Entry(orig).CurrentValues.SetValues(changes); dbContext.Entry(orig).State = EntityState.Modified; dbContext.SaveChanges(); } }
public static RegistrationsEdits get() { RegistrationsEdits regEdit; using (var dbContext = new WashingtonRedskinsContext()) { regEdit = dbContext.RegistrationsEdits.First(); } return(regEdit); }
public static void set(DateTime time) { using (var dbContext = new WashingtonRedskinsContext()) { var regEdit = dbContext.RegistrationsEdits.Where(r => r.Time > time).FirstOrDefault(); if (regEdit != null) { regEdit.Time = time; dbContext.SaveChanges(); } } }
public static void delete(uint id) { DateTime time; using (var dbContext = new WashingtonRedskinsContext()) { time = dbContext.Registrations.Find(id).Time; dbContext.Registrations.Find(id).DeletedAt = DateTime.Now; dbContext.SaveChanges(); } RegistrationsEdits.set(time); }
public static string login(string email, string password) { if (AuthController.validatePassword(email, password)) { Users usr; using (var dbContext = new WashingtonRedskinsContext()) { usr = dbContext.Users.Where(u => u.Email == email).First(); } return(AuthController.generateToken(usr)); } return(null); }
public static void edit(Registrations newRegistration, uint origId) { var orig = get(origId); using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Entry(orig).CurrentValues.SetValues(newRegistration); dbContext.Entry(orig).State = EntityState.Modified; dbContext.SaveChanges(); } var earliestTime = newRegistration.Time < orig.Time ? newRegistration.Time : orig.Time; RegistrationsEdits.set(earliestTime); }
public Registrations getPrevious() { Registrations reg; try { using (var dbContext = new WashingtonRedskinsContext()) { reg = dbContext.Registrations.Where(r => r.UserId == UserId).Where(r => r.Id < Id).OrderByDescending(r => r.Id).First(); } } catch { reg = null; } return(reg); }
public static List <Departments> list(int pageSize = 50, int skip = 0) { IQueryable <Departments> dbDepartments; using (var dbContext = new WashingtonRedskinsContext()) { dbDepartments = dbContext.Departments; if (pageSize != 0) { dbDepartments = dbDepartments.Take(pageSize); } if (skip != 0) { dbDepartments = dbDepartments.Skip(skip); } return(dbDepartments.ToList()); } }
public static List <UserGroup> list(int pageSize = 50, int skip = 0) { IQueryable <UserGroup> dbUserGroups; using (var dbContext = new WashingtonRedskinsContext()) { dbUserGroups = dbContext.UserGroups; if (pageSize != 0) { dbUserGroups = dbUserGroups.Take(pageSize); } if (skip != 0) { dbUserGroups = dbUserGroups.Skip(skip); } return(dbUserGroups.ToList()); } }
public static List <Breaks> list(int pageSize = 50, int skip = 0) { IQueryable <Breaks> dbBreaks; List <Breaks> brks; using (var dbContext = new WashingtonRedskinsContext()) { dbBreaks = dbContext.Breaks; if (pageSize != 0) { dbBreaks = dbBreaks.Take(pageSize); } if (skip != 0) { dbBreaks = dbBreaks.Skip(skip); } brks = dbBreaks.ToList(); } return(brks); }
public static void add(uint userId, uint statusId) { Registrations reg = new Registrations(); Users usr; using (var dbContext = new WashingtonRedskinsContext()) { usr = dbContext.Users.Find(userId); } reg.UserId = userId; reg.Time = DateTime.Now; reg.DepartmentId = usr.DepartmentId; reg.StatusId = statusId; using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Add(reg); dbContext.SaveChanges(); } }
public static List <RegistrationSummary> list(DateTime start, bool groupByDay, bool groupByWeek, bool groupByMonth) { List <RegistrationSummary> regSum; using (var dbContext = new WashingtonRedskinsContext()) { if (groupByMonth) { regSum = dbContext.RegistrationSummary.Where(r => r.Date > start).GroupBy(s => new { s.YearMonth, s.UserId, s.StatusId, s.DepartmentId }) .Select(g => new RegistrationSummary { UserId = g.Key.UserId, Duration = g.Sum(x => x.Duration), Id = g.Min(x => x.Id), YearMonth = g.Key.YearMonth, YearWeek = 0, DepartmentId = g.Key.DepartmentId, StatusId = g.Key.StatusId, Date = g.Min(x => x.Date) } ).ToList(); } else if (groupByMonth) { regSum = dbContext.RegistrationSummary.Where(r => r.Date > start).GroupBy(s => new { s.YearWeek, s.UserId, s.StatusId, s.DepartmentId }) .Select(g => new RegistrationSummary { UserId = g.Key.UserId, Duration = g.Sum(x => x.Duration), Id = g.Min(x => x.Id), YearMonth = g.Key.YearWeek, YearWeek = 0, DepartmentId = g.Key.DepartmentId, StatusId = g.Key.StatusId, Date = g.Min(x => x.Date) } ).ToList(); } else { regSum = dbContext.RegistrationSummary.Where(r => r.Date > start).GroupBy(s => new { s.UserId, s.StatusId, s.DepartmentId }) .Select(g => new RegistrationSummary { UserId = g.Key.UserId, Duration = g.Sum(x => x.Duration), Id = g.Min(x => x.Id), YearMonth = 0, YearWeek = 0, DepartmentId = g.Key.DepartmentId, StatusId = g.Key.StatusId, Date = g.Min(x => x.Date) } ).ToList(); } return(regSum); } }