public bool UpdateQuantityInCart(ProductCartModel productCartModel) { var productCartEntity = new ProductCartDTO(); var productCartRepository = new ProductCartRepository(); AutoMapper.Mapper.Map(productCartModel, productCartEntity); var status = productCartRepository.UpdateQuantityInCart(productCartEntity); return status; }
public bool InsertProductCart(ProductCartModel productCartModel) { var productCartEntity = new ProductCartDTO(); var productCartRepository = new ProductCartRepository(); AutoMapper.Mapper.Map(productCartModel, productCartEntity); bool status = productCartRepository.InsertProductCart(productCartEntity); return status; }
public ActionResult ShoppingCart(ProductCartModel productCart) { ViewData["Data"] = null; ShoppingCartModel cart = new ShoppingCartModel(); cart.ShoppingCartProductPrice = Convert.ToDecimal(productCart.ProductCartPrice); cart.ShoppingCartProductKId = Convert.ToInt32(productCart.ProductCartProductKId); cart.ShoppingCartQuantity = Convert.ToInt32(productCart.ProductCartQuantity); cart.ShoppingCartId = GetShoppingCartId(); bool status = false; status = ShoppingCartService.InsertProductShoppingCart(cart); if (status) { ViewData["Data"] = ToJSON(ShoppingCartService.GetShoppingCartIteim(GetShoppingCartId())); ViewData["AddToCartItems"] = ShoppingCartService.CountShoppingCartItems(GetShoppingCartId()); } return View(); }
public ActionResult ShoppingCart(ProductCartModel productCart) { IList<ProductCartModel> productCartModelList; shoppingCartId = base.GetShoppingCartId(); if (productCart.ProductId > 0) { productCartModelList = productCartManager.GetCartItems(shoppingCartId); ProductCartModel productCartModel = productCartModelList.FirstOrDefault(x => x.ProductId == productCart.ProductId); if (productCartModel == null) { productCart.CartId = shoppingCartId; bool status = productCartManager.InsertProductCart(productCart); } } productCartModelList = productCartManager.GetCartItems(shoppingCartId); ViewBag.ItemsCount = productCartManager.CountCartItems(shoppingCartId); return View(productCartModelList); }
public ActionResult UpdateQuantityInCart(int productCartId, int quantity) { shoppingCartId = base.GetShoppingCartId(); var productCartModel = new ProductCartModel(); productCartModel.Id = productCartId; productCartModel.Quantity = quantity; var productCartManager = new ProductCartManager(); productCartManager.UpdateQuantityInCart(productCartModel); return RedirectToAction("ShoppingCart", productCartManager.GetCartItems(shoppingCartId).FirstOrDefault()); }