Пример #1
0
 public ActionResult PostComment(CommentFormViewModel form)
 {
     if (ModelState.IsValid)
     {
         var comment = new ArticleComment()
         {
             ArticleId = form.ArticleId,
             ParentId  = form.ParentId,
             Name      = form.Name,
             Email     = form.Email,
             Message   = form.Message,
             AddedDate = DateTime.Now,
         };
         _articlesRepo.AddComment(comment);
         return(RedirectToAction("ContactUsSummary", "Home"));
     }
     return(RedirectToAction("Details", new { id = form.ArticleId }));
 }
Пример #2
0
        public async Task <IActionResult> AddComment(int id, ArticleCommentsDto comment)
        {
            comment.ArticleId = id;
            comment.AddedDate = DateTime.Now;
            var result = await _repo.AddComment(comment);

            if (result == null)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response <ArticleCommentsDto>()
                {
                    Succeeded = false, Message = "مقاله پیدا نشد"
                }));
            }

            return(Ok(new Response <ArticleCommentsDto>(result)
            {
                Message = "کامنت با موفقین اضافه شد"
            }));
        }