Exemple #1
0
        public async Task <IActionResult> CreateRole(AdminViewModel model)
        {
            if (!_context.Roles.Any(r => r.Name == model.Role.RoleName))
            {
                var role = new AppRole
                {
                    Name = model.Role.RoleName
                };

                var result = await _roleManager.CreateAsync(role);

                if (result.Succeeded)
                {
                    ViewBag.Message1 = "Role created";

                    // create blob container as well
                    BlobStorageService blobStorageService = new BlobStorageService();
                    blobStorageService.CreateContainer(model.Role.RoleName);
                }
                else
                {
                    ViewBag.Message1 = "Role not created";
                }
            }
            else
            {
                ViewBag.Message1 = "Role already exists";
            }

            return(View("Index"));
        }