create query to get crypto stat

This commit is contained in:
DavidGudEnough 2025-01-20 18:37:49 -05:00
parent ff1b284c25
commit 561d10fceb
Signed by: david.nguyen
GPG Key ID: 0B95DC36355BEB37
3 changed files with 21 additions and 0 deletions

View File

@ -20,5 +20,6 @@
<ProjectReference Include="..\CH.CryptoStats.CoinMarketCap\CH.CryptoStats.CoinMarketCap.csproj" /> <ProjectReference Include="..\CH.CryptoStats.CoinMarketCap\CH.CryptoStats.CoinMarketCap.csproj" />
<ProjectReference Include="..\CH.CryptoStats\CH.CryptoStats.Abstractions.csproj" /> <ProjectReference Include="..\CH.CryptoStats\CH.CryptoStats.Abstractions.csproj" />
<ProjectReference Include="..\CH.Dal\CH.Dal.csproj" /> <ProjectReference Include="..\CH.Dal\CH.Dal.csproj" />
<ProjectReference Include="..\CH.Energy.Abstractions\CH.Energy.Abstractions.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,18 @@
using CH.CryptoStats.CoinMarketCap;
using CH.Enum;
using OpenHarbor.CQRS.Abstractions;
namespace CH.CQRS.Query.CryptoStat;
public class CryptoStatQuery
{
public required string CoinName { get; set; }
public required string Currency { get; set; }
}
public class CryptoStatQueryHandler(CoinMarketCapService coinMarketCapService) : IQueryHandler<CryptoStatQuery, CH.CryptoStats.Abstractions.CryptoStats>
{
public Task<CH.CryptoStats.Abstractions.CryptoStats> HandleAsync(CryptoStatQuery query, CancellationToken cancellationToken = new CancellationToken())
{
return coinMarketCapService.GetCryptoStatsAsync(query.CoinName, query.Currency, cancellationToken);
}
}

View File

@ -7,6 +7,7 @@ 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.CryptoStat;
using CH.CQRS.Query.EnergyProvider; using CH.CQRS.Query.EnergyProvider;
using CH.CQRS.Query.EnergyRate; using CH.CQRS.Query.EnergyRate;
using CH.CQRS.Query.EnergyRateException; using CH.CQRS.Query.EnergyRateException;
@ -20,6 +21,7 @@ public class QueryModule : IModule
services.AddQuery<EnergyProviderQuery, EnergyProviderQueryResult, EnergyProviderQueryHandler>(); services.AddQuery<EnergyProviderQuery, EnergyProviderQueryResult, EnergyProviderQueryHandler>();
services.AddQuery<EnergyRateQuery, EnergyRateQueryResult, EnergyRateQueryHandler>(); services.AddQuery<EnergyRateQuery, EnergyRateQueryResult, EnergyRateQueryHandler>();
services.AddQuery<EnergyRateExceptionQuery, EnergyRateExceptionQueryResult, EnergyRateExceptionQueryHandler>(); services.AddQuery<EnergyRateExceptionQuery, EnergyRateExceptionQueryResult, EnergyRateExceptionQueryHandler>();
services.AddQuery<CryptoStatQuery, CH.CryptoStats.Abstractions.CryptoStats, CryptoStatQueryHandler>();
return services; return services;
} }
} }