Example #1
0
        public async Task <IActionResult> Create(IFormCollection collection)
        {
            PortfolioRole role = new PortfolioRole
            {
                Name = collection["RoleName"]
            };
            IdentityResult result = await _roleManager.CreateAsync(role);

            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
 public static void SeedRoles
     (RoleManager <PortfolioRole> roleManager)
 {
     if (!roleManager.RoleExistsAsync("Administrator").Result)
     {
         PortfolioRole role = new PortfolioRole();
         role.Name = "Administrator";
         IdentityResult roleResult = roleManager.CreateAsync(role).Result;
     }
     if (!roleManager.RoleExistsAsync("Moderator").Result)
     {
         PortfolioRole role = new PortfolioRole();
         role.Name = "Moderator";
         IdentityResult roleResult = roleManager.CreateAsync(role).Result;
     }
     if (!roleManager.RoleExistsAsync("User").Result)
     {
         PortfolioRole role = new PortfolioRole();
         role.Name = "User";
         IdentityResult roleResult = roleManager.CreateAsync(role).Result;
     }
 }