Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "DepartmentId,DeptName,DeptCode,DeptCredit,Adminstrator,StratDate,Building")] Department department)
        {
            if (ModelState.IsValid)
            {
                if (!_departmentBusiness.IsDeptNameExists(department.DeptName))
                {
                    if (!_departmentBusiness.IsDeptCodeExists(department.DeptCode))
                    {
                        _departmentBusiness.Add(department);
                        ViewBag.Message = "Department Created Successfully!";
                        // return RedirectToAction("Index");
                    }
                    else
                    {
                        ViewBag.Message = "Department Code Already Exists !";
                    }
                }
                else
                {
                    ViewBag.Message = "Department Name Already Exists !";
                }
            }

            return(View(department));
        }