예제 #1
0
        public async Task<ActionResult> Create(RoleViewModel roleViewModel)
        {
            if (ModelState.IsValid)
            {
                //initialize ApplicationRole instead of IdentityRole
                var role = new ApplicationRole(roleViewModel.Name);

                //save the new description property
                role.Description = 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
 public async Task<ActionResult> Create(RoleViewModel roleViewModel)
 {
     if (ModelState.IsValid)
     {
         var role = new ApplicationRole(roleViewModel.Name);
         var roleresult = await RoleManager.CreateAsync(role);
         if (!roleresult.Succeeded)
         {
             ModelState.AddModelError("", roleresult.Errors.First());
             return View();
         }
         return RedirectToAction("Index");
     }
     return View();
 }