public void CreateOrder(Order order)
        {
            order.OrderPlaced = DateTime.Now;
            order.Total       = _shoppingCart.GetShoppingCartTotal();
            _candyContext.Order.Add(order);
            _candyContext.SaveChanges();

            var shoppingCartItems = _shoppingCart.GetShoppingCartItems();

            foreach (var item in shoppingCartItems)
            {
                var orderDetail = new OrderDetail
                {
                    Amount  = item.Amount,
                    Price   = item.Candy.Price,
                    CandyId = item.Candy.Id,
                    OrderId = order.Id
                };
                _candyContext.OrderDetail.Add(orderDetail);
            }
            _candyContext.SaveChanges();
        }
        public void AddToCart(Candy candy, int amount, string shoppingCartId)
        {
            var shoppingCartItem = _candyContext.ShoppingCartItem
                                   .SingleOrDefault(x => x.Candy.Id == candy.Id && x.ShoppingCartId == shoppingCartId);

            if (shoppingCartItem == null)
            {
                shoppingCartItem = new ShoppingCartItem
                {
                    ShoppingCartId = shoppingCartId,
                    Candy          = candy,
                    Amount         = amount
                };

                _candyContext.ShoppingCartItem.Add(shoppingCartItem);
            }
            else
            {
                shoppingCartItem.Amount++;
            }
            _candyContext.SaveChanges();
        }
 public void Add(Candy candy)
 {
     _candyContext.Candy.Add(candy);
     _candyContext.SaveChanges();
 }
 public void Create(ReviewModel review)
 {
     db.Reviews.Add(review);
     db.SaveChanges();
 }