2025-01-20 18:37:49 -05:00
|
|
|
using CH.CryptoStats.CoinMarketCap;
|
|
|
|
using CH.Enum;
|
|
|
|
using OpenHarbor.CQRS.Abstractions;
|
|
|
|
|
|
|
|
namespace CH.CQRS.Query.CryptoStat;
|
|
|
|
|
|
|
|
public class CryptoStatQuery
|
|
|
|
{
|
2025-01-27 18:58:42 -05:00
|
|
|
|
2025-01-20 18:37:49 -05:00
|
|
|
}
|
2025-01-21 17:58:20 -05:00
|
|
|
public class CryptoStatQueryHandler(CoinMarketCapService coinMarketCapService) : IQueryHandler<CryptoStatQuery, CryptoStatQueryResult>
|
2025-01-20 18:37:49 -05:00
|
|
|
{
|
2025-01-21 17:58:20 -05:00
|
|
|
public async Task<CryptoStatQueryResult> HandleAsync(CryptoStatQuery query, CancellationToken cancellationToken = new CancellationToken())
|
2025-01-20 18:37:49 -05:00
|
|
|
{
|
2025-01-21 17:58:20 -05:00
|
|
|
var listCrypto = new List<CH.CryptoStats.Abstractions.CryptoStats>();
|
|
|
|
var cryptoStats = await coinMarketCapService.GetCryptoStatsAsync("bitcoin", "cad", cancellationToken);
|
|
|
|
listCrypto.Add(cryptoStats);
|
|
|
|
var listStat = new CryptoStatQueryResult
|
|
|
|
{
|
|
|
|
Data = listCrypto
|
|
|
|
};
|
|
|
|
return listStat;
|
2025-01-20 18:37:49 -05:00
|
|
|
}
|
|
|
|
}
|