Ejemplo n.º 1
0
        //
        // GET: /Roles/Delete/5
        public async Task<ActionResult> Delete(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var role = await RoleManager.FindByIdAsync(id);
            if (role == null)
            {
                return HttpNotFound();
            }

            var viewModel = new RoleViewModel
            {
                Id = role.Id,
                Name = role.Name
            };

            return View(viewModel);
        }
Ejemplo n.º 2
0
 public async Task<ActionResult> Create(RoleViewModel roleViewModel)
 {
     if (ModelState.IsValid)
     {
         var role = new IdentityRole(roleViewModel.Name);
         var roleresult = await RoleManager.CreateAsync(role);
         if (!roleresult.Succeeded)
         {
             ModelState.AddModelError("", roleresult.Errors.First());
             return View();
         }
         return RedirectToAction("Index");
     }
     return View();
 }