Exemplo n.º 1
0
        public IHttpActionResult Create([FromBody] NewOrderVM value)
        {
            var newOrder = new Order()
            {
                CustomerId    = value.CustomerId,
                Description   = value.Description,
                OrderDateTime = DateTime.UtcNow,
                OrderItems    = new List <OrderItem>(),
                UserId        = userId,
            };

            orderRepository.Add(newOrder);
            orderRepository.AddOrderItems(newOrder.OrderId, value.OrderItems);
            value.Id = newOrder.OrderId;
            return(Created("/Orders/{value.Id.ToString()}", value));
        }