This commit is contained in:
2024-07-12 22:20:43 +07:00
parent 6718d08448
commit 67630c2deb
7 changed files with 62 additions and 60 deletions

View File

@@ -8,25 +8,16 @@ namespace Managing.Application.ManageBot;
public class DeleteBotCommandHandler : IRequestHandler<DeleteBotCommand, bool>
{
private readonly ILogger<DeleteBotCommandHandler> _log;
private readonly ITaskCache _taskCache;
private readonly IBotService _botService;
public DeleteBotCommandHandler(ITaskCache taskCache, ILogger<DeleteBotCommandHandler> log)
public DeleteBotCommandHandler(ILogger<DeleteBotCommandHandler> log, IBotService botService)
{
_taskCache = taskCache;
_log = log;
_botService = botService;
}
public Task<bool> Handle(DeleteBotCommand request, CancellationToken cancellationToken)
{
try
{
_taskCache.Invalidate(request.Name);
return Task.FromResult(true);
}
catch (Exception e)
{
_log.LogError(e.Message);
return Task.FromResult(false);
}
return _botService.DeleteBot(request.Name);
}
}
}