create query to get crypto stat
This commit is contained in:
parent
ff1b284c25
commit
561d10fceb
@ -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>
|
||||||
|
18
CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs
Normal file
18
CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user