Exemplo n.º 1
0
        public virtual async Task <IActionResult> BanUser(string userId)
        {
            User userBan = await userManager.FindByIdAsync(userId);

            if (userBan == null)
            {
                return(BadRequest());
            }
            var roles = await userManager.GetRolesAsync(userBan);

            if (roles.Contains(RoleNames.Admin))
            {
                return(BadRequest());
            }

            var user = await GetUserAsync();

            await profileManager.BanUserAsync(user, userBan);

            return(Ok());
        }