public ActionResult Edit(int id, string name, DateTime? hireDate) { var repository = new EmployeeRepository(); var employee = repository.FindByID(id); if (ModelState.IsValid) { employee.Name = name; employee.HireDate = hireDate.Value; repository.Save(employee); return RedirectToAction("Index"); } if (!hireDate.HasValue) { ModelState.AddModelError("HireDate", "Could not parse the datetime value"); } return View(employee); }
// // GET: /Employee/ public ActionResult Index() { var repository = new EmployeeRepository(); var employees = repository.FindAll(); return View(employees); }
// // GET: /Employee/Edit/5 public ActionResult Edit(int id) { var repository = new EmployeeRepository(); var employee = repository.FindByID(id); return View(employee); }