public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Surname,Address,Qualification,ContactNo,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))); } ViewBag.DepartmentID = new SelectList(_context.Department, "ID", "Name", employee.DepartmentID); return(View(employee)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] 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)); }