Cleanup folder structure again

This commit is contained in:
lumijiez
2025-06-21 20:53:49 +03:00
parent f959770e25
commit ec78744d19
100 changed files with 195 additions and 232 deletions

View File

@@ -0,0 +1,36 @@
using Imprink.Domain.Entities;
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);
}
}