using ComputerShopBusinessLogic.OfficePackage;
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.StorageContracts;
using ComputerShopContracts.ViewModels;
using ComputerShopContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComputerShopBusinessLogic.BusinessLogics
{
    public class ReportLogic : IReportLogic
    {
        private readonly IComponentStorage _componentStorage;
        private readonly ISupplyStorage _supplyStorage;
        private readonly IAssemblyStorage _assemblyStorage;
        private readonly IEquipmentReceivingStorage _receivingStorage;
        private readonly AbstractSaveToExcel _saveToExcel;
        private readonly AbstractSaveToWord _saveToWord;
        private readonly AbstractSaveToPdf _saveToPdf;

        public ReportLogic(IComponentStorage componentStorage, IAssemblyStorage assemblyStorage, IEquipmentReceivingStorage receivingStorage, ISupplyStorage supplyStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
        {
            _componentStorage = componentStorage;
            _assemblyStorage = assemblyStorage;
            _receivingStorage = receivingStorage;
            _supplyStorage = supplyStorage;
            _saveToExcel = saveToExcel;
            _saveToWord = saveToWord;
            _saveToPdf = saveToPdf;
        }

        public List<ReportComponentReceivingViewModel> GetComponentReceivings(List<int> ids)
        {
            var result = new List<ReportComponentReceivingViewModel>();

            List<ComponentViewModel> components = new List<ComponentViewModel>();           
            foreach (int id in ids)
            {
                var component = _componentStorage.GetElement(new ComponentSearchModel()
                {
                    Id = id,
                });
                if (component != null) components.Add(component);
            }
            

            return result;
        }

        public void SaveReceivingComponentsToWordFile(ReportBindingModel model)
        {
            //_saveToWord.CreateDoc(new WordInfoProvider
            //{
            //    FileName = model.FileName,
            //    Title = "Список получений по компонентам",
            //    ComponentReceivings = GetComponentReceivings(model.Ids)
            //});
        }

        public void SaveReceivingComponentsToXmlFile(ReportBindingModel mode)
        {

        }

        public List<ReportPurchaseReceivingViewModel> GetPurchaseReceiving()
        {
            throw new NotImplementedException();
        }

        public List<ReportPurchaseSupplyViewModel> GetPurchaseSupply()
        {
            throw new NotImplementedException();
        }

        public void SaveOrdersToPdfFile(ReportBindingModel model)
        {
            throw new NotImplementedException();
        }

        public void SavePackagesToWordFile(ReportBindingModel model)
        {
            throw new NotImplementedException();
        }

        public void SaveProductComponentToExcelFile(ReportBindingModel model)
        {
            throw new NotImplementedException();
        }
    }
}
