//
        // POST: /Admin/AddUserRole:id [id = Nombre del rol]
        public async Task <IActionResult> DetailsRole(string id)
        {
            if (id == null)
            {
                AddError("Error");
                return(RedirectToAction(nameof(AdminController.Index), "Admin"));
            }
            if (id.Length == 0)
            {
                AddError("Error");
                return(RedirectToAction(nameof(AdminController.Index), "Admin"));
            }
            if (!await _roleManager.RoleExistsAsync(id))
            {
                AddError("Error");
                return(RedirectToAction(nameof(AdminController.Index), "Admin"));
            }

            var model = new DetailsRoleViewModel()
            {
                IdentityRole        = GetRole(id),
                ApplicationUserList = await GetUsersInRole(id)
            };

            return(View(model));
        }
        public async Task <ActionResult> Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var role = await RoleManager.FindByIdAsync(id);

            if (role == null)
            {
                return(HttpNotFound());
            }
            DetailsRoleViewModel roleViewModel = new DetailsRoleViewModel(role);
            // Get the list of Users in this Role
            var users = new List <ApplicationUser>();

            // Get the list of Users in this Role
            foreach (var user in UserManager.Users.ToList())
            {
                if (await UserManager.IsInRoleAsync(user.Id, role.Name))
                {
                    users.Add(user);
                }
            }

            ViewBag.Users     = users;
            ViewBag.UserCount = users.Count();
            return(PartialView(roleViewModel));
        }