Exemplo n.º 1
0
 public void AddToCraft(Craft craft)
 {
     _context.ShoppingCarts.Add(new ShoppingCart
     {
         ShoppingCartId = CartId,
         Craft          = craft,
         Price          = craft.Price
     });
     _context.SaveChanges();
 }
Exemplo n.º 2
0
        public void CreateOrder(Order order)
        {
            order.OrderTime = DateTime.Now;
            _context.Orders.Add(order);
            _context.SaveChanges();

            var items = _efCart.shopItems;

            foreach (var el in items)
            {
                var orderDetail = new OrderDetail()
                {
                    CraftId = el.Craft.Id,
                    OrderId = order.Id,
                    Price   = el.Craft.Price
                };
                _context.OrderDetails.Add(orderDetail);
            }
            _context.SaveChanges();
        }