Absolute garbage, trying to forward JWT, bad idea

This commit is contained in:
lumijiez
2025-06-06 22:27:55 +03:00
parent 6c2c846a21
commit 87c4f27de5
23 changed files with 581 additions and 2202 deletions

View File

@@ -0,0 +1,36 @@
using Imprink.Domain.Entities.Users;
using Imprink.Domain.Repositories;
using Imprink.Infrastructure.Database;
using Microsoft.EntityFrameworkCore;
namespace Imprink.Infrastructure.Repositories;
public class RoleRepository(ApplicationDbContext context) : IRoleRepository
{
public async Task<IEnumerable<Role>> GetAllRolesAsync(CancellationToken cancellationToken = default)
{
return await context.Roles
.AsNoTracking()
.ToListAsync(cancellationToken);
}
public async Task<Role?> GetRoleByIdAsync(Guid roleId, CancellationToken cancellationToken = default)
{
return await context.Roles
.AsNoTracking()
.FirstOrDefaultAsync(r => r.Id == roleId, cancellationToken);
}
public async Task<Role?> GetRoleByNameAsync(string roleName, CancellationToken cancellationToken = default)
{
return await context.Roles
.AsNoTracking()
.FirstOrDefaultAsync(r => r.RoleName == roleName, cancellationToken);
}
public async Task<bool> RoleExistsAsync(Guid roleId, CancellationToken cancellationToken = default)
{
return await context.Roles
.AnyAsync(r => r.Id == roleId, cancellationToken);
}
}