public async Task <IActionResult> Edit(int id, [Bind("DepartmentID,Name,CompanyID")] 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["CompanyID"] = new SelectList(_context.Company, "CompanyID", "CompanyID", department.CompanyID); //return View(department); //return Redirect("/Departments?=" + department.CompanyID); return(RedirectToAction("Index", "Companies")); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,City,Business,TurnOver")] Company company) { if (id != company.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(company); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyExists(company.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(company)); }
public async Task <IActionResult> Edit(int id, [Bind("EmployeeID,LastName,FirstName,Gender,Birthdate,Occupation,DepartmentID")] 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)); } ViewData["Department"] = new SelectList(_context.Department, "DepartmentID", "Name", employee.Department); //return Redirect("/Employees?=" + employee.DepartmentID); return(RedirectToAction("Index", "Companies")); }