Пример #1
0
 public Answer(Guid questionId, Contributor contributor, BodyContent body)
 {
     Id               = Guid.NewGuid();
     QuestionId       = questionId;
     Contributor      = contributor;
     Body             = body;
     HappenedDateTime = DateTime.Now;
     Votes            = new List <Vote>();
     Comments         = new List <Comment>();
 }
Пример #2
0
        public void DownVoteAnswer(Guid answerId, Contributor contributor)
        {
            const int requiredReputation = 1000;

            if (contributor.GetReputation() < requiredReputation)
            {
                throw new InsufficientReputationException(
                          $@"The contributor '{contributor.Id}', does not have the required reputation to down vote the answer '{answerId}', 
                        current reputation: {contributor.GetReputation()},
                        required reputation: {requiredReputation}");
            }
        }
Пример #3
0
        public void UpVoteAnswer(Guid answerId, Contributor contributor)
        {
            const int requiredReputation = 1000;

            if (contributor.GetReputation() < requiredReputation)
            {
                throw new InsufficientReputationException(
                          $@"The contributor '{contributor.Id}', does not have the required reputation to up vote the answer '{answerId}', 
                        current reputation: {contributor.GetReputation()},
                        required reputation: {requiredReputation}");
            }

            var answer = Answers.FirstOrDefault(a => a.Id == answerId);

            if (answer == null)
            {
                throw new InvalidAnswerException(Id, answerId);
            }

            answer.UpVote(contributor.Id);
        }
Пример #4
0
 public int GetContributorReputation()
 {
     return(Contributor.GetReputation());
 }
Пример #5
0
 public Comment(Contributor contributor, string text)
 {
     Contributor      = contributor;
     Text             = text;
     HappenedDateTime = DateTime.Now;
 }