public async Task <IActionResult> Edit(int id, [Bind("ShiftRoleId,RoleName")] ShiftRole shiftRole) { if (id != shiftRole.ShiftRoleId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shiftRole); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShiftRoleExists(shiftRole.ShiftRoleId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(shiftRole)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ScheduleId")] ShiftRole shiftRole) { if (id != shiftRole.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(shiftRole); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShiftRoleExists(shiftRole.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ScheduleId"] = new SelectList(_context.Schedule, "Id", "Name", shiftRole.ScheduleId); return(View(shiftRole)); }
public async Task <IActionResult> Create([Bind("ShiftRoleId,RoleName")] ShiftRole shiftRole) { if (ModelState.IsValid) { _context.Add(shiftRole); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(shiftRole)); }
public async Task <IActionResult> Create([Bind("Id,Name,ScheduleId")] ShiftRole shiftRole) { if (ModelState.IsValid) { _context.Add(shiftRole); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ScheduleId"] = new SelectList(_context.Schedule, "Id", "Name", shiftRole.ScheduleId); return(View(shiftRole)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ShiftRole = await _context.ShiftRoles.FirstOrDefaultAsync(m => m.Id == id); if (ShiftRole == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ShiftRole = await _context.ShiftRoles.FindAsync(id); if (ShiftRole != null) { _context.ShiftRoles.Remove(ShiftRole); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }