示例#1
0
 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);
 }
示例#2
0
 internal Question(User askedBy, string content)
 {
     var id = Guid.NewGuid();
     
     var questionAsked = new QuestionAsked(id, askedBy.UserName, content);
     Apply(questionAsked);
     Append(questionAsked);
 }
示例#3
0
 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);
 }
示例#4
0
 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);
 }
示例#5
0
 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);
 }
示例#6
0
 public void Downvote(User downvotedBy)
 {
     var asnwerDownvoted = new AnswerDownvoted(Id, downvotedBy.UserName);
     Apply(asnwerDownvoted);
     Append(asnwerDownvoted);
 }
示例#7
0
 public void Upvote(User upvotedBy)
 {
     var answerUpvoted = new AnswerUpvoted(Id, upvotedBy.UserName);
     Apply(answerUpvoted);
     Append(answerUpvoted);
 }