add query energy provider, rate, rate exception
This commit is contained in:
parent
1451314d56
commit
04ded7c21b
22
CH.CQRS/Query/EnergyProvider/EnergyProviderQuery.cs
Normal file
22
CH.CQRS/Query/EnergyProvider/EnergyProviderQuery.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
namespace CH.CQRS.Query.EnergyProvider;
|
||||||
|
|
||||||
|
public class EnergyProviderQueryResult
|
||||||
|
{
|
||||||
|
public required List<Dal.DbEntity.EnergyProvider> Data { get; set; }
|
||||||
|
}
|
23
CH.CQRS/Query/EnergyRate/EnergyRateQuery.cs
Normal file
23
CH.CQRS/Query/EnergyRate/EnergyRateQuery.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
6
CH.CQRS/Query/EnergyRate/EnergyRateQueryResult.cs
Normal file
6
CH.CQRS/Query/EnergyRate/EnergyRateQueryResult.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace CH.CQRS.Query.EnergyRate;
|
||||||
|
|
||||||
|
public class EnergyRateQueryResult
|
||||||
|
{
|
||||||
|
public required List<Dal.DbEntity.EnergyRate> Data { get; set; }
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using CH.Dal;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using OpenHarbor.CQRS.Abstractions;
|
||||||
|
|
||||||
|
namespace CH.CQRS.Query.EnergyRateException;
|
||||||
|
|
||||||
|
public class EnergyRateExceptionQuery
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public class EnergyRateExceptionQueryHandler(CHDbContext dbContext) : IQueryHandler<EnergyRateExceptionQuery, EnergyRateExceptionQueryResult>
|
||||||
|
{
|
||||||
|
public async Task<EnergyRateExceptionQueryResult> HandleAsync(EnergyRateExceptionQuery query, CancellationToken cancellationToken = new CancellationToken())
|
||||||
|
{
|
||||||
|
var energyRateExceptions = await dbContext.EnergyRateExceptions.ToListAsync(cancellationToken);
|
||||||
|
var energyRateExceptionsQueryResult = new EnergyRateExceptionQueryResult
|
||||||
|
{
|
||||||
|
Data = energyRateExceptions,
|
||||||
|
};
|
||||||
|
return energyRateExceptionsQueryResult;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
namespace CH.CQRS.Query.EnergyRateException;
|
||||||
|
|
||||||
|
public class EnergyRateExceptionQueryResult
|
||||||
|
{
|
||||||
|
public required List<Dal.DbEntity.EnergyRateException> Data { get; set; }
|
||||||
|
}
|
@ -7,6 +7,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using CH.CQRS.Query.EnergyProvider;
|
||||||
|
using CH.CQRS.Query.EnergyRate;
|
||||||
|
using CH.CQRS.Query.EnergyRateException;
|
||||||
|
|
||||||
namespace CH.CQRS;
|
namespace CH.CQRS;
|
||||||
public class QueryModule : IModule
|
public class QueryModule : IModule
|
||||||
@ -14,6 +17,9 @@ public class QueryModule : IModule
|
|||||||
public IServiceCollection ConfigureServices(IServiceCollection services)
|
public IServiceCollection ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddQuery<HealthQuery, HealthQueryResult, HealthQueryHandler>();
|
services.AddQuery<HealthQuery, HealthQueryResult, HealthQueryHandler>();
|
||||||
|
services.AddQuery<EnergyProviderQuery, EnergyProviderQueryResult, EnergyProviderQueryHandler>();
|
||||||
|
services.AddQuery<EnergyRateQuery, EnergyRateQueryResult, EnergyRateQueryHandler>();
|
||||||
|
services.AddQuery<EnergyRateExceptionQuery, EnergyRateExceptionQueryResult, EnergyRateExceptionQueryHandler>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user