public IActionResult CreateTopicComment(AddTopicCommentDto addTopicCommentDto) { var result = this._topicService.CreateTopicComment(addTopicCommentDto); if (result.ResultType == ResultType.UnAuthorized) { return(Unauthorized()); } if (result.ResultType == ResultType.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public IResult CreateTopicComment(AddTopicCommentDto addTopicCommentDto) { var errorResult = BusinessRules.Run(CheckAuthenticatedUserExist(), IsTopicExist(addTopicCommentDto.TopicId)); if (errorResult != null) { return(errorResult); } var user = _authService.GetAuthenticatedUser().Result.Data; var topic = _uow.Topics.Get(x => x.Id == addTopicCommentDto.TopicId); var topicComment = new TopicComment() { UserId = user.Id, Comment = addTopicCommentDto.Comment }; topic.TopicComments.Add(topicComment); _uow.Topics.Update(topic); _uow.Commit(); return(new SuccessResult(Message.TopicCommentCreated)); }