public async Task<ActionResult> Create(RoleViewModel roleViewModel) { if (ModelState.IsValid) { var role = new ApplicationRole{Name = roleViewModel.Name}; var roleresult = await _roleManager.CreateAsync(role); if (!roleresult.Succeeded) { ModelState.AddModelError("", roleresult.Errors.First()); return View(); } return RedirectToAction("Index"); } return View(); }
// // GET: /Roles/Edit/Admin public async Task<ActionResult> Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var role = await _roleManager.FindByIdAsync(id.Value); if (role == null) { return HttpNotFound(); } var roleModel = new RoleViewModel { Id = role.Id, Name = role.Name }; return View(roleModel); }