Beispiel #1
0
        public async Task <IActionResult> AddComment(string commentContent, string slug, int itemsId)
        {
            if (!string.IsNullOrEmpty(commentContent) && !string.IsNullOrEmpty(slug))
            {
                var user = await _userManager.GetUserAsync(User);

                var u       = _userRepository.GetBy(user.Email);
                var comment = new Comment
                {
                    CommentContent = commentContent,
                    User           = u,
                    Items          = _itemsRepository.GetByItemsId(itemsId)
                };

                _itemsRepository.AddComment(comment);
                _itemsRepository.SaveChanges();
            }

            return(RedirectToAction("Detail", new { slug = slug }));
        }