Пример #1
0
        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));
        }
Пример #2
0
 public ActionResult Create(Department department)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             m_repo.SaveDepartment(department);
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }