コード例 #1
0
        public ActionResult Add(ProductVisit productVisitFromForm)
        {
            SessionHelper sessionHelper = new SessionHelper();

            productVisitFromForm.sessionID = sessionHelper.SessionID;
            productVisitFromForm.updated   = sessionHelper.StartTime;

            ProductVisitRepo productVisitRepo = new ProductVisitRepo();

            if (productVisitFromForm.productID != 0 && productVisitFromForm.sessionID != null)
            {
                productVisitRepo.AddOrUpdateProductVisit(productVisitFromForm);
            }

            ProductVisit productVisitFromDB = productVisitRepo.GetCartItem(sessionHelper.SessionID, productVisitFromForm.productID);

            ViewBag.Qty = 1;
            if (productVisitFromDB.qtyOrdered != 1)
            {
                ViewBag.Qty = productVisitFromDB.qtyOrdered;
            }

            return(RedirectToAction("ViewCart", new { id = sessionHelper.SessionID }));
        }
コード例 #2
0
        public ActionResult Add(int id)
        {
            SessionHelper sessionHelper = new SessionHelper();

            ViewBag.SessionID = System.Web.HttpContext.Current.Session.SessionID;

            ProductVisitRepo productVisitRepo   = new ProductVisitRepo();
            ProductVisit     productVisitFromDB = productVisitRepo.GetCartItem(System.Web.HttpContext.Current.Session.SessionID, id);

            if (productVisitFromDB != null)
            {
                ViewBag.Qty = productVisitFromDB.qtyOrdered;
            }
            else
            {
                ViewBag.Qty = 1;
            }


            ProductRepo productRepo = new ProductRepo();

            RedirectToAction("ViewCart");
            return(View(productRepo.GetProduct(id)));
        }