public ActionResult Login()
        {
            var Info = XCookie.GetValue("user", "&").Split('&');

            ViewBag.Id       = Info[0];
            ViewBag.Password = Info[1];
            return(View());
        }
예제 #2
0
        public ActionResult _Favorite()
        {
            var ids  = XCookie.GetValue("Favorites");
            var list = dbc.Products.ToList()
                       .Where(p => ids.Contains(p.Id.ToString()));

            return(PartialView(list));
        }
예제 #3
0
        public ActionResult AddToFavorite(int Id)
        {
            var ids = XCookie.GetValue("Favorites", Id.ToString());

            if (!ids.Contains(Id.ToString()))
            {
                ids += "&" + Id.ToString();
            }
            XCookie.Add("Favorites", 30, ids);
            return(Content(""));
        }
예제 #4
0
        public ActionResult _Favorite()
        {
            var ids  = XCookie.GetValue("Favorites");
            var list = dbc.Products.ToList()
                       .Where(p => ids.Contains(p.Id.ToString())
                              ).Select(p => new
            {
                Name = p.Name,
                Id   = p.Id
            });

            return(Json(list, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public ActionResult Detail(int Id)
        {
            var model = dbc.Products.Find(Id);

            // Tăng số lần xem
            model.Views++;
            dbc.SaveChanges();

            // Ghi nhận mặt hàng đã xem bằng cookie
            var ids = XCookie.GetValue("Views", Id.ToString());

            if (!ids.Contains(Id.ToString()))
            {
                ids += "&" + Id.ToString();
            }
            XCookie.Add("Views", 30, ids);

            // Truy vấn hàng đã xem
            ViewBag.Views = dbc.Products.ToList()
                            .Where(p => ids.Contains(p.Id.ToString()));

            return(View(model));
        }