public virtual async Task<ApplicationIdentityResult> CreateAsync(ApplicationRole role) { var identityRole = role.ToIdentityRole(); var identityResult = await _roleManager.CreateAsync(identityRole).ConfigureAwait(false); role.CopyIdentityRoleProperties(identityRole); return identityResult.ToApplicationIdentityResult(); }
public ApplicationIdentityResult Create(ApplicationRole role) { var identityRole = role.ToIdentityRole(); var identityResult = _roleManager.Create(identityRole); role.CopyIdentityRoleProperties(identityRole); return identityResult.ToApplicationIdentityResult(); }
public async Task<ActionResult> Create(RoleViewModel roleViewModel) { if (ModelState.IsValid) { var role = new ApplicationRole{Name = roleViewModel.Name}; var roleresult = await _roleManager.CreateAsync(role); if (!roleresult.Succeeded) { ModelState.AddModelError("", roleresult.Errors.First()); return View(); } return RedirectToAction("Index"); } return View(); }