public async Task <IActionResult> Edit(int id, [Bind("id,DepartmentName")] Departments departments) { if (id != departments.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(departments); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentsExists(departments.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(departments)); }
public async Task <IActionResult> Edit(int id, [Bind("id,FName,LName,Phone,Address,City,State,Zipcode,DepartmentID")] Employees employees) { if (id != employees.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employees); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeesExists(employees.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentID"] = new SelectList(_context.Departments, "id", "DepartmentName", employees.DepartmentID); return(View(employees)); }