PIAPS_CW/BusinessLogic/OfficePackage/AbstractSaveToPdfPricelist.cs

52 lines
1.9 KiB
C#
Raw Normal View History

2024-06-25 21:12:06 +04:00
using BusinessLogic.OfficePackage.HelperEnums;
using BusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BusinessLogic.OfficePackage
{
public abstract class AbstractSaveToPdfPricelist
{
public void CreateDoc(PdfInfo info)
{
CreatePdf(info);
CreateParagraph(new PdfParagraph
{
Text = $"{info.Title}\nОт {info.Date}",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateParagraph(new PdfParagraph
{
Text = "Товары",
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "5cm", "5cm", "3cm", "2cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Id", "Название", "Цена", "Кол-во на складе" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var product in info.Products)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { product.Id.ToString(), product.Name, product.Price.ToString(), product.Amount.ToString() },
});
}
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 CreateImage(string path);
protected abstract void SavePdf(PdfInfo info);
}
}