using Managing.Application.Abstractions.Services;
using Managing.Application.Trading.Commands;
using Managing.Domain.Trades;
using MediatR;

namespace Managing.Application.Trading
{
    public class GetPositionsCommandHandler : IRequestHandler<GetPositionsCommand, List<Position>>
    {
        private readonly ITradingService _tradingService;

        public GetPositionsCommandHandler(ITradingService tradingService)
        {
            _tradingService = tradingService;
        }

        public Task<List<Position>> Handle(GetPositionsCommand request, CancellationToken cancellationToken)
        {
            var positions = _tradingService.GetPositions(request.Initiator);
            return Task.FromResult(positions.ToList());
        }
    }
}
