From dad144a80fdb3206466f9cf62424fbe90a049fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Vrabec?= Date: Sun, 10 Aug 2025 16:35:36 +0200 Subject: [PATCH] Create user profile service base --- .../ApiModels/UserProfile/UserProfileGet.cs | 6 +++++ .../ApiModels/UserProfile/UserProfilePut.cs | 6 +++++ .../Controllers/UserProfileController.cs | 18 ++++++++++++++ DrinkRateAPI/Services/UserProfileService.cs | 24 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 DrinkRateAPI/ApiModels/UserProfile/UserProfileGet.cs create mode 100644 DrinkRateAPI/ApiModels/UserProfile/UserProfilePut.cs create mode 100644 DrinkRateAPI/Controllers/UserProfileController.cs create mode 100644 DrinkRateAPI/Services/UserProfileService.cs diff --git a/DrinkRateAPI/ApiModels/UserProfile/UserProfileGet.cs b/DrinkRateAPI/ApiModels/UserProfile/UserProfileGet.cs new file mode 100644 index 0000000..ed241cf --- /dev/null +++ b/DrinkRateAPI/ApiModels/UserProfile/UserProfileGet.cs @@ -0,0 +1,6 @@ +namespace DrinkRateAPI.ApiModels.UserProfile; + +public class UserProfileGet +{ + +} \ No newline at end of file diff --git a/DrinkRateAPI/ApiModels/UserProfile/UserProfilePut.cs b/DrinkRateAPI/ApiModels/UserProfile/UserProfilePut.cs new file mode 100644 index 0000000..020071d --- /dev/null +++ b/DrinkRateAPI/ApiModels/UserProfile/UserProfilePut.cs @@ -0,0 +1,6 @@ +namespace DrinkRateAPI.ApiModels.UserProfile; + +public class UserProfilePut +{ + public string UserName { get; set; } +} \ No newline at end of file diff --git a/DrinkRateAPI/Controllers/UserProfileController.cs b/DrinkRateAPI/Controllers/UserProfileController.cs new file mode 100644 index 0000000..3405fd6 --- /dev/null +++ b/DrinkRateAPI/Controllers/UserProfileController.cs @@ -0,0 +1,18 @@ +using System.Security.Claims; +using DrinkRateAPI.ApiModels.UserProfile; +using Microsoft.AspNetCore.Mvc; + +namespace DrinkRateAPI.Controllers; + +[ApiController] +[Route("user_profile")] +public class UserProfileController : ControllerBase +{ + [HttpPut(Name = "user_profile")] + public UserProfileGet PutUserProfile(UserProfilePut userProfile) + { + throw new ApplicationException(); + var x = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; //HttpContext.User.Identities.First(); + return new(); + } +} \ No newline at end of file diff --git a/DrinkRateAPI/Services/UserProfileService.cs b/DrinkRateAPI/Services/UserProfileService.cs new file mode 100644 index 0000000..3bf12f8 --- /dev/null +++ b/DrinkRateAPI/Services/UserProfileService.cs @@ -0,0 +1,24 @@ +using System.Security.Claims; +using DrinkRateAPI.ApiModels.UserProfile; +using DrinkRateAPI.Contexts; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + + +namespace DrinkRateAPI.Services; + +public class UserProfileService(ApplicationDbContext context, + ApplicationUserService applicationUserService) +{ + private ApplicationDbContext _context = context; + private ApplicationUserService _applicationUserService = applicationUserService; + + public async Task PutUserProfileAsync(UserProfilePut userProfile, ClaimsPrincipal identity) + { + var profile = _applicationUserService.UserProfileByApplicationUserAsync(identity); + + + + return new(); + } +} \ No newline at end of file