Commit before refact factory into service

This commit is contained in:
2024-07-12 19:58:19 +07:00
parent 13e70cbf63
commit 0544749a69
11 changed files with 243 additions and 169 deletions

View File

@@ -1,30 +1,15 @@
using Managing.Application.Abstractions;
using Managing.Application.ManageBot.Commands;
using Managing.Core;
using MediatR;
namespace Managing.Application.ManageBot
{
public class GetActiveBotsCommandHandler : IRequestHandler<GetActiveBotsCommand, List<ITradingBot>>
public class GetActiveBotsCommandHandler(IBotService botService)
: IRequestHandler<GetActiveBotsCommand, List<ITradingBot>>
{
private readonly ITaskCache taskCache;
public GetActiveBotsCommandHandler(ITaskCache taskCache)
{
this.taskCache = taskCache;
}
public Task<List<ITradingBot>> Handle(GetActiveBotsCommand request, CancellationToken cancellationToken)
{
var cachedTask = taskCache.GetCache<AsyncLazy<ITradingBot>>();
var result = new List<ITradingBot>();
foreach (var item in cachedTask)
{
result.Add(item.Value.Result);
}
return Task.FromResult(result);
return Task.FromResult(botService.GetActiveBots());
}
}
}
}