Пример #1
0
        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);
        }
Пример #2
0
 public PastShiftModel(PastShift pastShift)
 {
     ShiftId     = pastShift.ShiftId;
     ShiftTypeId = pastShift.ShiftTypeId;
     EmployeeId  = pastShift.EmployeeId;
     Started     = pastShift.Started;
     Ended       = pastShift.Ended;
 }
Пример #3
0
        public PastShiftModel AddPastShiftModel(PastShiftModel pastShiftModel)
        {
            PastShift pastShift = pastShiftModel.ConvertToPastShift();

            DB.PastShifts.Add(pastShift);
            DB.SaveChanges();
            pastShiftModel.ShiftId = pastShift.ShiftId;
            return(pastShiftModel);
        }
Пример #4
0
        public void DeletePastShift(int id)
        {
            PastShift pastShiftToDelete = DB.PastShifts.SingleOrDefault(p => p.ShiftId == id);

            if (pastShiftToDelete == null)
            {
                return;
            }
            DB.PastShifts.Remove(pastShiftToDelete);
            DB.SaveChanges();
        }
Пример #5
0
        public PastShift ConvertToPastShift()
        {
            PastShift pastShift = new PastShift {
                ShiftId     = ShiftId,
                ShiftTypeId = ShiftTypeId,
                EmployeeId  = EmployeeId,
                Started     = Started,
                Ended       = Ended
            };

            return(pastShift);
        }
Пример #6
0
        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);
        }