示例#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();
     }
 }
 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();
 }