Esempio n. 1
0
        public void RemoveSelected(string id)
        {
            SelectedProduct s = db.ShoppingList.Find(id);

            s.num--;
            if (s.num == 0)
            {
                db.ShoppingList.Remove(db.ShoppingList.Find(id));
            }
            db.SaveChanges();
        }
Esempio n. 2
0
        public void AddProductToShoppingList(string id)
        {
            Product product = db.Products.Find(id);

            if (db.ShoppingList.Find(id) != null)
            {
                SelectedProduct s = db.ShoppingList.Find(id);
                s.num++;
            }
            else
            {
                SelectedProduct sProduct = new SelectedProduct()
                {
                    Id    = product.Id,
                    Name  = product.Name,
                    Price = product.Price,
                    num   = 1
                };
                db.ShoppingList.Add(sProduct);
            }

            db.SaveChanges();
        }