Упрощение отображения названия изделия в заказе

This commit is contained in:
Мк Игорь 2023-02-28 17:53:07 +04:00
parent 43c216879b
commit 1d46ac3610

View File

@ -14,18 +14,16 @@ namespace BlacksmithWorkshopFileImplement.Implements
{
source = DataFileSingleton.GetInstance();
}
private OrderViewModel AddManufactureName (OrderViewModel model)
{
model.ManufactureName = source.Manufactures.SingleOrDefault(x => x.Id == model.ManufactureId)?.ManufactureName ?? string.Empty;
return model;
}
public List<OrderViewModel> GetFullList()
{
List<OrderViewModel> orderList = new();
orderList = source.Orders
.Select(x => x.GetViewModel)
return source.Orders
.Select(x => AddManufactureName(x.GetViewModel))
.ToList();
foreach (var order in orderList)
{
var manufactureName = source.Manufactures.SingleOrDefault(x => x.Id == order.ManufactureId)?.ManufactureName ?? string.Empty;
order.ManufactureName = manufactureName;
}
return orderList;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
@ -33,17 +31,10 @@ namespace BlacksmithWorkshopFileImplement.Implements
{
return new();
}
List<OrderViewModel> orderList = new();
orderList = source.Orders
return source.Orders
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.Select(x => AddManufactureName(x.GetViewModel))
.ToList();
foreach (var order in orderList)
{
var manufactureName = source.Manufactures.SingleOrDefault(x => x.Id == order.ManufactureId)?.ManufactureName ?? string.Empty;
order.ManufactureName = manufactureName;
}
return orderList;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{