Merge remote-tracking branch 'origin/250809_UserProfile' into 250810_UserProfileAdmin
# Conflicts: # DrinkRateAPI/Services/UserProfileService.cs
This commit is contained in:
commit
3230a5ed0f
4 changed files with 47 additions and 1 deletions
6
DrinkRateAPI/ApiModels/UserProfile/UserProfileGet.cs
Normal file
6
DrinkRateAPI/ApiModels/UserProfile/UserProfileGet.cs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
namespace DrinkRateAPI.ApiModels.UserProfile;
|
||||||
|
|
||||||
|
public class UserProfileGet
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
6
DrinkRateAPI/ApiModels/UserProfile/UserProfilePut.cs
Normal file
6
DrinkRateAPI/ApiModels/UserProfile/UserProfilePut.cs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
namespace DrinkRateAPI.ApiModels.UserProfile;
|
||||||
|
|
||||||
|
public class UserProfilePut
|
||||||
|
{
|
||||||
|
public string UserName { get; set; }
|
||||||
|
}
|
18
DrinkRateAPI/Controllers/UserProfileController.cs
Normal file
18
DrinkRateAPI/Controllers/UserProfileController.cs
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,21 @@
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
using DrinkRateAPI.ApiModels.UserProfile;
|
||||||
using DrinkRateAPI.Contexts;
|
using DrinkRateAPI.Contexts;
|
||||||
using DrinkRateAPI.DbEntities;
|
using DrinkRateAPI.DbEntities;
|
||||||
|
using DrinkRateAPI.DbEntities;
|
||||||
using DrinkRateAPI.Exceptions;
|
using DrinkRateAPI.Exceptions;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
|
||||||
namespace DrinkRateAPI.Services;
|
namespace DrinkRateAPI.Services;
|
||||||
|
|
||||||
public class UserProfileService(ApplicationDbContext context)
|
public class UserProfileService(ApplicationDbContext context,
|
||||||
|
ApplicationUserService applicationUserService)
|
||||||
{
|
{
|
||||||
private ApplicationDbContext _context = context;
|
private ApplicationDbContext _context = context;
|
||||||
|
private ApplicationUserService _applicationUserService = applicationUserService;
|
||||||
|
|
||||||
public bool IsUserProfileAdmin(DbUserProfile userProfile)
|
public bool IsUserProfileAdmin(DbUserProfile userProfile)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +31,15 @@ public class UserProfileService(ApplicationDbContext context)
|
||||||
|
|
||||||
return userProfile;
|
return userProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<UserProfileGet> PutUserProfileAsync(UserProfilePut userProfile, ClaimsPrincipal identity)
|
||||||
|
{
|
||||||
|
var profile = _applicationUserService.UserProfileByApplicationUserAsync(identity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
|
||||||
public DbUserProfile GetUserProfileById(string userId)
|
public DbUserProfile GetUserProfileById(string userId)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue