constellation-api/CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs

24 lines
763 B
C#
Raw Normal View History

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-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
}
}