public async Task <IActionResult> CreateRole(ERRole model) { var name = model.RoleName + ""; try { name = name.Trim(); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } if (ModelState.IsValid) { IdentityRole identityRole = new IdentityRole { Name = name }; IdentityResult result = await roleManager.CreateAsync(identityRole); if (result.Succeeded) { ViewBag.Success = "Successfully added: " + name; return(RedirectToAction("Index")); } foreach (IdentityError error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(model)); }
public ActionResult Create(ERRole Role) { try { ERRepositry.Instance.AddRole(Role); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(Guid id, ERRole Role) { try { ERRepositry.Instance.UpdateRole(Role); return(RedirectToAction("Index")); } catch { return(View()); } }
// // GET: /Role/Create public ActionResult Create() { ERRole Role = new ERRole(); return(View(Role)); }