示例#1
0
        public IEnumerable <CategoryItem> GetCategoryItems(string code, bool addSelectOption = false, string selectOption = "[Select Option]", bool voided = false)
        {
            var categoryItems = new List <CategoryItem>();

            if (addSelectOption)
            {
                var initialSelected = CategoryItem.CreateInitial(selectOption);
                categoryItems.Add(initialSelected);
            }

            var categotry = _categoryRepository.GetWithCode(code);

            if (null != categotry)
            {
                var items = categotry.Items
                            .Where(x => x.Voided == voided)
                            .ToList();

                if (null != items && items.Count > 0)
                {
                    categoryItems.AddRange(items);
                    categoryItems = categoryItems.OrderBy(x => x.Rank).ToList();
                }
            }

            return(categoryItems);
        }
        public QuestionTemplate(Question question, string response = "")
        {
            Scaling  = 100;
            Id       = question.Id;
            Display  = question.ToString();
            Concept  = question.Concept;
            Allow    = true;
            Required = question.IsRequired;

            ShowTextObs    = Concept.ConceptTypeId == "Text";
            ShowSingleObs  = Concept.ConceptTypeId == "Single";
            ShowNumericObs = Concept.ConceptTypeId == "Numeric";
            ShowMultiObs   = Concept.ConceptTypeId == "Multi";
            ShowDateObs    = Concept.ConceptTypeId == "DateTime";

            if (ShowSingleObs || ShowMultiObs)
            {
                var initialSelected = CategoryItem.CreateInitial("[Select Option]");
                var options         = Concept.Category.Items;
                options.Add(initialSelected);
                options = options.OrderBy(x => x.Rank).ToList();

                if (ShowSingleObs)
                {
                    SingleOptions         = new ObservableCollection <CategoryItem>(options);
                    _selectedSingleOption = initialSelected;
                }

                if (ShowMultiObs)
                {
                    MultiOptions = options;
                }
            }

            if (ShowDateObs)
            {
                Scaling       = 200;
                _responseDate = DateTime.Today.Date.AddYears(1);
            }
        }