public static Shift Create(Shift shift) { if (shift.WorkerId == Guid.Empty) { throw new NullReferenceException("WorkerId"); } if (shift.ShiftTypeEnum.In(eShiftType.NotSet)) { throw new NullReferenceException("ShiftType"); } if (shift.Date == null) { throw new NullReferenceException("Date"); } using (var appDC = BARDBDataContext.Ready()) { shift.DateCreated = DateTime.Now; shift.ShiftId = Guid.NewGuid(); shift.ShiftType = (int)shift.ShiftTypeEnum; appDC.Shifts.InsertOnSubmit(shift); appDC.SubmitChanges(); return(shift); } }
public static Shift Get(DateTime date, eShiftType shiftType, Guid businessUnitId) { using (var appDC = BARDBDataContext.Ready()) { return(appDC.Shifts.FirstOrDefault(s => s.Date.Date == date.Date && s.ShiftType == (int)shiftType && s.BusinessUnitId == businessUnitId)); } }
public static List <usp_get_shiftsResult> GetList(DateTime dateTime) { using (var appDC = BARDBDataContext.Ready()) { return(appDC.usp_get_shifts(dateTime).OrderBy(s => s.ShiftType).ToList()); } }
public static bool IsExist(DateTime date, eShiftType shiftType, Guid businessUnitId) { using (var appDC = BARDBDataContext.Ready()) { return(appDC.Shifts.SingleOrDefault(s => s.Date.Date == date.Date && s.ShiftType == (int)shiftType && s.BusinessUnitId == businessUnitId) != null); } }
public static List <User> GetList() { using (var appDC = BARDBDataContext.Ready()) { return(appDC.Users.OrderBy(u => u.FirstName).ToList()); } }
public static User GetById(Guid id) { using (var appDC = BARDBDataContext.Ready()) { return(appDC.Users.SingleOrDefault(u => u.UserId == id)); } }
public static void Delete(Guid id) { using (var appDC = BARDBDataContext.Ready()) { var toDelete = appDC.Shifts.SingleOrDefault(s => s.ShiftId == id); if (toDelete != null) { appDC.Shifts.DeleteOnSubmit(toDelete); appDC.SubmitChanges(); } } }
public static void Delete(DateTime date, eShiftType shiftType, Guid businessUnitId) { using (var appDC = BARDBDataContext.Ready()) { var toDelete = appDC.Shifts.FirstOrDefault(s => s.Date.Date == date.Date && s.ShiftType == (int)shiftType && s.BusinessUnitId == businessUnitId); if (toDelete != null) { appDC.Shifts.DeleteOnSubmit(toDelete); appDC.SubmitChanges(); } } }
public static User Create(User user) { user.DateCreated = DateTime.Now; user.UserId = Guid.NewGuid(); user.Password = "******"; using (var appDC = BARDBDataContext.Ready()) { appDC.Users.InsertOnSubmit(user); appDC.SubmitChanges(); } return(user); }
public static void Update(User user) { using (var appDC = BARDBDataContext.Ready()) { var toUpdate = appDC.Users.SingleOrDefault(u => u.UserId == user.UserId); toUpdate.LastName = user.LastName; toUpdate.FirstName = user.FirstName; toUpdate.ColorHex = user.ColorHex; if (user.AvatarData != null) { toUpdate.AvatarData = user.AvatarData; } appDC.SubmitChanges(); } }