25 lines
864 B
C#
25 lines
864 B
C#
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, 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;
|
|
}
|
|
} |