Esempio n. 1
0
        private void QuestionCharacterConnectionViewSourceFilter(object sender, FilterEventArgs e)
        {
            QuestionCharacterConnection cat = e.Item as QuestionCharacterConnection;

            if (cat != null)
            {
                dbContextQuestionCharacterConnection.Questions.Load();
                dbContextQuestionCharacterConnection.Characters.Load();


                e.Accepted =
                    (dbContextQuestionCharacterConnection.Characters.Local.First(d => d.Id == cat.Character)
                     .Name.ToUpper().Contains(QuestionCharacterConnectionsSearchBox.Text.ToUpper())) ||
                    (dbContextQuestionCharacterConnection.Questions.Local.First(s => s.Id == cat.Question)
                     .Name.ToUpper().Contains(QuestionCharacterConnectionsSearchBox.Text.ToUpper()));
            }
        }
Esempio n. 2
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            QuestionCharacterConnection cQCCon = (value as BindingGroup).Items[0] as QuestionCharacterConnection;

            if (cQCCon.Character == 0)
            {
                return(new ValidationResult(false, "You have to choose one character option"));
            }

            if (cQCCon.Question == 0)
            {
                return(new ValidationResult(false, "You have to choose one question option"));
            }


            if (cQCCon.OccurencesNumber < 0)
            {
                return(new ValidationResult(false, "Occurence number value shall be greater or equal 0"));
            }

            if (cQCCon.YesAnswers < 0)
            {
                return(new ValidationResult(false, "Yes answers value shall be greater or equal 0"));
            }

            if (cQCCon.ProbablyYesAnswers < 0)
            {
                return(new ValidationResult(false, "Probably yes value shall be greater or equal 0"));
            }

            if (cQCCon.DontKnowAnswers < 0)
            {
                return(new ValidationResult(false, "Don't know value shall be greater or equal 0"));
            }

            if (cQCCon.ProbablyNotAnswers < 0)
            {
                return(new ValidationResult(false, "Probably not value shall be greater or equal 0"));
            }

            if (cQCCon.NotAnswers < 0)
            {
                return(new ValidationResult(false, "Not answers value shall be greater or equal 0"));
            }

            if ((cQCCon.ProbabilisticEvaluation < 0.0) || (cQCCon.ProbabilisticEvaluation > 1.0))
            {
                return(new ValidationResult(false, "Probabilisic evaluation value shall be in range (0.0, 1.0)"));
            }

            AkinatorDatabaseEntities tempContext = new AkinatorDatabaseEntities();

            if (tempContext.QuestionCharacterConnections
                .Count(s => ((s.Character == cQCCon.Character) && (s.Id != cQCCon.Id) && (s.Question == cQCCon.Question))) > 0)
            {
                return(new ValidationResult(false, "Character Question connection have to be unique"));
            }


            return(ValidationResult.ValidResult);
        }