Exemplo n.º 1
0
        public async Task <IActionResult> addOrder(OrderedProduct[] products)
        {
            double total = 0;

            foreach (var item in products)
            {
                total += item.Price;
            }
            DateTime today  = DateTime.Today;
            int      userId = int.Parse(User.FindFirst(ClaimTypes.Role).Value);
            var      order  = new Order {
                UserId     = userId,
                OrderDate  = today,
                TotalPrice = total
            };
            var MyOrder = await _repo.AddOrder(order);

            return(Ok(MyOrder));
        }