using Edge.Core.Domain.FccOrderInfo.Input;
using Edge.Core.Domain.FccOrderInfo.Output;
using FccLite.Web.Repositories.FccOrderInfo;

namespace FccLite.Web.Services.FccOrderInfo
{
    public class OrderInfoService : IOrderInfoService
    {
        private readonly IOrderInfoReposity _orderInfoReposity;
        public OrderInfoService(IOrderInfoReposity orderInfoReposity) 
        {
            _orderInfoReposity = orderInfoReposity;
        }


        public async Task<OrderInfoOutput> GetPage(OrderInfoPageInput orderInfoPageInput)
        {
            //throw new NotImplementedException();
            IEnumerable<Edge.Core.Domain.FccOrderInfo.FccOrderInfo> enumerable = await _orderInfoReposity.GetPage(orderInfoPageInput);
            List<OrderInfo> orderInfos = enumerable.Select(order => new OrderInfo(order)).ToList();
            return new OrderInfoOutput()
            {
                Total = orderInfos.Count,
                List = orderInfos
            };
        }
    }
}
