public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Code,CountryId,DesignationId")] 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))); } ViewData["CountryId"] = new SelectList(_context.Country, "Id", "Id", employee.CountryId); ViewData["DesignationId"] = new SelectList(_context.Designation, "Id", "Id", employee.DesignationId); return(View(employee)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Designation1,Code")] Designation designation) { if (id != designation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(designation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DesignationExists(designation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(designation)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Country country) { if (id != country.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(country); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(country.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(country)); }