using VeterinaryBusinessLogic.OfficePackage.HelperEnums;
using VeterinaryBusinessLogic.OfficePackage.HelperModels;

namespace VeterinaryBusinessLogic.OfficePackage
{
	public abstract class AbstractSaveToExcelOwner
	{
		public void CreateReport(ExcelInfoOwner info)
		{
			CreateExcel(info);

			InsertCellInWorksheet(new ExcelCellParameters
			{
				ColumnName = "A",
				RowIndex = 1,
				Text = info.Title,
				StyleInfo = ExcelStyleInfoType.Title
			});

			MergeCells(new ExcelMergeParameters
			{
				CellFromName = "A1",
				CellToName = "C1"
			});

			uint rowIndex = 2;

			foreach (var rec in info.PetServices)
			{
				InsertCellInWorksheet(new ExcelCellParameters
				{
					ColumnName = "A",
					RowIndex = rowIndex,
					Text = rec.PetName,
					StyleInfo = ExcelStyleInfoType.Text
				});

				rowIndex++;

				foreach (var animal in rec.Services)
				{
					InsertCellInWorksheet(new ExcelCellParameters
					{
						ColumnName = "B",
						RowIndex = rowIndex,
						Text = animal.ServiceName,
						StyleInfo = ExcelStyleInfoType.TextWithBroder
					});

					rowIndex++;
				}

				rowIndex++;
			}

			SaveExcel(info);
		}

		protected abstract void CreateExcel(ExcelInfoOwner info);

		protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);

		protected abstract void MergeCells(ExcelMergeParameters excelParams);

		protected abstract void SaveExcel(ExcelInfoOwner info);
	}
}
