public async Task <IActionResult> Edit(int id, [Bind("Id,Name,DepartmentEmail")] Department department) { if (id != department.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,DepartmentId,LecturerId,ModuleId")] Allocation allocation) { if (id != allocation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(allocation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AllocationExists(allocation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Set <Department>(), "Id", "Id", allocation.DepartmentId); ViewData["LecturerId"] = new SelectList(_context.Set <Lecturer>(), "Id", "Id", allocation.LecturerId); ViewData["ModuleId"] = new SelectList(_context.Set <Module>(), "Id", "Id", allocation.ModuleId); return(View(allocation)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Credits")] Module @module) { if (id != @module.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(@module); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ModuleExists(@module.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(@module)); }