public async Task <ActionResult> Details(int?orderId, int?productId, int?addressId, DateTime?productionDate) { if (orderId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (productId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (addressId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (productionDate == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderProductAddressProductionDate orderProductAddressProductionDate = await context.OrderProductAddressProductionDates .Include(opapd => opapd.OrderProductAddress.OrderProduct.Order) .Include(opapd => opapd.OrderProductAddress.OrderProduct.Product) .Include(opapd => opapd.OrderProductAddress.Address) .Include(opapd => opapd.OrderProductAddressProductionDateSizes) .Include(opapd => opapd.OrderProductAddressProductionDateSizes.Select(opapds => opapds.Size)) .FirstOrDefaultAsync(opapd => opapd.OrderId == orderId && opapd.ProductId == productId && opapd.AddressId == addressId && opapd.ProductionDate == productionDate); if (orderProductAddressProductionDate == null) { return(HttpNotFound()); } OrderProductAddressProductionDateViewModel model = new OrderProductAddressProductionDateViewModel(orderProductAddressProductionDate); if (orderProductAddressProductionDate.OrderProductAddressProductionDateSizes.Any()) { foreach (var orderProductAddressProductionDateSize in orderProductAddressProductionDate.OrderProductAddressProductionDateSizes) { model.OrderProductAddressProductionDateSizes.Add(new OrderProductAddressProductionDateSizeViewModel(orderProductAddressProductionDateSize)); } } return(View(model)); }
public OrderProductAddressProductionDateSizeViewModel(OrderProductAddressProductionDateSize orderProductAddressProductionDateSize) { OrderProductAddressProductionDate = new OrderProductAddressProductionDateViewModel(orderProductAddressProductionDateSize.OrderProductAddressProductionDate); Size = new SizeViewModel(orderProductAddressProductionDateSize.Size); Quantity = orderProductAddressProductionDateSize.Quantity; }