public PastShiftModel UptdatePartialPastShift(PastShiftModel pastShiftModel) { PastShift pastShift = DB.PastShifts.SingleOrDefault(p => p.ShiftId == pastShiftModel.ShiftId); if (pastShift == null) { return(null); } if (pastShift.ShiftTypeId != null) { pastShift.ShiftTypeId = pastShiftModel.ShiftTypeId; } if (pastShift.EmployeeId != null) { pastShift.EmployeeId = pastShiftModel.EmployeeId; } if (pastShift.Started != null) { pastShift.Started = pastShiftModel.Started; } if (pastShift.Ended != null) { pastShift.Ended = pastShiftModel.Ended; } DB.SaveChanges(); return(pastShiftModel); }
public PastShiftModel AddPastShiftModel(PastShiftModel pastShiftModel) { PastShift pastShift = pastShiftModel.ConvertToPastShift(); DB.PastShifts.Add(pastShift); DB.SaveChanges(); pastShiftModel.ShiftId = pastShift.ShiftId; return(pastShiftModel); }
public PastShiftModel UptdateFullPastShift(PastShiftModel pastShiftModel) { PastShift pastShift = DB.PastShifts.SingleOrDefault(e => e.ShiftId == pastShiftModel.ShiftId); if (pastShift == null) { return(null); } pastShift.ShiftTypeId = pastShiftModel.ShiftTypeId; pastShift.EmployeeId = pastShiftModel.EmployeeId; pastShift.Started = pastShiftModel.Started; pastShift.Ended = pastShiftModel.Ended; DB.SaveChanges(); return(pastShiftModel); }