コード例 #1
0
        public ActionResult Create(ApplicationRole applicationRole)
        {
            if (string.IsNullOrEmpty(applicationRole.Name))
            {
                ModelState.AddModelError("Errors", "Name is required, up to 128 characters!");

                var applicationRoles = applicationRoleRepository.GetApplicationRoles();

                var viewModel = new ApplicationRoleContainerViewModel(applicationRoles);

                return(View("Index", viewModel));
            }

            applicationRole.MakeActive();
            applicationRoleRepository.Add(applicationRole);
            unitOfWork.Complete();

            return(RedirectToAction("Index"));
        }