GetViewModel with LINQ

This commit is contained in:
Никита Волков 2024-03-04 20:39:08 +04:00
parent 4ac60f090d
commit 3aef079512

View File

@ -82,13 +82,10 @@ namespace ComputersShopFileImplement.Implements
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var comp in source.Computers)
{
if (comp.Id == order.ComputerId)
var comp = source.Computers.FirstOrDefault(comp => comp.Id == order.ComputerId);
if (comp != null)
{
viewModel.ComputerName = comp.ComputerName;
break;
}
}
return viewModel;
}