public void AddToCart(Product product)
        {
            var cartItem = db.CartItems.SingleOrDefault(c => c.CartId == ShoppingCartId &&
                c.ProductId == product.ProductId);

            if (cartItem == null)
            {
                //create new cart item
                cartItem = new CartItem
                {
                    CartItemId = db.CartItems.Count() + 1,
                    CartId = ShoppingCartId,
                    ProductId = product.ProductId,
                    //Product = product,
                    Count = 1,
                    DateCreated = DateTime.Now,
                };
                db.CartItems.Add(cartItem);
                db.SaveChanges();
            }
            else
            {
                //item exists in cart, so add one to quantity
                cartItem.Count++;
            }
        }
 public void CreateNewProduct(Product product)
 {
     var newProduct = new Product()
     {
         Name = product.Name,
         Description = product.Description,
         Quantity = product.Quantity,
         Price = product.Price,
         Cost = product.Cost,
         PurchaseDate = product.PurchaseDate,
         CategoryId = product.CategoryId,
         StoreManagerId = product.StoreManagerId,
     };
     db.Products.Add(newProduct);
     db.SaveChanges();
 }
 public void EditProduct(Product product)
 {
     db.Entry(product).State = EntityState.Modified;
     db.SaveChanges();
 }