PIbd-21_MasenkinMS_LabWork01_Basic #1

Closed
Factorino73 wants to merge 3 commits from LabWork01_Basic into main
Showing only changes of commit 42af538e01 - Show all commits

View File

@ -38,7 +38,7 @@ namespace AircraftPlantListImplement.Implements
var result = new List<OrderViewModel>();
foreach (var order in _source.Orders)
{
result.Add(order.GetViewModel);
result.Add(GetViewModel(order));
}
return result;
}
@ -60,7 +60,7 @@ namespace AircraftPlantListImplement.Implements
{
if (order.Id == model.Id)
{
result.Add(order.GetViewModel);
result.Add(GetViewModel(order));
}
}
return result;
@ -82,7 +82,7 @@ namespace AircraftPlantListImplement.Implements
{
if (model.Id.HasValue && order.Id == model.Id)
{
return order.GetViewModel;
return GetViewModel(order);
}
}
return null;
@ -111,7 +111,7 @@ namespace AircraftPlantListImplement.Implements
}
_source.Orders.Add(newOrder);
return newOrder.GetViewModel;
return GetViewModel(newOrder);
}
/// <summary>
@ -126,7 +126,7 @@ namespace AircraftPlantListImplement.Implements
if (order.Id == model.Id)
{
order.Update(model);
return order.GetViewModel;
return GetViewModel(order);
}
}
return null;
@ -145,10 +145,29 @@ namespace AircraftPlantListImplement.Implements
{
var element = _source.Orders[i];
_source.Orders.RemoveAt(i);
return element.GetViewModel;
return GetViewModel(element);
}
}
return null;
}
/// <summary>
/// Получение модели заказа
/// </summary>
/// <param name="order"></param>
/// <returns></returns>
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var sushi in _source.Planes)
{
if (sushi.Id == order.PlaneId)
{
viewModel.PlaneName = sushi.PlaneName;
break;
}
}
return viewModel;
}
}
}