示例#1
0
        public ActionResult CartItem()
        {
            Ecommerce.Areas.admin.Models.ShopingContext shpoing = new Ecommerce.Areas.admin.Models.ShopingContext();
            List <AddToCartBean> cartList = AddToCart.getData();

            if (cartList != null)
            {
                foreach (AddToCartBean bean in cartList)
                {
                    int id = Convert.ToInt32(bean.pid);
                    Ecommerce.Areas.admin.Models.Product.Product prod = shpoing.product.Where(x => x.Id == id).FirstOrDefault();
                    bean.ProductName  = prod.p_name;
                    bean.ProductPrice = float.Parse(prod.p_price.ToString());
                    bean.ProductQty   = 1;
                    bean.TotalPrice   = 1 * bean.ProductPrice;
                    bean.ProductImage = shpoing.uploadImage.Where(x => x.p_id == id).FirstOrDefault().imageURL;
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
            Session["AddList"] = cartList;
            return(View(cartList));
        }
示例#2
0
        public ActionResult PaymentMethod()
        {
            Ecommerce.Models.Register.RegisterPro shippingdetails = null;
            try
            {
                shippingdetails =
                    ((Ecommerce.Models.Register.RegisterPro)Session["userId"]);
            }
            catch { }
            ViewBag.shippingDetails = shippingdetails;
            Ecommerce.Areas.admin.Models.ShopingContext shpoing = new Ecommerce.Areas.admin.Models.ShopingContext();
            List <AddToCartBean> cartList = AddToCart.getData();

            if (cartList != null)
            {
                foreach (AddToCartBean bean in cartList)
                {
                    int id = Convert.ToInt32(bean.pid);
                    Ecommerce.Areas.admin.Models.Product.Product prod = shpoing.product.Where(x => x.Id == id).FirstOrDefault();
                    bean.ProductName  = prod.p_name;
                    bean.ProductPrice = float.Parse(prod.p_price.ToString());
                    bean.ProductQty   = 1;
                    bean.TotalPrice   = 1 * bean.ProductPrice;
                    bean.ProductImage = shpoing.uploadImage.Where(x => x.p_id == id).FirstOrDefault().imageURL;
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
            Session["AddList"]  = cartList;
            ViewBag.cartAddItem = cartList;
            return(View());
        }
示例#3
0
        public ActionResult PaymentMethod_Post()
        {
            Ecommerce.Areas.admin.Models.ShopingContext shpoing =
                new Ecommerce.Areas.admin.Models.ShopingContext();
            int c_id = ((Ecommerce.Models.Register.RegisterPro)Session["userId"]).Id;
            List <AddToCartBean> cartList = AddToCart.getData();

            if (cartList != null)
            {
                int   qty    = 0;
                float tprice = 0;
                foreach (AddToCartBean bean in cartList)
                {
                    qty    = 1 + qty;
                    tprice = tprice + bean.ProductPrice;
                }
                OrderDetails OD = new OrderDetails();
                OD.c_id       = c_id;
                OD.datetime   = DateTime.Now;
                OD.status     = 1;
                OD.totalPrice = tprice;
                OD.totalQty   = qty;
                shpoing.OrderDetails.Add(OD);
                shpoing.SaveChanges();
                Order ord;
                foreach (AddToCartBean bean in cartList)
                {
                    int id = Convert.ToInt32(bean.pid);
                    Ecommerce.Areas.admin.Models.Product.Product prod = shpoing.product.Where(x => x.Id == id).FirstOrDefault();
                    ord                = new Order();
                    ord.c_id           = c_id;
                    ord.OrderDetailsID = OD.Id;
                    ord.date           = DateTime.Now;
                    ord.order_status   = 1;
                    ord.p_id           = Convert.ToInt32(bean.pid);
                    ord.price          = bean.ProductPrice * 1;
                    ord.qty            = 1;
                    shpoing.Order.Add(ord);
                    shpoing.SaveChanges();
                }
                // Session.Remove("AddList");
            }
            Ecommerce.Models.Register.RegisterPro shippingdetails = null;
            try
            {
                shippingdetails =
                    ((Ecommerce.Models.Register.RegisterPro)Session["userId"]);
            }
            catch { }
            ViewBag.shippingDetails = shippingdetails;
            ViewBag.cartAddItem     = (List <AddToCartBean>)Session["AddList"];
            return(RedirectToAction("ThankYou", "Confirm"));
        }