using System.Security.Claims; using DrinkRateAPI.Contexts; using DrinkRateAPI.DbEntities; using DrinkRateAPI.Exceptions; using Microsoft.EntityFrameworkCore; namespace DrinkRateAPI.Services; public class UserProfileService(ApplicationDbContext context) { private ApplicationDbContext _context = context; public bool IsUserProfileAdmin(DbUserProfile userProfile) { return userProfile.IsAdmin; } public DbUserProfile ChangeUserAdminStatus(string userId, bool changeStatusTo) { var userProfile = GetUserProfileById(userId); userProfile.IsAdmin = changeStatusTo; _context.UserProfiles.Update(userProfile); _context.SaveChanges(); return userProfile; } public DbUserProfile GetUserProfileById(string userId) { var userProfile = _context.UserProfiles.FirstOrDefault(x => x.Id.ToString() == userId); return userProfile ?? throw new KeyNotFoundException($"User with ID {userId} not found"); } }