using System.Security.Claims; using DrinkRateAPI.Contexts; using DrinkRateAPI.DbEntities; using DrinkRateAPI.Exceptions; using Microsoft.EntityFrameworkCore; namespace DrinkRateAPI.Services; public class ApplicationUserService(ApplicationDbContext context) { private ApplicationDbContext _context = context; public async Task UserProfileByApplicationUserAsync(ClaimsPrincipal identity) { var appUserId = identity.FindFirst(ClaimTypes.NameIdentifier)?.Value; var profile = await _context.UserProfiles .FirstAsync(x => x.ApplicationUserId.ToString() == appUserId && !x.IsDeleted) ?? throw new NotFoundException(); return profile; } }