Пример #1
0
        public async Task <IActionResult> CommentTopic(int userId, int topicId, IncomingComment comment)
        {
            var commentToSave = new RatingComment {
                Content = comment.Content,
                Side    = comment.Side
            };

            _ratingRepo.CreateComment(userId, topicId, commentToSave);

            if (await _mainRepo.SaveAll())
            {
                return(NoContent());
            }
            return(BadRequest("Failed"));
        }
Пример #2
0
        public async Task <Result> AddComment(Guid ratingId, string comment)
        {
            var rating = await _ratingRepository.Get(ratingId);

            if (rating == null)
            {
                return(Result.ErrorResult(ErrorCodes.RatingNotFound));
            }

            var ratingComment = new RatingComment()
            {
                RatingId = ratingId,
                Comment  = comment
            };

            await _ratingCommentRepository.Add(ratingComment);

            return(Result.SuccessResult());
        }
Пример #3
0
        public Task <RatingComment> Add(RatingComment ratingComment)
        {
            ratingComment.Id = Guid.NewGuid();

            return(Task.FromResult(ratingComment));
        }
Пример #4
0
 public void CreateComment(int userId, int topicId, RatingComment comment)
 {
     comment.User  = _context.Users.Find(userId);
     comment.Topic = _context.RatingTopics.Find(topicId);
     _context.RatingComments.Add(comment);
 }