Example #1
0
        public async Task <IActionResult> AddComment(string postId, string message)
        {
            var loggedInUser = await _userManager.GetUserAsync(HttpContext.User);

            var comment = new Comment()
            {
                AuthorId       = loggedInUser.Id,
                AuthorName     = loggedInUser.FullName,
                AuthorImageUrl = GetImageName(loggedInUser.ImageUrl),
                CreationDate   = DateTime.Now,
                Message        = message,
                PostId         = new Guid(postId)
            };

            await _postService.AddCommentAsync(comment);

            await NotifyAsync(postId, loggedInUser);

            return(RedirectToAction("Index", "Forum"));
        }