public ActionResult Login() { var Info = XCookie.GetValue("user", "&").Split('&'); ViewBag.Id = Info[0]; ViewBag.Password = Info[1]; return(View()); }
public ActionResult _Favorite() { var ids = XCookie.GetValue("Favorites"); var list = dbc.Products.ToList() .Where(p => ids.Contains(p.Id.ToString())); return(PartialView(list)); }
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("")); }
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)); }
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)); }