public ActionResult Likes(int userID, int commentID) { var _like = likeMange.Find(userID, commentID); var _comment = commentMange.Find(commentID); var _user = userManage.Find(_comment.UserID); if (_like == null) { Like like = new Like(); like.UserID = userID; like.MovieCommentID = commentID; _comment.Likes = _comment.Likes++; _user.SweetScore = _user.SweetScore++; var _resp = likeMange.Add(like); var _res = commentMange.Update(_comment); var _re = userManage.Update(_user); return(Json(new { StatusCode = 1 })); } else { _comment.Likes = _comment.Likes--; _user.SweetScore = _user.SweetScore--; var _res = commentMange.Update(_comment); var _re = userManage.Update(_user); var _resp = likeMange.Delete(_like.ID); return(Json(new { StatusCode = 0 })); } }
public ActionResult Modify(int ID) { var _users = new UserManage().FindList(); List <SelectListItem> _userlistItems = new List <SelectListItem>(_users.Count()); foreach (var _user in _users) { _userlistItems.Add(new SelectListItem() { Text = _user.Username, Value = _user.ID.ToString() }); } ViewBag.Users = _userlistItems; var _movies = new MovieManage().FindList(); List <SelectListItem> _movielistItems = new List <SelectListItem>(_movies.Count()); foreach (var _movie in _movies) { _movielistItems.Add(new SelectListItem() { Text = _movie.MovieName, Value = _movie.ID.ToString() }); } ViewBag.Movies = _movielistItems; var comment = commentManage.Find(ID); var _likes = new LikeManage().FindList(); int like = 0; foreach (var _like in _likes) { if (ID == _like.MovieCommentID) { like++; } } comment.Likes = like; return(PartialView(comment)); }