using BarBusinessLogic.OfficePackage.HelperEnums;
using BarBusinessLogic.OfficePackage.HelperModels;

namespace BarBusinessLogic.OfficePackage
{
    public abstract class AbstractSaveToPdf
    {
        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> { "2cm", "3cm", "3cm", "4cm", "3cm" });

            CreateRow(new PdfRowParameters
            {
                Texts = new List<string> { "Номер", "Дата заказа", "Коктейль", "Статус", "Сумма" },
                Style = "NormalTitle",
                ParagraphAlignment = PdfParagraphAlignmentType.Center
            });

            foreach (var order in Info.Orders)
            {
                CreateRow(new PdfRowParameters
                {
                    Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.CocktailName, order.Status.ToString(), order.Sum.ToString() },
                    Style = "Normal",
                    ParagraphAlignment = PdfParagraphAlignmentType.Left
                });
            }
            CreateParagraph(new PdfParagraph { Text = $"Итого: {Info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });

            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);
    }
}
