using Microsoft.EntityFrameworkCore;

using Monitoring.Core.Domain;
using Monitoring.Core.Domain.RolePrimitives;
using Monitoring.Infrastructure.Data;

namespace Monitoring.Repositories;

public class RoleRepository(
	DataContext dataContext
)
{
	public Task<Role?> Find(string role, CancellationToken cancellationToken)
	{
		var upperCaseRoleName = RoleUpperCaseName.Create(role);
		return dataContext.Roles
			.FirstOrDefaultAsync(x => x.UpperCaseName == upperCaseRoleName, cancellationToken);
	}
}