public async Task <IActionResult> Edit(int id, [Bind("DepartmentId,Name,BuildingId")] Department department) { if (id != department.DepartmentId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.DepartmentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BuildingId"] = new SelectList(_context.Set <Building>(), "BuildingId", "Name", department.BuildingId); return(View(department)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,DepartmentId")] Employee employee) { if (id != employee.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Set <Department>(), "DepartmentId", "Name", employee.DepartmentId); return(View(employee)); }
public async Task <IActionResult> Edit(int id, [Bind("BuildingId,Name")] Building building) { if (id != building.BuildingId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(building); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuildingExists(building.BuildingId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(building)); }