public async Task <IActionResult> CreateRol(CreateRolViewModel model) { if (ModelState.IsValid) { IdentityRole identityRole = new IdentityRole { Name = model.NameRole }; IdentityResult result = await processRoles.CreateAsync(identityRole); if (result.Succeeded) { return(RedirectToAction("index", "home")); } foreach (IdentityError error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(model)); }
public async Task <IActionResult> CreateRol(CreateRolViewModel model) { if (ModelState.IsValid) { IdentityRole identityRole = new IdentityRole { Name = model.RoleName }; IdentityResult result = await roleManager.CreateAsync(identityRole); if (result.Succeeded) { return(RedirectToAction("ListRoles", "administracion")); } foreach (IdentityError error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(model)); }