public ActionResult MovieDetail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var _movie = movieManage.Find(id); if (_movie == null && _movie.Hidden == Movie.Hiddens.隐藏) { return(View("404NotFound")); } if (Session["UserID"] != null) { var _userid = Convert.ToInt32(Session["UserID"]); var favCount = favoriteManage.Count(p => p.UserID == _userid && p.MovieID == id); ViewBag.AlreadyFavorite = (favCount == 0) ? false : true; var _history = historyManage.Find(id, _userid); if (_history == null) { History his = new History(); his.ViewTime = DateTime.Now; his.MovieID = id; his.UserID = _userid; var _resp = historyManage.Add(his); } else { _history.ViewTime = DateTime.Now; var _resp = historyManage.Update(_history); } } return(View(_movie)); }
public ActionResult Favorite(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var _movie = movieManage.Find(id); if (_movie.Hidden == Movie.Hiddens.隐藏 || _movie == null) { return(HttpNotFound()); } var _user = userManage.Find(Convert.ToInt32(Session["UserID"])); var MovieID = _movie.ID; //Status【0:收藏成功1:取消收藏】 var _fav = favoriteManage.Find(id, _user.ID); if (_fav == null) { Favorite _favor = new Favorite(); _favor.MovieID = id; _favor.UserID = _user.ID; var _resp = favoriteManage.Add(_favor); return(Json(new { StatusCode = 0 })); } else { var _resp = favoriteManage.Delete(_fav.ID); return(Json(new { StatusCode = 1 })); } }
public ActionResult Modify(int ID) { return(View(movieManage.Find(ID))); }