Askme.Domain.Question.AcceptSolution C# (CSharp) Method

AcceptSolution() public method

public AcceptSolution ( Answer answer ) : void
answer Answer
return void
        public virtual void AcceptSolution(Answer answer)
        {
            lock (localLock)
            {
                if (acceptedAnswer == null)
                {
                    acceptedAnswer = answer;
                    AssignPointForAcceptingAnswer();
                }
                else
                {
                    throw new NotSupportedException("An answer has been already accepted");
                }
            }
        }

Usage Example

Beispiel #1
0
 public virtual void AcceptAnswer(Question question,Answer answer)
 {
     if (!question.IsOwner(this))
         throw new NotSupportedException("An answer can be accepted only by the question's owner");
     question.AcceptSolution(answer);
 }