using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VetClinicBusinessLogic.OfficePackage.HelperEnums;
using VetClinicBusinessLogic.OfficePackage.HelperModels;
using VetClinicDataBaseImplement.Implements;

namespace VetClinicBusinessLogic.OfficePackage
{
	public abstract class AbstractSaveToPdfAdmin
	{
		public void CreateDoc(PdfInfo info)
		{
			CreatePdf(info);
			CreateParagraph(new PdfParagraph
			{
				Text = info.Title,
				Style =
		   "NormalTitle",
				ParagraphAlignment = PdfParagraphAlignmentType.Center
			});
			CreateParagraph(new PdfParagraph
			{
				Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style
		   = "Normal",
				ParagraphAlignment = PdfParagraphAlignmentType.Center
			});
			CreateTable(new List<string> { "4cm", "4cm", "4cm", "4cm" });
			CreateRow(new PdfRowParameters
			{
				Texts = new List<string> { "Дата", "Название визита", "Животное прививки", "Медикамент"},
				Style = "NormalTitle",
				ParagraphAlignment = PdfParagraphAlignmentType.Center
			});
			foreach (var visit in info.Visits)
			{
                CreateRow(new PdfRowParameters
                {
                    Texts = new List<string> { visit.DateVisit.ToString(), visit.VisitName, "", "" },
                    Style = "NormalTitle",
                    ParagraphAlignment = PdfParagraphAlignmentType.Center
                });
				
				foreach (var vaccination in visit.Vaccinations)
				{
					CreateRow(new PdfRowParameters
					{
						Texts = new List<string> { vaccination.DateStamp.ToString(), "", vaccination.AnimalName, "" },
						Style = "Normal",
						ParagraphAlignment = PdfParagraphAlignmentType.Center
					});
				}
				foreach (var medicine in visit.Medicines)
				{
					CreateRow(new PdfRowParameters
					{
						Texts = new List<string> { "", "", "", medicine.MedicineName },
						Style = "Normal",
						ParagraphAlignment = PdfParagraphAlignmentType.Center
					});
				}
			}
			SavePdf(info);
		}
		protected abstract void CreatePdf(PdfInfo info);
		protected abstract void CreateParagraph(PdfParagraph paragraph);
		protected abstract void CreateTable(List<string> columns);
		protected abstract void CreateRow(PdfRowParameters rowParameters);
		protected abstract void SavePdf(PdfInfo info);
	}
}
