/// <summary> /// 添加到收藏夹 /// </summary> /// <returns></returns> public ActionResult AddToCollection(int carid) { var session = Session["logID"]; if (session == null) { return RedirectToAction("Login"); } else { int userid = Int32.Parse(session.ToString()); CollectionModel model = new CollectionModel(); model.CarID = carid; model.UserInfo_ID = userid; ICollectionDal dal = new CollectionDal(); dal.AddCollection(model); return RedirectToAction("MyCollection"); } }
public ActionResult MyCollection() { var session = Session["logID"]; if (session == null) { return RedirectToAction("Login"); } else { int userid = Int32.Parse(session.ToString()); ICollectionDal dal = new CollectionDal(); List<CollectionModel> list = dal.GetCollectionsByUserId(userid); return View(list); } }
public ActionResult DeleteCollection(int id) { ICollectionDal dal=new CollectionDal(); int result=dal.RemoveCollection(id); if (result==1) { return RedirectToAction("MyCollection"); } else { return RedirectToAction("Failed", "PageHelper"); } }