public ActionResult Index() { A00964856_ShoppingCartEntities db = new A00964856_ShoppingCartEntities(); ProductRepo prodRepo = new ProductRepo(db); return View(prodRepo.GetProducts()); }
public ActionResult Add(int prodId) { SessionHelper sessonHlp = new SessionHelper(); int qty = sessonHlp.GetProductQtyFromCart(prodId); A00964856_ShoppingCartEntities db = new A00964856_ShoppingCartEntities(); ProductRepo prodRepo = new ProductRepo(db); CartItemRepo cartItemRepo = new CartItemRepo(prodRepo); CartItemModel item = cartItemRepo.GetCartItem(prodId, qty); return View(item); }
private bool UpdateCart(CartItemModel cartItem) { if (cartItem.Quantity < 1) { return false; } SessionHelper sessionHlp = new SessionHelper(); sessionHlp.AddProductToCart(cartItem.ProductID, cartItem.Quantity); A00964856_ShoppingCartEntities db = new A00964856_ShoppingCartEntities(); ProductRepo prodRepo = new ProductRepo(db); VisitRepo visitRepo = new VisitRepo(db); ProductVisitRepo prodVisitRepo = new ProductVisitRepo(db); Visit visit = visitRepo.GetVisit(sessionHlp.SessionID); Product product = prodRepo.GetProduct(cartItem.ProductID); prodVisitRepo.AddProductVisit(visit, product, cartItem.Quantity); return true; }
public CartItemRepo(ProductRepo prodRepo) { this.prodRepo = prodRepo; }
public ActionResult ViewCart() { SessionHelper sessionHlp = new SessionHelper(); Dictionary<int, int> sessionCart = sessionHlp.GetCart(); A00964856_ShoppingCartEntities db = new A00964856_ShoppingCartEntities(); ProductRepo prodRepo = new ProductRepo(db); CartItemRepo cartItemRepo = new CartItemRepo(prodRepo); List<CartItemModel> cartItems = cartItemRepo.GetAllCartItems(sessionCart); CheckoutCartModel checkoutCart = new CheckoutCartModel(); checkoutCart.CartItems = cartItems; return View(checkoutCart); }