ISEbd-21 Melnikov I. O. Lab work 02 Base #2

Closed
Igor-Melnikov wants to merge 5 commits from lab2 into lab1
Showing only changes of commit 1d46ac3610 - Show all commits

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)
{