internal Answer(Question question, string content, User answeredBy) { var id = Guid.NewGuid(); var answerSuggested = new AnswerSuggested(id, question.Id, content, answeredBy.UserName); Apply(answerSuggested); Append(answerSuggested); }
internal Question(User askedBy, string content) { var id = Guid.NewGuid(); var questionAsked = new QuestionAsked(id, askedBy.UserName, content); Apply(questionAsked); Append(questionAsked); }
public IActionResult Ask([FromBody]AskQuestionModel questionModel) { User user = new User("dmusial"); Question question = user.Ask(questionModel.Content); _questionRepository.Save(question); _logger.LogInformation(string.Format("Question Asked: '{0}' by {1}. Question Id {2}", question.Content, question.AskedByUserName, question.Id)); return new ObjectResult(question); }
public IActionResult Suggest([FromBody]SuggestAnswerModel answerModel) { var question = _questionRepository.Get(answerModel.QuestionId); if (question == null) return HttpNotFound(); User user = new User("dmusial"); var answer = user.SuggestAnswerTo(question, answerModel.AnswerContent); _answerRepository.Save(answer); return new ObjectResult(answer); }
public IActionResult Downvote(Guid answerId,[FromBody]DownvoteModel downvote) { var answer = _answerRepository.Get(downvote.AnswerId); if (answer == null) return HttpNotFound(); User user = new User("dmusial"); answer.Downvote(user); _answerRepository.Save(answer); return new ObjectResult(answer); }
public void Downvote(User downvotedBy) { var asnwerDownvoted = new AnswerDownvoted(Id, downvotedBy.UserName); Apply(asnwerDownvoted); Append(asnwerDownvoted); }
public void Upvote(User upvotedBy) { var answerUpvoted = new AnswerUpvoted(Id, upvotedBy.UserName); Apply(answerUpvoted); Append(answerUpvoted); }