public ActionResult WeikeDetail(int weikeId) { // get comment list WeikeData data = WeikeDB.FindByWeikeId(weikeId); return(Json(new { weikeData = data })); }
public ActionResult WeikeDetailWithComment(int weikeId) { WeikeData weikeDetail = WeikeDB.FindByWeikeId(weikeId); List <NestedComment> comments = NestedComment.getAllCommentsByWeikeId(weikeId); User user = (User)Session["user"]; List <FavoriteData> FavoriteWeikeList = FavoriteDB.FindFavoriteWeikeByUserId(user.id); bool hasFavorited = false; foreach (FavoriteData fw in FavoriteWeikeList) { if (weikeId == fw.weike.weike_id) { hasFavorited = true; } } return(Json(new { weikeData = weikeDetail, comments = comments, hasFavorited = hasFavorited })); }
public ActionResult Dislike(int weikeId) { // todo if ((User)Session["user"] != null) { int user_id = ((User)Session["user"]).id; FavoriteDB.Delete(user_id, weikeId); WeikeData wd = WeikeDB.FindByWeikeId(weikeId); Notice notice = new Notice(0, user_id, wd.weike.user_id, weikeId, "dislike", false, DateTime.Now); NoticeDB.Insert(notice); return(Json(new { success = true })); } else { return(Json(new { success = false, message = "用户尚未登录" })); } }