public OrderProductDeliveryMaterialViewModel(OrderProductDeliveryMaterial orderProductDeliveryMaterial) { OrderProductDelivery = new OrderProductDeliveryViewModel(orderProductDeliveryMaterial.OrderProductDelivery); Material = new MaterialViewModel(orderProductDeliveryMaterial.Material); DeliveryQuantity = orderProductDeliveryMaterial.DeliveryQuantity; AcceptanceQuantity = orderProductDeliveryMaterial.AcceptanceQuantity; }
public async Task <ActionResult> Details(int?orderId, int?productId, int?deliveryId) { if (orderId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (productId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (deliveryId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderProductDelivery orderProductDelivery = await context.OrderProductDeliveries .Include(opd => opd.OrderProduct.Order) .Include(opd => opd.OrderProduct.Product) .Include(opd => opd.OrderProductDeliveryMaterials.Select(opdm => opdm.Material)) .FirstOrDefaultAsync(opd => opd.OrderId == orderId && opd.ProductId == productId && opd.DeliveryId == deliveryId); if (orderProductDelivery == null) { return(HttpNotFound()); } OrderProductDeliveryViewModel model = new OrderProductDeliveryViewModel(orderProductDelivery); if (orderProductDelivery.OrderProductDeliveryMaterials.Any()) { foreach (var orderProductlDeliveryMaterial in orderProductDelivery.OrderProductDeliveryMaterials) { model.OrderProductDeliveryMaterials.Add(new OrderProductDeliveryMaterialViewModel(orderProductlDeliveryMaterial)); } } return(View(model)); }