Esempio n. 1
0
        public Order Create(NewOrderInformation orderInfo)
        {
            var order = new Order()
            {
                CustomerId    = orderInfo.CustomerId,
                SalespersonId = orderInfo.SalesPersonId,
                Status        = "due",
                TotalDue      = orderInfo.products.Sum(p => p.Price * p.Quantity),
                CreatedDate   = DateTime.Now,
                OrderDate     = DateTime.Now,
                OrderItem     = orderInfo.products.Select(p =>
                {
                    return(new OrderItem()
                    {
                        ProductId = p.ProductCode,
                        Quantity = p.Quantity
                    });
                }).ToList()
            };

            _context.Add(order);

            return(order);
        }
 public virtual void Add(T Item)
 {
     _context.Add(Item);
 }
 public virtual async Task Add(T Item)
 {
     _context.Add(Item);
     await _context.SaveChangesAsync();
 }