/// <summary> /// 收藏帖子 /// </summary> public ReturnResult<bool> AddArticleCollect(ArticleCollectDataContract articleCollect, int categoryId) { int rootCategoryId = articleCategoryService.GetRootCategoryId(categoryId); if (rootCategoryId == -1) { return new ReturnResult<bool>(101, false, "分类参数错误"); } articleCollect.TableName = "SA_ArticleContent" + rootCategoryId; if (ArticleCollectRepository.Instance.IsExists(articleCollect.ArticleID, articleCollect.TableName)) { return new ReturnResult<bool>(true); } var article = ArticleContentRepository.Instance.GetArticle(rootCategoryId, articleCollect.ArticleID); if (null == article) { return new ReturnResult<bool>(102, false, "未找到指定的帖子"); } articleCollect.Title = article.Title; articleCollect.Author = article.Author; articleCollect.AuthorUserKeyId = article.UserKeyId; articleCollect.CollectTime = DateTime.Now; if (ArticleCollectRepository.Instance.InsertArticleCollect(articleCollect)) { System.Threading.Tasks.Task.Factory.StartNew(() => articleContentService.UpdateArticleCount(article.ArticleID, article.CategoryId, articleCollect.UserKeyId, ArticleCountEnum.CollectCount)); return new ReturnResult<bool>(true); } return new ReturnResult<bool>(103, false, "收藏失败"); }
public JsonResult CollectArticle(OauthToken token, long articleId, int categoryId) { var model = new ArticleCollectDataContract() { UserKeyId = token.UserKeyId, ArticleID = articleId, CollectTime = DateTime.Now }; return Json(articleCollectService.AddArticleCollect(model, categoryId), JsonRequestBehavior.AllowGet); }