using TravelAgencyBusinessLogic.OfficePackage.HelperEnums; using TravelAgencyBusinessLogic.OfficePackage.HelperModels; namespace TravelAgencyBusinessLogic.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 { "2cm", "3cm", "3cm", "4cm", "3cm", "3cm"}); CreateRow(new PdfRowParameters { Texts = new List { "Тур", "Стоимость тура", "Дата тура", "Экскурсионная группа", "Количество участников", "Гид" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); foreach (var tour in info.Tours) { CreateRow(new PdfRowParameters { Texts = new List { tour.Tour.TourName, tour.Tour.Price.ToString(), tour.Tour.TourDate.ToShortDateString(), "", "", "" }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); foreach(var excursionGroup in tour.ExcursionGroups) { CreateRow(new PdfRowParameters { Texts = new List { "", "", "", excursionGroup.ExcursionGroupName, excursionGroup.ParticipantsAmount.ToString(), excursionGroup.GuideFIO}, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); } } SavePdf(info); } /// /// Создание doc-файла /// /// protected abstract void CreatePdf(PdfInfo info); /// /// Создание параграфа с текстом /// /// /// protected abstract void CreateParagraph(PdfParagraph paragraph); /// /// Создание таблицы /// /// /// protected abstract void CreateTable(List columns); /// /// Создание и заполнение строки /// /// protected abstract void CreateRow(PdfRowParameters rowParameters); /// /// Сохранение файла /// /// protected abstract void SavePdf(PdfInfo info); } }