示例#1
0
 public ActionResult Index()
 {
     A00964856_ShoppingCartEntities db = new A00964856_ShoppingCartEntities();
     ProductRepo prodRepo = new ProductRepo(db);
     
     return View(prodRepo.GetProducts());
 }
示例#2
0
        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);
        }
示例#3
0
        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;
        }
示例#4
0
 public CartItemRepo(ProductRepo prodRepo)
 {
     this.prodRepo = prodRepo;
 }
示例#5
0
        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);
        }