public ActionResult Add(Department aDepartment) { try { bool errorStatus = false; string codeError = aDepartmentManager.CodeCheck(aDepartment.Code); if (codeError != null) { ViewBag.CodeError = codeError; errorStatus = true; } string nameError = aDepartmentManager.NameCheck(aDepartment.Name); if (nameError != null) { ViewBag.NameError = nameError; errorStatus = true; } if (errorStatus) { return(View(aDepartment)); } string msg = aDepartmentManager.Save(aDepartment); ViewBag.CodeError = null; ViewBag.NameError = null; ViewBag.Msg = msg; ModelState.Clear(); return(View(new Department())); } catch { return(View()); } }