public ActionResult AddToCart(ShoppingCartItemVM shoppingCartItemVm) { if (shoppingCartItemVm != null) { ShoppingCartBL.AddItem(shoppingCartItemVm); } return View(); }
public ActionResult AddToCart(ShoppingCartItemVM shoppingCartItemVm) { if (shoppingCartItemVm != null) { var success = ShoppingCartBL.AddItem(shoppingCartItemVm); if (success) return View(); } return RedirectToAction("WrongStock"); }
public static Boolean AddItem(ShoppingCartItemVM shoppingCartItemVm) { ProductMapper productMapper = new ProductMapper(); Product product = productMapper.GetProduct(shoppingCartItemVm.IdProduct); if (product.Stock >= shoppingCartItemVm.Quantity) { ShoppingCartMapper shoppingCartMapper = new ShoppingCartMapper(); ShoppingCartItem shoppingCartItem = new ShoppingCartItem(shoppingCartItemVm.IdProduct, shoppingCartItemVm.Quantity); shoppingCartMapper.AddShoppingCartItem(shoppingCartItem); return true; } else { return false; } }
public static ShoppingCartVM GetShoppingCart() { ShoppingCartMapper shoppingCartMapper = new ShoppingCartMapper(); ShoppingCart shoppingCart = shoppingCartMapper.GetShoppingCart(); shoppingCart.TotalPrice = TotalPrice(shoppingCart); LoginVM loginVm = new LoginVM(shoppingCart.User.EmailAddress, shoppingCart.User.Password); List<ShoppingCartItemVM> shoppingCartItemVmList = new List<ShoppingCartItemVM>(); foreach (var shoppingCartItem in shoppingCart.ShoppingCartItemsList) { var shoppingCartItemVM=new ShoppingCartItemVM(shoppingCartItem.IdProduct, shoppingCartItem.Quantity); shoppingCartItemVmList.Add(shoppingCartItemVM); } ShoppingCartVM shoppingCartVM = new ShoppingCartVM(shoppingCart.Id, loginVm, shoppingCart.TotalPrice,shoppingCartItemVmList); return shoppingCartVM; }
public static void UpdateItem(ShoppingCartItemVM shoppingCartItemVm) { ShoppingCartMapper shoppingCartMapper = new ShoppingCartMapper(); ShoppingCartItem shoppingCartItem = new ShoppingCartItem(shoppingCartItemVm.IdProduct, shoppingCartItemVm.Quantity); shoppingCartMapper.UpdateShoppingCartItem(shoppingCartItem); }
public ActionResult UpdateItem(ShoppingCartItemVM shoppingCartItemVM) { ShoppingCartBL.UpdateItem(shoppingCartItemVM); return RedirectToAction("Index"); }