示例#1
0
 public ActionResult <string> AddComment(Comment comment)
 {
     if (comment.Content != null && comment.ArticleId != 0 && comment.FirstComment != false)
     {
         comment.CreateTime = DateTime.Now;
         string result = _articleService.AddComment(comment);
         return(Ok(result));
     }
     return(NotFound("评论内容、文章Id为空或不是第一评论者"));
 }
示例#2
0
        public string AddComment(string user_id, int article_id, string text, DateTime datetime, string user_name = "")
        {
            if (user_id == "")
            {
                user_id = articleService.GetUserIdByName(User.Identity.Name);
            }
            string image_path = "~/Images/" + user_id + ".jpg";

            articleService.AddComment(user_id, article_id, image_path, text, datetime);
            return("Your comment was added, but not approved. Please, wait some time");
        }
        public async Task <CommentDataTransfer> SendComment([FromBody] CommentDataTransfer commentDataTransfer)
        {
            if (await _articleService.AddComment(commentDataTransfer))
            {
                commentDataTransfer.Succeded = true;

                return(commentDataTransfer);
            }
            else
            {
                commentDataTransfer.Succeded = false;

                return(commentDataTransfer);
            }
        }
示例#4
0
 public IActionResult AddComment([FromQuery] int articleId, [FromBody] ArticleComment comment)
 {
     if (articleService.GetArticle(articleId) == null)
     {
         return(BadRequest(JsonConvert.SerializeObject("article does not exists")));
     }
     try
     {
         articleService.AddComment(articleId, comment);
         return(Ok(comment));
     }
     catch (ServiceException ex)
     {
         logger.LogError(ex.Message);
         return(BadRequest(JsonConvert.SerializeObject("Server error" + ex.Message)));
     }
 }
示例#5
0
        public async Task <IActionResult> AddCommentForArticle(int id, string text)
        {
            await _articleService.AddComment(id, text, await _userProfile.GetUserId(User));

            return(RedirectToAction("Article", new { id }));
        }
示例#6
0
 public IApiResult AddComment(int articleId, [FromBody] d_ArticleComment_Add d_ArticleComment_Add)
 {
     articleService.AddComment(articleId, d_ArticleComment_Add.MapTo <m_ArticleComment>());
     return(ApiResult.Succeed());
 }