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")); }
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()); }
public Task <RatingComment> Add(RatingComment ratingComment) { ratingComment.Id = Guid.NewGuid(); return(Task.FromResult(ratingComment)); }
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); }