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

24 lines
763 B
C#

using CH.CryptoStats.CoinMarketCap;
using CH.Enum;
using OpenHarbor.CQRS.Abstractions;
namespace CH.CQRS.Query.CryptoStat;
public class CryptoStatQuery
{
}
public class CryptoStatQueryHandler(CoinMarketCapService coinMarketCapService) : IQueryHandler<CryptoStatQuery, CryptoStatQueryResult>
{
public async Task<CryptoStatQueryResult> HandleAsync(CryptoStatQuery query, CancellationToken cancellationToken = new CancellationToken())
{
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;
}
}