public ActionResult ShoppingCart(int?id, PartialListModel partialModelList)
        {
            List <ShoppingCartObjectModel> itemObjList = new List <ShoppingCartObjectModel>();

            itemObjList = TempData["itemList"] as List <ShoppingCartObjectModel>;
            TempData.Keep("itemList");

            if (Request.Form["okOrCancel"] == "ok")
            {
                // copy the quantity from the model posted from delete button,
                // to the itemList, then save the new quantity to tempData.
                foreach (ShoppingCartObjectModel item in itemObjList)
                {
                    PartialListItemModel itemToCopy = partialModelList.PartialList.SingleOrDefault(r => r.PartialListProductId == item.ProductID);
                    item.Quantity    = itemToCopy.PartialListProductBuyQuantity;
                    item.UnitPrice   = itemToCopy.PartialListProductUnitPrice;
                    item.ProductName = itemToCopy.PartialListProductName;
                }

                TempData["itemList"] = itemObjList;
                TempData.Keep("itemList");

                return(RedirectToAction("DeliveryInfo"));
            }
            else if (Request.Form["okOrCancel"] == "continue")
            {
                if (TempData["shoppingURL"] != null)
                {
                    // then there could be 3 cases: "/", "/Home", "/Home/Index"
                    string returnPath = TempData["shoppingURL"].ToString();
                    //return Content(returnPath);
                    string[] pathArray = returnPath.Split('/');
                    if (pathArray.Length == 3)
                    {
                        return(RedirectToAction(pathArray[2], pathArray[1]));
                    }
                    else if (pathArray.Length == 2 && pathArray[1] != "")
                    {
                        return(RedirectToAction(pathArray[1], ""));
                    }
                    else
                    {
                        return(RedirectToAction("", ""));
                    }
                }
                else
                {
                    return(RedirectToAction("", ""));
                }
            }
            return(RedirectToAction("", ""));
        }
        public ActionResult CartItemDelete(int?id, PartialListModel partialModelList)
        {
            List <ShoppingCartObjectModel> itemObjList = new List <ShoppingCartObjectModel>();

            itemObjList = TempData["itemList"] as List <ShoppingCartObjectModel>;
            TempData.Keep("itemList");

            // remove from itemList, or say itemObjList
            ShoppingCartObjectModel itemToRemove = itemObjList.SingleOrDefault(r => r.ProductID == id);

            if (itemToRemove != null)
            {
                itemObjList.Remove(itemToRemove);
            }

            PartialListItemModel itemToRemoveFromPartialModel = partialModelList.PartialList.SingleOrDefault(r => r.PartialListProductId == id);

            if (itemToRemoveFromPartialModel != null)
            {
                partialModelList.PartialList.Remove(itemToRemoveFromPartialModel);
            }

            // copy the quantity from the model posted from delete button,
            // to the itemList, then save the new quantity to tempData.
            foreach (ShoppingCartObjectModel item in itemObjList)
            {
                PartialListItemModel itemToCopy = partialModelList.PartialList.SingleOrDefault(r => r.PartialListProductId == item.ProductID);
                item.Quantity = itemToCopy.PartialListProductBuyQuantity;
            }



            TempData["itemList"] = itemObjList;
            TempData.Keep("itemList");
            return(RedirectToAction("ShoppingCart"));
        }