public async Task<ActionResult> Create(RoleViewModel roleViewModel) { if (ModelState.IsValid) { //initialize ApplicationRole instead of IdentityRole var role = new ApplicationRole(roleViewModel.Name); //save the new description property role.Description = roleViewModel.Description; var roleresult = await RoleManager.CreateAsync(role); if (!roleresult.Succeeded) { ModelState.AddModelError("", roleresult.Errors.First()); return View(); } return RedirectToAction("Index"); } return View(); }
public async Task<ActionResult> Create(RoleViewModel roleViewModel) { if (ModelState.IsValid) { var role = new ApplicationRole(roleViewModel.Name); var roleresult = await RoleManager.CreateAsync(role); if (!roleresult.Succeeded) { ModelState.AddModelError("", roleresult.Errors.First()); return View(); } return RedirectToAction("Index"); } return View(); }