public IActionResult Details(int id) { using (var context = new FirstAppDemoDbContext()) { SQLEmployeeData sqlData = new SQLEmployeeData(_context); var employee = sqlData.Get(id); if (employee == null) { return(RedirectToAction("Index")); } return(View(employee)); } }
public IActionResult Edit(int id, EmployeeEditViewModel input) { using (var context = new FirstAppDemoDbContext()) { SQLEmployeeData sqlData = new SQLEmployeeData(_context); var employee = sqlData.Get(id); if (employee != null && ModelState.IsValid) { employee.Name = input.Name; _context.SaveChanges(); return(RedirectToAction("Details", new { id = employee.ID })); } return(View(employee)); } }