using Managing.Application.Abstractions; using Managing.Application.ManageBot.Commands; using MediatR; namespace Managing.Application.ManageBot { /// /// Handler for updating trading bot configurations /// public class UpdateBotConfigCommandHandler : IRequestHandler { private readonly IBotService _botService; public UpdateBotConfigCommandHandler(IBotService botService) { _botService = botService; } public async Task Handle(UpdateBotConfigCommand request, CancellationToken cancellationToken) { try { if (request.NewConfig == null) { throw new ArgumentException("New configuration is required"); } var bot = await _botService.GetBotByIdentifier(request.Identifier); if (bot == null) { throw new Exception($"Bot with identifier {request.Identifier} not found"); } return await _botService.UpdateBotConfiguration(request.Identifier, request.NewConfig); } catch (Exception ex) { throw new Exception($"Error updating bot configuration: {ex.Message}"); } } } }