Пример #1
0
        public RevisitedCart StoreCartWithInitialProduct(NewCart newCart)
        {
            if (newCart.CartItems.Count != 1)
            {
                return(null);
            }
            CheckForExistingCustomer(newCart);
            _context.Carts.Add(newCart);
            _context.SaveChanges();
            var cart = RevisitedCart.CreateWithItems(newCart.CartId, newCart.CartItems);

            cart.SetCookieData(newCart.CartCookie, newCart.Expires);
            return(cart);
        }
Пример #2
0
 public void RemoveCustomer(int id)
 {
     using (var context = new OrderSystemContext()) {
         context.Customers.Remove(context.Customers.Find(id));
         context.SaveChanges();
     }
 }
Пример #3
0
 public void UpdateCustomer(Customer customer)
 {
     using (var context = new OrderSystemContext()) {
         context.Entry(customer).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #4
0
 public void AddCustomer(Customer customer)
 {
     using (var context = new OrderSystemContext()) {
         context.Customers.Add(customer);
         context.SaveChanges();
     }
 }
Пример #5
0
 public void AddProduct(Product product)
 {
     using (var context = new OrderSystemContext()) {
         product.IsAvailable = true;
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
Пример #6
0
 public int Save()
 {
     return(_context.SaveChanges());
 }
Пример #7
0
 public void AddCustomer(Customer customer)
 {
     _context.Customers.Add(customer);
     _context.SaveChanges();
 }
Пример #8
0
 public void AddProduct(Product product)
 {
     product.IsAvailable = true;
     _context.Products.Add(product);
     _context.SaveChanges();
 }