示例#1
0
        public ActionResult Create([Bind(Include = "DepartmentId,Name,ColourId")] Department department)
        {
            if (ModelState.IsValid)
            {
                var result = HRBusinessService.CreateDepartment(UserOrganisationId, department);
                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error);
                }
            }
            var viewModel = new DepartmentViewModel
            {
                Department  = department,
                ColoursList = HRBusinessService.RetrieveColours().ToList()
            };

            return(View(viewModel));
        }