Ejemplo n.º 1
0
        public ActionResult XemChiTiet(string id)
        {
            var san = new SanDao().ViewDetail(id);

            ViewBag.RelatedProducts = new SanDao().ListRelatedProducts(id);
            return(View(san));
        }
Ejemplo n.º 2
0
        public ActionResult Index( )
        {
            ViewBag.Slides = new SlideDao().ListAll();
            var sanDao = new SanDao();

            ViewBag.NewProducts = sanDao.ListNewProduct();
            return(View());
        }
Ejemplo n.º 3
0
        public JsonResult ListName(string q)
        {
            var data = new SanDao().ListName(q);

            return(Json(new
            {
                data = data,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public ActionResult AddItem(string productId, int quantity)
        {
            var product = new SanDao().ViewDetail(productId);
            var cart    = Session[CartSession];

            if (cart != null)
            {
                var list = (List <CartItem>)cart;
                if (list.Exists(x => x.sans.MaSan == productId))
                {
                    foreach (var item in list)
                    {
                        if (item.sans.MaSan == productId)
                        {
                            item.SoLuong += quantity;
                        }
                    }
                }
                else
                {
                    //tạo mới đối tượng cart item
                    var item = new CartItem();
                    item.sans    = product;
                    item.SoLuong = quantity;
                    list.Add(item);
                }
                //Gán vào session
                Session[CartSession] = list;
            }
            else
            {
                //tạo mới đối tượng cart item
                var item = new CartItem();
                item.sans    = product;
                item.SoLuong = quantity;
                var list = new List <CartItem>();
                list.Add(item);
                //Gán vào session
                Session[CartSession] = list;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult Search(string keyword, int page = 1, int pageSize = 1)
        {
            int totalRecord = 0;
            var model       = new SanDao().Search(keyword, ref totalRecord, page, pageSize);

            ViewBag.Total   = totalRecord;
            ViewBag.Page    = page;
            ViewBag.Keyword = keyword;
            int maxPage   = 5;
            int totalPage = 0;

            totalPage         = (int)Math.Ceiling((double)(totalRecord / pageSize));
            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = page + 1;
            ViewBag.Prev      = page - 1;

            return(View(model));
        }