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