Exemplo n.º 1
0
        public IActionResult DeleteShift(int id, EditShiftViewModel model)
        {
            Shift shift = context.Shifts.Single(x => x.ID == id);

            context.Remove(shift);
            context.SaveChanges();

            return(Redirect($"/admin/editschedule/{model.ScheduleId}"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditShift(string id)
        {
            Shift shift = _shiftCollection.GetById(id);
            EditShiftViewModel model = new EditShiftViewModel()
            {
                EmployeeEmails = _companyHandler.GetAllEmployeeEmails(_companyHandler.GetCompanyFromUser(User.FindFirstValue(ClaimTypes.NameIdentifier)).CompanyId),
                ShiftId        = shift.ShiftId,
                ScheduleId     = shift.ScheduleId,
                DateTime       = shift.ShiftDate,
                StartTime      = shift.StartTime,
                EndTime        = shift.EndTime,
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public IActionResult EditShift(EditShiftViewModel model)
        {
            Shift shift = context.Shifts.Include(x => x.Schedule).Single(x => x.ID == model.ShiftId);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            shift.StartTime = model.StartTime;
            shift.EndTime   = model.EndTime;
            context.SaveChanges();

            return(Redirect($"/admin/editschedule/{shift.ScheduleID}"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> EditShift(EditShiftViewModel model)
        {
            var user = await _userManager.FindByEmailAsync(model.UserEmail);

            Shift shift  = new Shift(model.ShiftId, model.ScheduleId, user.Id, model.DateTime, model.StartTime, model.EndTime);
            var   result = _shiftCollection.Update(shift);

            if (result != null)
            {
                return(RedirectToAction("EditSchedule", new { id = model.ScheduleId }));
            }

            model.EmployeeEmails = _companyHandler.GetAllEmployeeEmails(_companyHandler
                                                                        .GetCompanyFromUser(User.FindFirstValue(ClaimTypes.NameIdentifier)).CompanyId);
            return(View(model));
        }
Exemplo n.º 5
0
        public IActionResult EditShift(int id)
        {
            Shift shift = context.Shifts.Include(x => x.User).Include(x => x.Schedule).Single(x => x.ID == id);

            EditShiftViewModel model = new EditShiftViewModel
            {
                StartTime  = shift.StartTime,
                EndTime    = shift.EndTime,
                ShiftId    = shift.ID,
                User       = shift.User,
                Day        = shift.Day,
                ScheduleId = shift.ScheduleID
            };

            return(View(model));
        }