diff --git a/SushiBar/FormMain.cs b/SushiBar/FormMain.cs index 7b621e4..254d871 100644 --- a/SushiBar/FormMain.cs +++ b/SushiBar/FormMain.cs @@ -148,7 +148,7 @@ namespace SushiBarView using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; if (dialog.ShowDialog() == DialogResult.OK) { - _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + _reportLogic.SaveSushisToWordFile(new ReportBindingModel { FileName = dialog.FileName }); diff --git a/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 1b9f497..ea07bf3 100644 --- a/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -17,12 +17,12 @@ namespace SushiBarBusinessLogic.OfficePackage JustificationType = WordJustificationType.Center } }); - foreach (var component in info.Components) + foreach (var sushi in info.Sushi) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { - (component.ComponentName, new WordTextProperties { Size = "24", }) + (sushi.SushiName, new WordTextProperties { Size = "24", }) }, TextProperties = new WordTextProperties { diff --git a/SushiBarBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/SushiBarBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index b5aad66..0d72fe4 100644 --- a/SushiBarBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/SushiBarBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -6,7 +6,7 @@ namespace SushiBarBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Components { get; set; } = new(); + public List Sushi { get; set; } = new(); } } diff --git a/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index 5b343e7..c18d035 100644 --- a/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -11,8 +11,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements private Document? _document; private Section? _section; private Table? _table; - private static ParagraphAlignment - GetParagraphAlignment(PdfParagraphAlignmentType type) + private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type) { return type switch { @@ -86,7 +85,6 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements row.Cells[i].VerticalAlignment = VerticalAlignment.Center; } } - protected override void SavePdf(PdfInfo info) { var renderer = new PdfDocumentRenderer(true) diff --git a/SushiBarBusinessLogic/Reportlogic.cs b/SushiBarBusinessLogic/Reportlogic.cs index a60ecdd..588da4f 100644 --- a/SushiBarBusinessLogic/Reportlogic.cs +++ b/SushiBarBusinessLogic/Reportlogic.cs @@ -80,13 +80,13 @@ namespace SushiBarBusinessLogic /// Сохранение компонент в файл-Word /// /// - public void SaveComponentsToWordFile(ReportBindingModel model) + public void SaveSushisToWordFile(ReportBindingModel model) { _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, Title = "Список компонент", - Components = _componentStorage.GetFullList() + Sushi = _sushiStorage.GetFullList() }); } /// diff --git a/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj b/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj index f0dcddc..2215cb8 100644 --- a/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj +++ b/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj @@ -12,8 +12,10 @@ + + diff --git a/SushiBarContracts/BusinessLogicsContracts/IReportLogic.cs b/SushiBarContracts/BusinessLogicsContracts/IReportLogic.cs index dc1f4af..93f1385 100644 --- a/SushiBarContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/SushiBarContracts/BusinessLogicsContracts/IReportLogic.cs @@ -20,7 +20,7 @@ namespace SushiBarContracts.BusinessLogicsContracts /// Сохранение компонент в файл-Word /// /// - void SaveComponentsToWordFile(ReportBindingModel model); + void SaveSushisToWordFile(ReportBindingModel model); /// /// Сохранение компонент с указаеним продуктов в файл-Excel /// diff --git a/SushiBarDatabaseImplement/Implements/OrderStorage.cs b/SushiBarDatabaseImplement/Implements/OrderStorage.cs index 82bfce6..e9e648f 100644 --- a/SushiBarDatabaseImplement/Implements/OrderStorage.cs +++ b/SushiBarDatabaseImplement/Implements/OrderStorage.cs @@ -17,23 +17,15 @@ namespace SushiBarDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { + if (!model.Id.HasValue && !model.DateTo.HasValue && !model.DateFrom.HasValue) + { + return new(); + } using var context = new SushiBarDatabase(); - var orders = context.Orders - .Select(x => x.GetViewModel) - .ToList(); if (model.Id.HasValue) - { - orders = orders.Where(x => x.Id == model.Id.Value).ToList(); - } - if (model.DateFrom.HasValue) - { - orders = orders.Where(x => x.DateCreate >= model.DateFrom.Value).ToList(); - } - if (model.DateTo.HasValue) - { - orders = orders.Where(x => x.DateCreate <= model.DateTo.Value).ToList(); - } - return orders; + return context.Orders.Where(x => x.Id == model.Id).Select(x => AccessViewModel(x.GetViewModel)).ToList(); + else + return context.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AccessViewModel(x.GetViewModel)).ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) {