using DrinkRateAPI.Requests; using DrinkRateAPI.Services; using Microsoft.AspNetCore.Mvc; namespace DrinkRateAPI.Controllers; [ApiController] [Route("[controller]")] public class AdminController : ControllerBase { private readonly ILogger _logger; private readonly ApplicationUserService _applicationUserService; private readonly UserProfileService _userProfileService; public AdminController(ILogger logger, ApplicationUserService applicationUserService, UserProfileService userProfileService) { _logger = logger; _applicationUserService = applicationUserService; _userProfileService = userProfileService; } [HttpPut] [Route("[action]")] [Produces("application/json")] public async Task PutUserAdminStatus([FromBody] ChangeUserAdminStatusRequest request) { var userProfile = await _applicationUserService.UserProfileByApplicationUserAsync(User); if (!_userProfileService.IsUserProfileAdmin(userProfile)) { return Unauthorized(); } var changedProfile = _userProfileService.ChangeUserAdminStatus(request.UserId, request.ChangeStatusTo); return Ok(changedProfile); } }