constellation-api/CH.CQRS/Query/EnergyRate/EnergyRateQuery.cs

23 lines
676 B
C#
Raw Permalink Normal View History

using CH.CQRS.Query.EnergyProvider;
using CH.Dal;
using Microsoft.EntityFrameworkCore;
using OpenHarbor.CQRS.Abstractions;
namespace CH.CQRS.Query.EnergyRate;
public class EnergyRateQuery
{
}
public class EnergyRateQueryHandler(CHDbContext dbContext) : IQueryHandler<EnergyRateQuery, EnergyRateQueryResult>
{
public async Task<EnergyRateQueryResult> HandleAsync(EnergyRateQuery query, CancellationToken cancellationToken = new CancellationToken())
{
var energyRates = await dbContext.EnergyRates.ToListAsync(cancellationToken);
var energyRateQueryResult = new EnergyRateQueryResult
{
Data = energyRates
};
return energyRateQueryResult;
}
}