Ejemplo n.º 1
0
 public ActionResult Create(vmDepartment dept)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (DeptManager)
             {
                 var item    = Mapper.Map <Department>(dept);
                 var success = DeptManager.AddDepartment(item);
                 if (success)
                 {
                     return(RedirectToAction("Index"));
                 }
                 throw new DataException("Failed to save " + dept.Name + " Department. Please try again.");
             }
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", ex.Message);
     }
     return(View(dept));
 }