This commit is contained in:
parent 2ee1a80d7d
commit 42af538e01

View File

@ -38,7 +38,7 @@ namespace AircraftPlantListImplement.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
result.Add(order.GetViewModel); result.Add(GetViewModel(order));
} }
return result; return result;
} }
@ -60,7 +60,7 @@ namespace AircraftPlantListImplement.Implements
{ {
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
result.Add(order.GetViewModel); result.Add(GetViewModel(order));
} }
} }
return result; return result;
@ -82,7 +82,7 @@ namespace AircraftPlantListImplement.Implements
{ {
if (model.Id.HasValue && order.Id == model.Id) if (model.Id.HasValue && order.Id == model.Id)
{ {
return order.GetViewModel; return GetViewModel(order);
} }
} }
return null; return null;
@ -111,7 +111,7 @@ namespace AircraftPlantListImplement.Implements
} }
_source.Orders.Add(newOrder); _source.Orders.Add(newOrder);
return newOrder.GetViewModel; return GetViewModel(newOrder);
} }
/// <summary> /// <summary>
@ -126,7 +126,7 @@ namespace AircraftPlantListImplement.Implements
if (order.Id == model.Id) if (order.Id == model.Id)
{ {
order.Update(model); order.Update(model);
return order.GetViewModel; return GetViewModel(order);
} }
} }
return null; return null;
@ -145,10 +145,29 @@ namespace AircraftPlantListImplement.Implements
{ {
var element = _source.Orders[i]; var element = _source.Orders[i];
_source.Orders.RemoveAt(i); _source.Orders.RemoveAt(i);
return element.GetViewModel; return GetViewModel(element);
} }
} }
return null; 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;
}
} }
} }