public ActionResult EditRole(string name, ManageMessageId? Message = null) { var role = this.ApplicationDbContext.Roles.First(r => r.Name == name); var model = new EditRoleViewModel(role); ViewBag.MessageId = Message; ViewBag.Title = "Edit Role"; return View(model); }
public async Task<ActionResult> EditRole(EditRoleViewModel model) { if (ModelState.IsValid) { var identityManager = new IdentityManager(); if (model.Id != null) { var role = await identityManager.GetRoleByNameAsync(model.RoleName); await identityManager.UpdateRoleAsync(role); } else { await identityManager.CreateRoleAsync(model.RoleName); } await this.ApplicationDbContext.SaveChangesAsync(); return RedirectToAction("Index"); } return View(model); }
public ActionResult CreateRole() { var model = new EditRoleViewModel(); ViewBag.Title = "Create Role"; return View("EditRole", model); }