using DrinkRateAPI.ApiModels.UserProfile; using DrinkRateAPI.Services; using Microsoft.AspNetCore.Mvc; namespace DrinkRateAPI.Controllers; [ApiController] [Route("admin")] 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("adminStatus")] [Produces("application/json")] public async Task PutUserAdminStatus([FromBody] ChangeUserAdminStatusRequest request) { var userProfile = await _applicationUserService.UserProfileByApplicationUserAsync(User); if (!_userProfileService.IsUserProfileAdmin(userProfile)) { return Unauthorized(); } var changedProfile = await _userProfileService.ChangeUserAdminStatusAsync(request.UserId, request.ChangeStatusTo); return Ok(changedProfile); } }