Beispiel #1
0
        public async Task<ActionResult> AddRole(RoleViewModel model)
        {
            if (ModelState.IsValid)
            {
                var roleManager = HttpContext.GetOwinContext().Get<ApplicationRoleManager>();

                var newRole = new ApplicationRole(model.RoleName);
                newRole.Description = model.RoleDescription;

                var roleResult = await roleManager.CreateAsync(newRole);

                if (!roleResult.Succeeded)
                {
                    ModelState.AddModelError("", roleResult.Errors.First());
                    return View();
                }

                return RedirectToAction("AddRole");
            }


            return View();
        }
Beispiel #2
0
 public ViewResult AddRole()
 {
     var model = new RoleViewModel();
     return View(model);
 }