constellation-api/CH.CQRS/Query/EnergyProvider/EnergyProviderQuery.cs

22 lines
693 B
C#
Raw Normal View History

using CH.Dal;
using Microsoft.EntityFrameworkCore;
using OpenHarbor.CQRS.Abstractions;
namespace CH.CQRS.Query.EnergyProvider;
public class EnergyProviderQuery
{
}
public class EnergyProviderQueryHandler(CHDbContext dbContext) : IQueryHandler<EnergyProviderQuery, EnergyProviderQueryResult>
{
public async Task<EnergyProviderQueryResult> HandleAsync(EnergyProviderQuery query, CancellationToken cancellationToken = new CancellationToken())
{
var energyProviders = await dbContext.EnergyProviders.ToListAsync(cancellationToken);
var energyProviderQueryResult = new EnergyProviderQueryResult
{
Data = energyProviders
};
return energyProviderQueryResult;
}
}