From 561d10fcebd6abd5d1cf1fecd1171312928f425c Mon Sep 17 00:00:00 2001 From: DavidGudEnough Date: Mon, 20 Jan 2025 18:37:49 -0500 Subject: [PATCH] create query to get crypto stat --- CH.CQRS/CH.CQRS.csproj | 1 + CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs | 18 ++++++++++++++++++ CH.CQRS/QueryModule.cs | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs diff --git a/CH.CQRS/CH.CQRS.csproj b/CH.CQRS/CH.CQRS.csproj index bff4ccf..fa9958f 100644 --- a/CH.CQRS/CH.CQRS.csproj +++ b/CH.CQRS/CH.CQRS.csproj @@ -20,5 +20,6 @@ + diff --git a/CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs b/CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs new file mode 100644 index 0000000..154207b --- /dev/null +++ b/CH.CQRS/Query/CryptoStat/CryptoStatQuery.cs @@ -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 +{ + public Task HandleAsync(CryptoStatQuery query, CancellationToken cancellationToken = new CancellationToken()) + { + return coinMarketCapService.GetCryptoStatsAsync(query.CoinName, query.Currency, cancellationToken); + } +} \ No newline at end of file diff --git a/CH.CQRS/QueryModule.cs b/CH.CQRS/QueryModule.cs index 1535d36..f416bb6 100644 --- a/CH.CQRS/QueryModule.cs +++ b/CH.CQRS/QueryModule.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using CH.CQRS.Query.CryptoStat; using CH.CQRS.Query.EnergyProvider; using CH.CQRS.Query.EnergyRate; using CH.CQRS.Query.EnergyRateException; @@ -20,6 +21,7 @@ public class QueryModule : IModule services.AddQuery(); services.AddQuery(); services.AddQuery(); + services.AddQuery(); return services; } }