예제 #1
0
        public async Task <IActionResult> AddCommment(HomePageViewModel model)
        {
            var user = User.Identity.Name;

            _logger.LogInformation($"{user} has added a comment");

            // Save to Db
            var saveToDb = await _process.SaveCommentToDb(model.NewsPostId, model.Comment, user);

            if (saveToDb)
            {
                return(RedirectToAction("Index", new { comment = "new", post = model.NewsPostId }));
            }
            else
            {
                var error = new ErrorViewModel()
                {
                    ErrorMessage = "There was an issue saving your comment"
                };

                return(View("Error", error));
            }
        }