public async Task <IActionResult> Edit(int id, [Bind("Id,Dep_LastName,Dep_FirstName,Relationship,EmployeeId")] Dependent dependent) { if (id != dependent.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dependent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DependentExists(dependent.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmployeeId"] = new SelectList(_context.employees, "EmployeeId", "EmployeeId", dependent.EmployeeId); return(View(dependent)); }
public async Task <IActionResult> Edit(int id, [Bind("EmployeeId,FullName,Gender,Department,Company")] Employee employee) { if (id != employee.EmployeeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.EmployeeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(employee)); }