public UpdateArticleCount ( long articleId, int categoryId, long userKeyId, ArticleCountEnum articleCountEnum ) : ReturnResult |
||
articleId | long | |
categoryId | int | |
userKeyId | long | |
articleCountEnum | ArticleCountEnum | |
return | ReturnResult |
public ReturnResult <long> InsertArticleComment(ArticleCommentDataContract model, int articleCategoryId) { if (null == model) { return(new ReturnResult <long>(101, 0, "参数异常,未找到数据")); } if (string.IsNullOrWhiteSpace(model.CommentContent)) { return(new ReturnResult <long>(102, 0, "参数异常,内容不允许为空")); } int rootCategoryId = articleCategoryService.GetRootCategoryId(articleCategoryId); if (rootCategoryId == -1) { return(new ReturnResult <long>(103, 0, "参数异常,文章分类错误")); } model.PostTime = DateTime.Now; model.UpdateTime = DateTime.Now; model.TableName = "SA_ArticleContent" + rootCategoryId; if (ArticleCommentRepository.Instance.InsertArticleComment(model)) { System.Threading.Tasks.Task.Factory.StartNew(() => articleContentService.UpdateArticleCount(model.ArticleID, articleCategoryId, model.UserKeyId, ArticleCountEnum.CommentCount)); return(new ReturnResult <long>(model.CommentID)); } else { return(new ReturnResult <long>(104, 0, "评论发表失败")); } }
/// <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, "收藏失败")); }