diff --git a/CH.CQRS/Query/EnergyProvider/EnergyProviderQuery.cs b/CH.CQRS/Query/EnergyProvider/EnergyProviderQuery.cs new file mode 100644 index 0000000..2cb66bf --- /dev/null +++ b/CH.CQRS/Query/EnergyProvider/EnergyProviderQuery.cs @@ -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 +{ + public async Task HandleAsync(EnergyProviderQuery query, CancellationToken cancellationToken = new CancellationToken()) + { + var energyProviders = await dbContext.EnergyProviders.ToListAsync(cancellationToken); + var energyProviderQueryResult = new EnergyProviderQueryResult + { + Data = energyProviders + }; + return energyProviderQueryResult; + } +} \ No newline at end of file diff --git a/CH.CQRS/Query/EnergyProvider/EnergyProviderQueryResult.cs b/CH.CQRS/Query/EnergyProvider/EnergyProviderQueryResult.cs new file mode 100644 index 0000000..557041a --- /dev/null +++ b/CH.CQRS/Query/EnergyProvider/EnergyProviderQueryResult.cs @@ -0,0 +1,6 @@ +namespace CH.CQRS.Query.EnergyProvider; + +public class EnergyProviderQueryResult +{ + public required List Data { get; set; } +} \ No newline at end of file diff --git a/CH.CQRS/Query/EnergyRate/EnergyRateQuery.cs b/CH.CQRS/Query/EnergyRate/EnergyRateQuery.cs new file mode 100644 index 0000000..0df763a --- /dev/null +++ b/CH.CQRS/Query/EnergyRate/EnergyRateQuery.cs @@ -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 +{ + public async Task HandleAsync(EnergyRateQuery query, CancellationToken cancellationToken = new CancellationToken()) + { + var energyRates = await dbContext.EnergyRates.ToListAsync(cancellationToken); + var energyRateQueryResult = new EnergyRateQueryResult + { + Data = energyRates + }; + return energyRateQueryResult; + } +} \ No newline at end of file diff --git a/CH.CQRS/Query/EnergyRate/EnergyRateQueryResult.cs b/CH.CQRS/Query/EnergyRate/EnergyRateQueryResult.cs new file mode 100644 index 0000000..6bc92b4 --- /dev/null +++ b/CH.CQRS/Query/EnergyRate/EnergyRateQueryResult.cs @@ -0,0 +1,6 @@ +namespace CH.CQRS.Query.EnergyRate; + +public class EnergyRateQueryResult +{ + public required List Data { get; set; } +} \ No newline at end of file diff --git a/CH.CQRS/Query/EnergyRateException/EnergyRateExceptionQuery.cs b/CH.CQRS/Query/EnergyRateException/EnergyRateExceptionQuery.cs new file mode 100644 index 0000000..0385dcf --- /dev/null +++ b/CH.CQRS/Query/EnergyRateException/EnergyRateExceptionQuery.cs @@ -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 +{ + public async Task HandleAsync(EnergyRateExceptionQuery query, CancellationToken cancellationToken = new CancellationToken()) + { + var energyRateExceptions = await dbContext.EnergyRateExceptions.ToListAsync(cancellationToken); + var energyRateExceptionsQueryResult = new EnergyRateExceptionQueryResult + { + Data = energyRateExceptions, + }; + return energyRateExceptionsQueryResult; + } +} \ No newline at end of file diff --git a/CH.CQRS/Query/EnergyRateException/EnergyRateExceptionQueryResult.cs b/CH.CQRS/Query/EnergyRateException/EnergyRateExceptionQueryResult.cs new file mode 100644 index 0000000..a54a8f3 --- /dev/null +++ b/CH.CQRS/Query/EnergyRateException/EnergyRateExceptionQueryResult.cs @@ -0,0 +1,6 @@ +namespace CH.CQRS.Query.EnergyRateException; + +public class EnergyRateExceptionQueryResult +{ + public required List Data { get; set; } +} \ No newline at end of file diff --git a/CH.CQRS/QueryModule.cs b/CH.CQRS/QueryModule.cs index e6ec018..1535d36 100644 --- a/CH.CQRS/QueryModule.cs +++ b/CH.CQRS/QueryModule.cs @@ -7,6 +7,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using CH.CQRS.Query.EnergyProvider; +using CH.CQRS.Query.EnergyRate; +using CH.CQRS.Query.EnergyRateException; namespace CH.CQRS; public class QueryModule : IModule @@ -14,6 +17,9 @@ public class QueryModule : IModule public IServiceCollection ConfigureServices(IServiceCollection services) { services.AddQuery(); + services.AddQuery(); + services.AddQuery(); + services.AddQuery(); return services; } }