Exemple #1
0
        public FutureShiftModel UptdatePartialFutureShift(FutureShiftModel futureShiftModel)
        {
            FutureShift futureShift = DB.FutureShifts.SingleOrDefault(f => f.ShiftId == futureShiftModel.ShiftId);

            if (futureShift == null)
            {
                return(null);
            }

            if (futureShift.ShiftTypeId != null)
            {
                futureShift.ShiftTypeId = futureShiftModel.ShiftTypeId;
            }

            if (futureShift.EmployeeId != null)
            {
                futureShift.EmployeeId = futureShiftModel.EmployeeId;
            }

            if (futureShift.Started != null)
            {
                futureShift.Started = futureShiftModel.Started;
            }

            if (futureShift.Ended != null)
            {
                futureShift.Ended = futureShiftModel.Ended;
            }

            DB.SaveChanges();
            return(futureShiftModel);
        }
 public FutureShiftModel(FutureShift futureShift)
 {
     ShiftId     = futureShift.ShiftId;
     ShiftTypeId = futureShift.ShiftTypeId;
     EmployeeId  = futureShift.EmployeeId;
     Started     = futureShift.Started;
     Ended       = futureShift.Ended;
 }
Exemple #3
0
        public FutureShiftModel AddFutureShiftModel(FutureShiftModel futureShiftModel)
        {
            FutureShift futureShift = futureShiftModel.ConvertToFutureShift();

            DB.FutureShifts.Add(futureShift);
            DB.SaveChanges();
            futureShiftModel.ShiftId = futureShift.ShiftId;
            return(futureShiftModel);
        }
Exemple #4
0
        public void DeleteFutureShift(int id)
        {
            FutureShift futureShiftToDelete = DB.FutureShifts.SingleOrDefault(p => p.ShiftId == id);

            if (futureShiftToDelete == null)
            {
                return;
            }
            DB.FutureShifts.Remove(futureShiftToDelete);
            DB.SaveChanges();
        }
        public FutureShift ConvertToFutureShift()
        {
            FutureShift futureShift = new FutureShift
            {
                ShiftId     = ShiftId,
                ShiftTypeId = ShiftTypeId,
                EmployeeId  = EmployeeId,
                Started     = Started,
                Ended       = Ended
            };

            return(futureShift);
        }