public async Task <IActionResult> AddComment(string content, string userEmail, int newsId = 0) { if (newsId == 0) { return(BadRequest()); } var news = await _newsRepository.GetNewsByIdAsync(newsId); if (news == null) { return(BadRequest()); } var user = await _userRepository.GetUserByEmailAsync(userEmail); if (user == null) { return(StatusCode(403)); } var comment = new Comment() { Content = content, DateTime = DateTime.Now, IsConfirmed = true, NewsId = newsId, UserId = user.Id }; await _commentRepository.AddCommentForNewsAsync(comment, user, news); TempData["Success"] = "نظر شما با موفقیت افزوده شد"; return(RedirectToAction("ShowNews", "News", new { newsId })); }