diff --git a/SushiBar/SushiBarBusinessLogic/BusinessLogics/ReportLogic.cs b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ReportLogic.cs
index 477f92d..50b641b 100644
--- a/SushiBar/SushiBarBusinessLogic/BusinessLogics/ReportLogic.cs
+++ b/SushiBar/SushiBarBusinessLogic/BusinessLogics/ReportLogic.cs
@@ -32,26 +32,23 @@ namespace SushiBarBusinessLogic.BusinessLogics
///
public List GetSushiComponent()
{
- var components = _componentStorage.GetFullList();
var sushis = _sushiStorage.GetFullList();
var list = new List();
- foreach (var component in components)
+ foreach (var sushi in sushis)
{
var record = new ReportSushiComponentViewModel
{
- ComponentName = component.ComponentName,
- Sushis = new List>(),
+ SushiName = sushi.SushiName,
+ Components = new List>(),
TotalCount = 0
};
- foreach (var sushi in sushis)
+ foreach (var component in sushi.SushiComponents)
{
- if (sushi.SushiComponents.ContainsKey(component.Id))
- {
- record.Sushis.Add(new Tuple(sushi.SushiName, sushi.SushiComponents[component.Id].Item2));
- record.TotalCount +=
- sushi.SushiComponents[component.Id].Item2;
- }
+ record.Components.Add(new Tuple(
+ component.Value.Item1.ComponentName,
+ component.Value.Item2
+ ));
+ record.TotalCount += component.Value.Item2;
}
list.Add(record);
}
@@ -66,8 +63,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
{
return _orderStorage.GetFilteredList(new OrderSearchModel
{
- DateFrom
- = model.DateFrom,
+ DateFrom = model.DateFrom,
DateTo = model.DateTo
})
.Select(x => new ReportOrdersViewModel
@@ -75,6 +71,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
Id = x.Id,
DateCreate = x.DateCreate,
SushiName = x.SushiName,
+ OrderStatus = x.Status.ToString(),
Sum = x.Sum
})
.ToList();
@@ -88,7 +85,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
- Title = "Список компонент",
+ Title = "Список суши",
Sushis = _sushiStorage.GetFullList()
});
}
@@ -101,7 +98,7 @@ namespace SushiBarBusinessLogic.BusinessLogics
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
- Title = "Список компонент",
+ Title = "Список суши",
SushiComponents = GetSushiComponent()
});
}
diff --git a/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
index a19fcb2..cb40f87 100644
--- a/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
+++ b/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
@@ -25,35 +25,33 @@ namespace SushiBarBusinessLogic.OfficePackage
CellToName = "C1"
});
uint rowIndex = 2;
- foreach (var pc in info.SushiComponents)
+ foreach (var sc in info.SushiComponents)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
- Text = pc.ComponentName,
+ Text = sc.SushiName,
StyleInfo = ExcelStyleInfoType.Text
});
- rowIndex++;
- foreach (var sushi in pc.Sushis)
+ ++rowIndex;
+ foreach (var sushi in sc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = sushi.Item1,
- StyleInfo =
- ExcelStyleInfoType.TextWithBroder
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = sushi.Item2.ToString(),
- StyleInfo =
- ExcelStyleInfoType.TextWithBroder
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
});
- rowIndex++;
+ ++rowIndex;
}
InsertCellInWorksheet(new ExcelCellParameters
{
@@ -66,10 +64,10 @@ namespace SushiBarBusinessLogic.OfficePackage
{
ColumnName = "C",
RowIndex = rowIndex,
- Text = pc.TotalCount.ToString(),
+ Text = sc.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
- rowIndex++;
+ ++rowIndex;
}
SaveExcel(info);
}
@@ -82,8 +80,7 @@ namespace SushiBarBusinessLogic.OfficePackage
/// Добавляем новую ячейку в лист
///
///
- protected abstract void InsertCellInWorksheet(ExcelCellParameters
- excelParams);
+ protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
///
/// Объединение ячеек
///
diff --git a/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
index 11582da..502436c 100644
--- a/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
+++ b/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
@@ -25,10 +25,10 @@ namespace SushiBarBusinessLogic.OfficePackage
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
- CreateTable(new List { "2cm", "3cm", "6cm", "3cm" });
+ CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "4cm" });
CreateRow(new PdfRowParameters
{
- Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма" },
+ Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@@ -40,7 +40,9 @@ namespace SushiBarBusinessLogic.OfficePackage
order.Id.ToString(),
order.DateCreate.ToShortDateString(),
order.SushiName,
- order.Sum.ToString() },
+ order.Sum.ToString(),
+ order.OrderStatus.ToString()
+ },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
diff --git a/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs
index 8426bd1..b0cc42d 100644
--- a/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs
+++ b/SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs
@@ -26,7 +26,8 @@ namespace SushiBarBusinessLogic.OfficePackage
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> {
- (sushis.SushiName, new WordTextProperties { Size = "24", })
+ (sushis.SushiName, new WordTextProperties { Size = "24", Bold = true }),
+ (" - цена " + sushis.Price.ToString(), new WordTextProperties { Size = "24" })
},
TextProperties = new WordTextProperties
{
diff --git a/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
index 8650d0c..4c7121c 100644
--- a/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
+++ b/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
@@ -193,8 +193,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
}
protected override void CreateExcel(ExcelInfo info)
{
- _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
- SpreadsheetDocumentType.Workbook);
+ _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
// Создаем книгу (в ней хранятся листы)
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
workbookpart.Workbook = new Workbook();
@@ -266,7 +265,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
}
var newCell = new Cell()
{
- CellReference = excelParams.CellReference
+ CellReference = excelParams.CellReference
};
row.InsertBefore(newCell, refCell);
cell = newCell;
@@ -294,8 +293,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
mergeCells = new MergeCells();
if (_worksheet.Elements().Any())
{
- _worksheet.InsertAfter(mergeCells,
- _worksheet.Elements().First());
+ _worksheet.InsertAfter(mergeCells, _worksheet.Elements().First());
}
else
{
@@ -315,6 +313,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
return;
}
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
+ _spreadsheetDocument.Dispose();
}
}
}
diff --git a/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
index 74cde92..933ac9c 100644
--- a/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
+++ b/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
@@ -48,8 +48,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
}
var paragraph = _section.AddParagraph(pdfParagraph.Text);
paragraph.Format.SpaceAfter = "1cm";
- paragraph.Format.Alignment =
- GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
+ paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
paragraph.Style = pdfParagraph.Style;
}
protected override void CreateTable(List columns)
@@ -83,8 +82,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
row.Cells[i].Borders.Right.Width = borderWidth;
row.Cells[i].Borders.Top.Width = borderWidth;
row.Cells[i].Borders.Bottom.Width = borderWidth;
- row.Cells[i].Format.Alignment =
- GetParagraphAlignment(rowParameters.ParagraphAlignment);
+ row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
}
}
diff --git a/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToWord.cs
index c49ee75..bd1231f 100644
--- a/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToWord.cs
+++ b/SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToWord.cs
@@ -58,6 +58,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
{
LineRule = LineSpacingRuleValues.Auto
});
+
properties.AppendChild(new Indentation());
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
if (!string.IsNullOrEmpty(paragraphProperties.Size))
@@ -114,6 +115,7 @@ namespace SushiBarBusinessLogic.OfficePackage.Implements
}
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
+ _wordDocument.Dispose();
}
}
}
diff --git a/SushiBar/SushiBarContracts/ViewModels/ReportOrdersViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ReportOrdersViewModel.cs
index 0a4ca04..dfb4ded 100644
--- a/SushiBar/SushiBarContracts/ViewModels/ReportOrdersViewModel.cs
+++ b/SushiBar/SushiBarContracts/ViewModels/ReportOrdersViewModel.cs
@@ -12,5 +12,6 @@ namespace SushiBarContracts.ViewModels
public DateTime DateCreate { get; set; }
public string SushiName { get; set; } = string.Empty;
public double Sum { get; set; }
+ public string OrderStatus { get; set; } = string.Empty;
}
}
diff --git a/SushiBar/SushiBarContracts/ViewModels/ReportProductComponentViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ReportProductComponentViewModel.cs
index d409d44..63ce68a 100644
--- a/SushiBar/SushiBarContracts/ViewModels/ReportProductComponentViewModel.cs
+++ b/SushiBar/SushiBarContracts/ViewModels/ReportProductComponentViewModel.cs
@@ -8,8 +8,8 @@ namespace SushiBarContracts.ViewModels
{
public class ReportSushiComponentViewModel
{
- public string ComponentName { get; set; } = string.Empty;
+ public string SushiName { get; set; } = string.Empty;
public int TotalCount { get; set; }
- public List> Sushis { get; set; } = new List>();
+ public List> Components { get; set; } = new();
}
}