Example #1
0
        public async Task <IActionResult> Delete(String id)
        {
            IdentityRole role = await rolePresentationService.FindById(id);

            if (role != null)
            {
                IdentityResult result = await rolePresentationService.Delete(role);

                if (result.Succeeded)
                {
                    RedirectToAction("Index");
                }
                else
                {
                    AddErrorsFromResult(result);
                }
            }
            else
            {
                ModelState.AddModelError("", "No role found");
            }

            return(RedirectToAction("Index"));
        }
Example #2
0
        public async Task<IActionResult> Edit(String id)
        {
            IdentityRole role = await rolePresentationService.FindById(id);
            List<ApplicationUser> members = new List<ApplicationUser>();
            List<ApplicationUser> nonMembers = new List<ApplicationUser>();

            foreach (var user in userAccountPresentationService.Users)
            {
                var list = await userAccountPresentationService.IsInRole(user, role.Name)
                    ? members
                    : nonMembers;

                list.Add(user);
            }

            return View(new RoleEditModel()
            {
                Role = role,
                Members = members,
                NonMembers = nonMembers
            });
        }