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 ViewResult Index() { var model = new HomePageViewModel(); /*var Employees = new Employee { Name = "tung" };*/ using (var context = new FirstAppDemoDbContext()) { SQLEmployeeData sqlData = new SQLEmployeeData(_context); /*sqlData.Add(Employees);*/ model.Employees = sqlData.GetAll(); } return(View(model)); }
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)); } }