Пример #1
0
        public async Task <IActionResult> Post([FromBody] OrderCreationRequest request)
        {
            var order = new OrderDTO
            {
                DeliveryDate          = request.DeliveryDate,
                CustomerName          = request.CustomerName,
                CustomerNumber        = request.CustomerNumber,
                CustomerAddress       = request.CustomerAddress,
                AdditionalInformation = request.AdditionalInformation,
                OrderItems            = request.OrderItems.ToList()
            };

            var idOrder = await orderManager.CreateOrderAsync(order);

            foreach (var orderItem in request.OrderItems)
            {
                await orderManager.AddOrderItemAsync(idOrder, orderItem.IdCategory, orderItem.IdProduct, orderItem.Qty);
            }

            var response = new OrderCreationResponse {
                IdOrder = idOrder
            };

            return(Ok(response));
        }