public async Task<IActionResult> Edit(int id, [Bind("DepartmentId,DepartmentName,LocationId")] 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["LocationId"] = new SelectList(_context.Locations, "LocationId", "Address", department.LocationId); return View(department); }
public async Task <IActionResult> Edit(int id, [Bind("JobId,Title,MinSalary,MaxSalary")] Jobs jobs) { if (id != jobs.JobId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(jobs); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JobsExists(jobs.JobId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(jobs)); }
public async Task <IActionResult> Edit(int id, [Bind("EmployeeId,FirstName,LastName,Email,PhoneNum,HireDate,JobId,DepartmentId")] Employees employees) { if (id != employees.EmployeeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employees); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeesExists(employees.EmployeeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentId"] = new SelectList(_context.Department, "DepartmentId", "DepartmentName", employees.DepartmentId); ViewData["JobId"] = new SelectList(_context.Jobs, "JobId", "Title", employees.JobId); return(View(employees)); }