This commit is contained in:
Николай 2023-03-10 17:49:43 +04:00
parent dc15fc10f3
commit 53167b7608
10 changed files with 42 additions and 30 deletions

View File

@ -27,8 +27,8 @@ namespace FoodOrdersView
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" });
foreach (var listElem in elem.Dishes)
dataGridView.Rows.Add(new object[] { elem.DishName, "", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}

View File

@ -46,19 +46,19 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
var list = new List<ReportDishComponentViewModel>();
foreach (var component in components)
foreach (var dish in dishes)
{
var record = new ReportDishComponentViewModel
{
ComponentName = component.ComponentName,
Dishes = new List<(string, int)>(),
DishName = dish.DishName,
Components = new List<(string, int)>(),
TotalCount = 0
};
foreach (var dish in dishes)
foreach (var component in components)
{
if (dish.DishComponents.ContainsKey(component.Id))
{
record.Dishes.Add(new (dish.DishName, dish.DishComponents[component.Id].Item2));
record.Components.Add(new (component.ComponentName, dish.DishComponents[component.Id].Item2));
record.TotalCount += dish.DishComponents[component.Id].Item2;
}
}
@ -96,8 +96,8 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список компонент",
Components = _componentStorage.GetFullList()
Title = "Список блюд",
Dishes = _dishStorage.GetFullList()
});
}

View File

@ -34,18 +34,18 @@ namespace FoodOrdersBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ComponentName,
Text = pc.DishName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (Dish, Count) in pc.Dishes)
foreach (var (Component, Count) in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Dish,
Text = Component,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});

View File

@ -11,7 +11,7 @@ namespace FoodOrdersBusinessLogic.OfficePackage
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) },
TextProperties = new WordTextProperties
{
Size = "24",
@ -19,11 +19,11 @@ namespace FoodOrdersBusinessLogic.OfficePackage
}
});
foreach (var component in info.Components)
foreach (var dish in info.Dishes)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (component.ComponentName, new WordTextProperties { Size = "24", }) },
Texts = new List<(string, WordTextProperties)> { (dish.DishName, new WordTextProperties { Size = "24" }) },
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -8,6 +8,6 @@ namespace FoodOrdersBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new();
public List<DishViewModel> Dishes { get; set; } = new();
}
}

View File

@ -1,4 +1,5 @@
using System;
using FoodOrdersDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -15,5 +16,7 @@ namespace FoodOrdersContracts.ViewModels
public string DishName { get; set; } = string.Empty;
public double Sum { get; set; }
public OrderStatus OrderStatus { get; set; }
}
}

View File

@ -8,10 +8,10 @@ namespace FoodOrdersContracts.ViewModels
{
public class ReportDishComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string DishName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Dish, int Count)> Dishes { get; set; } = new();
public List<(string Component, int Count)> Components { get; set; } = new();
}
}

View File

@ -37,15 +37,20 @@ namespace FoodOrdersDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new FoodOrdersDatabase();
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return context.Orders
.Include(x => x.Dish)
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
.Include(x => x.Dish)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
private static OrderViewModel GetViewModel(Order order)

View File

@ -19,9 +19,11 @@ namespace FoodOrdersFileImplement.Implements
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return new();
return _source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => GetViewModel(x))
.ToList();
}
return _source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList();
}

View File

@ -30,9 +30,11 @@ namespace FoodOrdersListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (!model.Id.HasValue)
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return result;
return _source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => GetViewModel(x))
.ToList();
}
foreach (var order in _source.Orders)
{