Example #1
0
        public ActionResult UpdateCart([Bind(Include = "ProductId, Amount")] List <CartProduct> cartProducts, Guid cartId)
        {
            var cart = Context.Carts.Find(cartId);

            foreach (var updatedCartProduct in cartProducts)
            {
                var oldCartProduct = cart.CartProducts.Single(x => x.ProductId == updatedCartProduct.ProductId);
                oldCartProduct.Amount = updatedCartProduct.Amount;
            }
            Context.SaveChanges();

            return(RedirectToAction("Cart"));
        }
 public ActionResult CreateContract(Contract contract)
 {
     contract.Id = Guid.NewGuid();
     Context.Contracts.Add(contract);
     Context.SaveChanges();
     return(View());
 }