drinkrate/DrinkRateAPI/Controllers/UserProfileController.cs
Martin Velebil cfa0da8082 Merge branch 'main' into 250811_ProductCompanyTable
# Conflicts:
#	DrinkRateAPI/Controllers/UserProfileController.cs
2025-08-12 06:52:40 +02:00

49 lines
No EOL
1.5 KiB
C#

using DrinkRateAPI.ApiModels.UserProfile;
using DrinkRateAPI.AuthorizationPolicies;
using DrinkRateAPI.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace DrinkRateAPI.Controllers;
[ApiController]
[Route("userProfile")]
public class UserProfileController : ControllerBase
{
private readonly UserProfileService _userProfileService;
public UserProfileController(UserProfileService userProfileService)
{
_userProfileService = userProfileService;
}
[HttpPut]
[Produces("application/json")]
public async Task<UserProfileGet> PutUserProfileSelf([FromBody] UserProfileSelfPut userProfile)
{
return await _userProfileService.PutUserProfileSelfAsync(User, userProfile);
}
[HttpGet]
[Produces("application/json")]
public async Task<UserProfileGet> GetUserProfileSelf()
{
return await _userProfileService.GetUserProfileSelfAsync(User);
}
[HttpPut("{userId}")]
[Authorize(Policy = PolicyConstants.AdminOnly)]
[Produces("application/json")]
public async Task<UserProfileGet> PutUserProfile(string userId, [FromBody] UserProfilePut userProfile)
{
return await _userProfileService.PutUserProfileAsync(User, userProfile, userId);
}
[HttpGet("{userId}")]
[Authorize(Policy = PolicyConstants.AdminOnly)]
[Produces("application/json")]
public async Task<UserProfileGet> GetUserProfile(string userId)
{
return await _userProfileService.GetUserProfileAsync(User, userId);
}
}