public QuestionVM QuestionCreate()
        {
            var questionVM = questionHelper.QuestionData(answerLetter);

            if (validator.Validate(questionVM).IsValid)
            {
                Dye.Succsess();
                Console.WriteLine("You have successfully created question");
                Console.ResetColor();
                return(questionVM);
            }
            else
            {
                Dye.Fail();
                Console.WriteLine(validator.Validate(questionVM));
                Console.ResetColor();
                QuestionCreate();
                return(null);
            }
        }
        public Question Insert(Question question)
        {
            var validator = new QuestionValidator();
            var results   = validator.Validate(question);

            if (results.IsValid)
            {
                repository.Insert(question);

                UoW.Commit();
                return(question);
            }
            else
            {
                var errors = results.Errors.Select(e => e.ErrorMessage).ToList();
                throw new BusinessException(errors);
            }
        }
Beispiel #3
0
        public override ValidationResult IsValid()
        {
            var validator = new QuestionValidator();

            return(validator.Validate(this));
        }