예제 #1
0
        public ProfileQuestion(ProfileCategory category, RankingManager rankingManger, ProfileImportQuestion importQuestion) : this(category, rankingManger)
        {
            IsCustomQuestion = true;
            Weight           = 10;
            CustomQuestionID = importQuestion.ID;
            CanEdit          = true;
            CanDelete        = true;
            CanSelect        = true;
            IsReadOnly       = false;

            Question         = importQuestion.QuestionObj.Question;
            Comments         = importQuestion.QuestionObj.Comments;
            References       = importQuestion.QuestionObj.References;
            SupplementalInfo = importQuestion.QuestionObj.SupplementalInfo;
            IsSelect         = true;

            if (category.DoesSubLabelNumberAlreadyExist(this, importQuestion.QuestionObj.SubLabelNumber))
            {
                SubLabelNumber = category.GetNextSubLabelNumber();
            }
            else
            {
                SubLabelNumber = importQuestion.QuestionObj.SubLabelNumber;
            }
        }
예제 #2
0
        internal Tuple <bool, ProfileQuestion> AddImportQuestion(ProfileImportQuestion importQuestion)
        {
            ProfileCategory category;

            if (!dictionaryCategoriesBySubLabel.TryGetValue(importQuestion.CategorySubLabel, out category))
            {
                category          = new ProfileCategory(this);
                category.SubLabel = importQuestion.CategorySubLabel;
                category.Heading  = importQuestion.Category;
                category.IsSelect = true;
                AddCategory(category);
            }


            if (!category.ContainsImportQuestion(importQuestion))
            {
                ProfileQuestion question = new ProfileQuestion(category, RankingManger, importQuestion);
                category.AddQuestion(question);
                return(Tuple.Create(true, question));
            }
            else
            {
                return(Tuple.Create <bool, ProfileQuestion>(false, null));
            }
        }
예제 #3
0
 internal void RemoveCategory(ProfileCategory profileCategory)
 {
     ProfileCategories.Remove(profileCategory);
     if (profileCategory.SubLabel != null)
     {
         dictionaryCategoriesBySubLabel.Remove(profileCategory.SubLabel);
     }
 }
예제 #4
0
        public static ValidationResult ValidateSubLabel(String value, ValidationContext context)
        {
            ProfileCategory category = (ProfileCategory)context.ObjectInstance;

            if (category.DoesSubLabelExistAlready(value))
            {
                return(new ValidationResult("ID already exists.", new string[] { context.MemberName }));
            }
            return(ValidationResult.Success);
        }
예제 #5
0
        public bool IsSame(ProfileCategory profileCategory)
        {
            if (this.Heading != profileCategory.Heading ||
                this.QuestionGroupHeadingID != profileCategory.QuestionGroupHeadingID || this.SubLabel != profileCategory.SubLabel ||
                this.IsSelect != profileCategory.IsSelect)
            {
                return(false);
            }

            if (dictionaryDefaultQuestions.Count != profileCategory.dictionaryDefaultQuestions.Count)
            {
                return(false);
            }

            foreach (ProfileQuestion question in profileCategory.ProfileQuestions)
            {
                if (question.IsCustomQuestion)
                {
                    ProfileQuestion thisProfileQuestion;
                    if (this.dictionaryCustomQuestions.TryGetValue(question.CustomQuestionID, out thisProfileQuestion))
                    {
                        if (!thisProfileQuestion.IsSame(question))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    ProfileQuestion thisProfileQuestion;
                    if (!this.dictionaryDefaultQuestions.TryGetValue(question.QuestionDefaultID, out thisProfileQuestion))
                    {
                        return(false);
                    }
                    else
                    {
                        if (thisProfileQuestion.IsSelect != question.IsSelect)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
예제 #6
0
        internal static ProfileQuestion CreateNewQuestion(ProfileCategory profileCategory, RankingManager rankingManager)
        {
            int             nextSubLabelNumber = profileCategory.GetNextSubLabelNumber();
            ProfileQuestion question           = new ProfileQuestion(profileCategory, rankingManager)
            {
                SubFunCatLabel = profileCategory.SubFunCatLabel,
                SubLabelNumber = nextSubLabelNumber
            };

            question.Weight           = 10;
            question.CanDelete        = true;
            question.CanEdit          = true;
            question.CanSelect        = true;
            question.IsCustomQuestion = true;
            question.CustomQuestionID = Guid.NewGuid();
            question.IsSelect         = true;

            return(question);
        }
예제 #7
0
 public ProfileQuestion(ProfileCategory category, RankingManager rankingManger)
 {
     this.Category       = category;
     this.SubFunCatLabel = category.SubFunCatLabel;
     this.RankingManger  = rankingManger;
 }
예제 #8
0
 internal void AddCategory(ProfileCategory profileCategory)
 {
     ProfileCategories.Add(profileCategory);
     dictionaryCategoriesBySubLabel[profileCategory.SubLabel] = profileCategory;
 }