Example #1
0
        public async Task <IActionResult> Create(ShiftEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var shift = new ShiftModel
            {
                ShiftName = model.ShiftName,
                StartTime = model.StartTime,
                EndTime   = model.EndTime
            };

            await _shiftService.AddAsync(shift);

            return(RedirectToAction(nameof(Index)));
        }
Example #2
0
        public async Task <IActionResult> Edit(int id)
        {
            var shift = await _shiftService.GetByIdAsync(id);

            if (shift == null)
            {
                return(NotFound());
            }

            var editModel = new ShiftEditViewModel
            {
                ShiftId   = shift.ShiftId,
                ShiftName = shift.ShiftName,
                StartTime = shift.StartTime,
                EndTime   = shift.EndTime
            };

            return(View(editModel));
        }