Esempio n. 1
0
        public JsonResult Create(RoleViewModel roleViewModel)
        {
            if (ModelState.IsValid)
            {
                IdentityResult roleresult = _userAccountService.CreateRole(roleViewModel.Name);

                if (!roleresult.Succeeded)
                {
                    ModelState.AddModelError("", roleresult.Errors.First());
                    throw new Exception(RQResources.Views.Shared.SharedStrings.um_database_store_error);
                }
                else
                {
                    return(Json(roleViewModel.Name));
                }
            }
            else
            {
                throw new Exception(RQResources.Views.Shared.SharedStrings.um_invalid_role_name);
            }
        }