using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VentaUniformes.Application.Interfaces;

namespace VentaUniformes.Application.VentasView.historico
{
    public class VentasHistoricoViewService: IVentasHistoricoViewService
    {
        IPersistenciaService _persistenciaService;
        IMapper _mapper;
        public VentasHistoricoViewService(IPersistenciaService persistenciaService, IMapper mapper)
        {
            _persistenciaService = persistenciaService;
            _mapper = mapper;
        }

        public async Task<VentasHistoricoViewModel> GetVentas()
        {
            var res = new VentasHistoricoViewModel();
            res.Alumno = "";
            res.Top = 25;
            return await GetVentas(res);
        }
        public async Task<VentasHistoricoViewModel> GetVentas(VentasHistoricoViewModel model)
        {

            var l = await _persistenciaService.GetSale(model.Top, model.Alumno);
            model.ventas = _mapper.Map<List<VentaLineHistoricoViewModel>>(l);
            return model;
        }
    }
}
