public async Task <ActionResult <DeliveryItem> > PostDeliveryItem(DeliveryItem delivery) { if (delivery == null) { throw new System.ArgumentNullException(nameof(delivery)); } else if (delivery.OrderItems == null) { throw new System.ArgumentNullException(nameof(delivery.OrderItems)); } // Retrieving all orders from delivery ICollection <OrderItem> orders = await CommonOperations.ExtractOrders(delivery, _context); delivery.OrderItems = orders; delivery.Status = "created"; _context.DeliveryItems.Add(delivery); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetDeliveryItem), new { id = delivery.DeliveryId }, delivery)); }