public ActionResult Create([Bind(Include = "Id,FirstName,Email,PhoneNumber,DepartmentId")] Employee employee) { if (ModelState.IsValid) { m_repo.UpdateEmployee(employee); m_repo.SaveEmployee(employee); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(m_repo.GetAllDepartments(), "Id", "Name", employee.DepartmentId); return(View(employee)); }
public ActionResult Create([Bind(Include = "Id,FName,LName,DepartmentId")] Employee employee) { if (employee == null) { return(RedirectToAction("Create")); } if (ModelState.IsValid) { p_repo.SaveEmployee(employee); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(p_repo.GetDepartments(), "Id", "Name", employee.DepartmentId); return(View(employee)); }
public ActionResult Create(Employee employee) { try { // TODO: Add insert logic here if (ModelState.IsValid) { m_repo.SaveEmployee(employee); } return(RedirectToAction("Index")); } catch { return(View()); } }