public async Task <IActionResult> Create([Bind("Name,NormalizedName")] NetCoreIdentityRole role) { if (string.IsNullOrEmpty(role.Name)) { ModelState.AddModelError("Name", "Name is required"); } //if (string.IsNullOrEmpty(role.NormalizedName)) //{ // ModelState.AddModelError("NormalizedName", "NormalizedName is required"); //} if (ModelState.IsValid) { role.NormalizedName = role.Name.ToUpper(); await RoleManager.CreateAsync(role); return(Json(Url.Action(nameof(Index)))); } return(PartialView("_Create", role)); }
public async Task <IActionResult> Edit([Bind("Name,NormalizedName")] NetCoreIdentityRole role) { var roleData = await RoleManager.FindByIdAsync(role.Id); if (roleData == null) { return(NotFound()); } if (string.IsNullOrEmpty(role.Name)) { ModelState.AddModelError("Name", "Name is required"); } if (ModelState.IsValid) { roleData.Name = role.Name; roleData.NormalizedName = role.Name.ToUpper(); await RoleManager.UpdateAsync(role); return(Json(Url.Action(nameof(Index)))); } return(PartialView("_Edit", role)); }