public ActionResult Create(FormCollection collection) { Employee employee = new Employee(); try { // TODO: Add insert logic here UpdateModel(employee, collection); employeeRepository.Add(employee); employeeRepository.Save(); return RedirectToAction("Index"); } catch(Exception e) { return View(employee); } }
public ActionResult Edit(int id, FormCollection collection, Employee _employee) { Employee employee = employeeRepository.FindBy(x => x.Id == id).FirstOrDefault(); if (employee == null) return HttpNotFound(); try { // TODO: Add update logic here UpdateModel(employee, collection); employeeRepository.Edit(employee, employee.Id); employeeRepository.Save(); return RedirectToAction("Index"); } catch(Exception e) { ViewBag.Error = e.Data; return View("Error"); } }