diff --git a/AircraftPlant/AircraftPlantFileImplement/Implements/OrderStorage.cs b/AircraftPlant/AircraftPlantFileImplement/Implements/OrderStorage.cs index a0eaf82..ea7a16f 100644 --- a/AircraftPlant/AircraftPlantFileImplement/Implements/OrderStorage.cs +++ b/AircraftPlant/AircraftPlantFileImplement/Implements/OrderStorage.cs @@ -36,7 +36,7 @@ namespace AircraftPlantFileImplement.Implements public List GetFullList() { return _source.Orders - .Select(x => x.GetViewModel) + .Select(x => GetViewModel(x)) .ToList(); } @@ -54,7 +54,7 @@ namespace AircraftPlantFileImplement.Implements return _source.Orders .Where(x => x.Id.Equals(model.Id)) - .Select(x => x.GetViewModel) + .Select(x => GetViewModel(x)) .ToList(); } @@ -70,9 +70,8 @@ namespace AircraftPlantFileImplement.Implements return null; } - return _source.Orders - .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; + return GetViewModel(_source.Orders + .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))); } /// @@ -92,7 +91,7 @@ namespace AircraftPlantFileImplement.Implements _source.Orders.Add(newOrder); _source.SaveOrders(); - return newOrder.GetViewModel; + return GetViewModel(newOrder); } /// @@ -110,7 +109,7 @@ namespace AircraftPlantFileImplement.Implements order.Update(model); _source.SaveOrders(); - return order.GetViewModel; + return GetViewModel(order); } /// @@ -125,9 +124,25 @@ namespace AircraftPlantFileImplement.Implements { _source.Orders.Remove(element); _source.SaveOrders(); - return element.GetViewModel; + return GetViewModel(element); } return null; } + + /// + /// Получение модели заказа + /// + /// + /// + private OrderViewModel GetViewModel(Order order) + { + var viewModel = order.GetViewModel; + var plane = _source.Planes.FirstOrDefault(x => x.Id == order.PlaneId); + if (plane != null) + { + viewModel.PlaneName = plane.PlaneName; + } + return viewModel; + } } } diff --git a/AircraftPlant/AircraftPlantListImplement/Implements/OrderStorage.cs b/AircraftPlant/AircraftPlantListImplement/Implements/OrderStorage.cs index f24a094..cdd1b93 100644 --- a/AircraftPlant/AircraftPlantListImplement/Implements/OrderStorage.cs +++ b/AircraftPlant/AircraftPlantListImplement/Implements/OrderStorage.cs @@ -38,7 +38,7 @@ namespace AircraftPlantListImplement.Implements var result = new List(); 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); } /// @@ -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; } + + /// + /// Получение модели заказа + /// + /// + /// + 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; + } } }