예제 #1
0
        private bool IsDuplicateQuestion(string question, Guid?questionId = null)
        {
            var existing = SecurityQuestions.FirstOrDefault(q =>
                                                            q.Question.Equals(question, StringComparison.InvariantCultureIgnoreCase) && (questionId == null || q.Id != questionId));

            return(existing != null);
        }
예제 #2
0
        public void UpdateQuestion(Guid questionId, string question, string answer)
        {
            Ensure.Argument.NotNull(questionId, "questionId");
            Ensure.Argument.NotNullOrEmpty(question, "question");
            Ensure.Argument.NotNullOrEmpty(answer, "answer");

            var securityQuestion = SecurityQuestions.FirstOrDefault(q => q.Id == questionId);

            if (securityQuestion == null)
            {
                throw new ArgumentException("A security question with Id '{0}' does not exist.");
            }

            //if (IsDuplicateQuestion(question, securityQuestion.Id))
            //{
            //    throw new ArgumentException("The question '{0}' already exists.".FormatWith(question));
            //}

            securityQuestion.Update(question, answer);
        }
예제 #3
0
 public SecurityQuestion GetSecurityQuestion(Guid questionId)
 {
     Ensure.Argument.NotNull(questionId, "questionId");
     return(SecurityQuestions.FirstOrDefault(q => q.Id == questionId));
 }