public ActionResult Create([Bind(Include = "Id,Name,RoomNumber,BuildingId")] Department department) { if (department == null) { return(RedirectToAction("Create")); } if (ModelState.IsValid) { p_repo.SaveDepartment(department); return(RedirectToAction("Index")); } ViewBag.BuildingId = new SelectList(p_repo.GetBuildings(), "Id", "Name", department.BuildingId); return(View(department)); }
public ActionResult Create(Department department) { try { // TODO: Add insert logic here if (ModelState.IsValid) { m_repo.SaveDepartment(department); } return(RedirectToAction("Index")); } catch { return(View()); } }