public async Task <IActionResult> Edit(int id, [Bind("RosterShiftId,RosterShiftName,IsActive")] RosterShift rosterShift) { if (id != rosterShift.RosterShiftId) { return(NotFound()); } if (ModelState.IsValid) { try { var _rosterShift = _context.RosterShifts.Single(e => e.RosterShiftId == id); _rosterShift.IsActive = rosterShift.IsActive; _rosterShift.RosterShiftName = rosterShift.RosterShiftName; _rosterShift.ModifiedOn = DateTime.Now; _context.Update(_rosterShift); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RosterShiftExists(rosterShift.RosterShiftId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(rosterShift)); }
public async Task <IActionResult> Create(RosterShift rosterShift) { if (ModelState.IsValid) { rosterShift.CreatedOn = DateTime.Now; rosterShift.IsActive = true; _context.Add(rosterShift); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(rosterShift)); }