using DocumentFormat.OpenXml.EMMA;
using DocumentFormat.OpenXml.Presentation;
using VeterinaryBusinessLogic.OfficePackage;
using VeterinaryBusinessLogic.OfficePackage.HelperModels;
using VeterinaryContracts.BindingModels;
using VeterinaryContracts.BusinessLogicContracts;
using VeterinaryContracts.SearchModels;
using VeterinaryContracts.StorageContracts;
using VeterinaryContracts.ViewModels;

namespace VeterinaryBusinessLogic.BusinessLogic
{
	public class ReportLogicOwner : IReportLogicOwner
	{
		private readonly IPetStorage _petStorage;
		private readonly AbstractSaveToExcelOwner _saveToExcel;
		private readonly AbstractSaveToWordOwner _saveToWord;
		public ReportLogicOwner(IPetStorage petStorage,
			AbstractSaveToExcelOwner saveToExcel, AbstractSaveToWordOwner saveToWord)
		{
			_petStorage = petStorage;
			_saveToExcel = saveToExcel;
			_saveToWord = saveToWord;
		}

		public List<ReportPetServicesViewModel> GetPetServices(ReportServicesBindingModel model)
		{
			return _petStorage.GetReportServices(new() { petsIds = model.Pets});
		}
		public List<ReportVisitsDrugsViewModel> GetVisitsDrugs(ReportVisitsDrugsBindingModel model)
		{
			return _petStorage.GetReportVisitsDrugs(new() { DateFrom = model.DateFrom, DateTo = model.DateTo });
		}
		public void SaveServicesToExcelFile(ReportServicesBindingModel model)
		{
			_saveToExcel.CreateReport(new ExcelInfoOwner
			{
				FileName = model.FileName,
				Title = "Список услуг для животных",
				PetServices = GetPetServices(model)
			});
		}

		public void SaveServicesToWordFile(ReportServicesBindingModel model)
		{
			_saveToWord.CreateDoc(new WordInfoOwner
			{
				FileName = model.FileName,
				Title = "Список услуг для животных",
				PetServices = GetPetServices(model)
			});
		}
	}
}
