using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CanteenBusinessLogic.OfficePackage.HelperEnums; using CanteenBusinessLogic.OfficePackage.HelperModels; using DocumentFormat.OpenXml.EMMA; namespace CanteenBusinessLogic.OfficePackage { public abstract class AbstractSaveToWord { public void CreateCooksDoc(WordInfo info) { CreateWord(info); CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); foreach (var reportCookView in info.Cooks) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Обед: ", new WordTextProperties { Bold = true, Size = "24" }), (reportCookView.Lunch.LunchName, new WordTextProperties { Bold = false, Size = "24" }), (" Дата создания: ", new WordTextProperties { Bold = true, Size = "24" }), (reportCookView.Lunch.DateCreate.ToString(), new WordTextProperties { Bold = false, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Both } }); CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Повара: ", new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Both } }); foreach (var cook in reportCookView.Cooks) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { (cook.FIO, new WordTextProperties { Bold = false, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Both } }); } } SaveWord(info); } public void CreateOrdersDoc(WordInfo info) { CreateWord(info); CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); foreach (var reportOrderView in info.Orders) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Продукт: ", new WordTextProperties { Bold = true, Size = "24" }), (reportOrderView.Product.Id.ToString(), new WordTextProperties { Bold = false, Size = "24" }), ("Название: ", new WordTextProperties { Bold = true, Size = "24" }), (reportOrderView.Product.ProductName.ToString(), new WordTextProperties { Bold = false, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Both } }); CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Заказы: ", new WordTextProperties { Bold = true, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Both } }); foreach (var order in reportOrderView.Orders) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { ("Заказ: ", new WordTextProperties { Bold = false, Size = "24" }), (order.Id.ToString(), new WordTextProperties { Bold = false, Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Both } }); } } SaveWord(info); } protected abstract void CreateWord(WordInfo info); protected abstract void CreateParagraph(WordParagraph paragraph); protected abstract void SaveWord(WordInfo info); } }