Пример #1
0
        // GET: Cart
        public ActionResult DisplayCart()
        {
            List <ProductModel>      lstpm = new List <ProductModel>();
            ProductModelManager      ppM   = new ProductModelManager();
            Dictionary <string, int> dpm   = null;
            double Total = 0;

            if (Session["dpm"] != null)
            {
                dpm = Session["dpm"] as Dictionary <string, int>;
                foreach (KeyValuePair <string, int> item in dpm)
                {
                    ProductModel pm = ppM.GetProductByProductID(item.Key);
                    pm.RequiredQuantity = Convert.ToInt32(item.Value);
                    pm.Amount           = (pm.Rate) * Convert.ToDouble(pm.RequiredQuantity);
                    Total = Total + pm.Amount;
                    lstpm.Add(pm);
                }
                if (lstpm.Count > 0)
                {
                    lstpm[0].SubTotal = Total;
                }


                IEnumerable <ProductModel> ie = lstpm as IEnumerable <ProductModel>;
                Session["ie"] = ie;
                return(View(ie));
            }
            else
            {
                dpm = new Dictionary <string, int>();
                return(View("DisplayEmptyCart"));
            }
        }
Пример #2
0
        public ActionResult DisplayProduct(string Pid)
        {
            ProductModelManager pmM = new ProductModelManager();
            ProductModel        pm  = pmM.GetProductByProductID(Pid);

            return(View(pm));
        }