This commit is contained in:
parent 30b284dda5
commit 5d4ee306ce
2 changed files with 25 additions and 9 deletions

View File

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace AircraftPlantFileImplement.Implements
{
@ -36,7 +37,7 @@ namespace AircraftPlantFileImplement.Implements
public List<OrderViewModel> GetFullList()
{
return _source.Orders
.Select(x => x.GetViewModel)
.Select(x => GetViewModel(x))
.ToList();
}
@ -54,7 +55,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 +71,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)));
}
/// <summary>
@ -92,7 +92,7 @@ namespace AircraftPlantFileImplement.Implements
_source.Orders.Add(newOrder);
_source.SaveOrders();
return newOrder.GetViewModel;
return GetViewModel(newOrder);
}
/// <summary>
@ -110,7 +110,7 @@ namespace AircraftPlantFileImplement.Implements
order.Update(model);
_source.SaveOrders();
return order.GetViewModel;
return GetViewModel(order);
}
/// <summary>
@ -125,9 +125,25 @@ namespace AircraftPlantFileImplement.Implements
{
_source.Orders.Remove(element);
_source.SaveOrders();
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;
var plane = _source.Planes.FirstOrDefault(x => x.Id == order.PlaneId);
if (plane != null)
{
viewModel.PlaneName = plane.PlaneName;
}
return viewModel;
}
}
}

View File

@ -39,7 +39,7 @@ namespace AircraftPlantView
/// <param name="logger"></param>
/// <param name="planeLogic"></param>
/// <param name="shopLogic"></param>
public FormSell(ILogger logger, IPlaneLogic planeLogic, IShopLogic shopLogic)
public FormSell(ILogger<FormSell> logger, IPlaneLogic planeLogic, IShopLogic shopLogic)
{
InitializeComponent();
_logger = logger;