Esempio n. 1
0
        public List <Vocabulary> GetVocabularies(int portalId, int pageIndex, int pageSize, int scopeTypeId, out int total)
        {
            var vocabularies = _vocabularyController.GetVocabularies().Where(v => v.ScopeType.ScopeType == "Application" || (v.ScopeType.ScopeType == "Portal" && v.ScopeId == portalId));

            if (scopeTypeId != Null.NullInteger)
            {
                vocabularies = vocabularies.Where(v => v.ScopeTypeId == scopeTypeId);
            }
            total = vocabularies.Count();
            return(vocabularies.Skip(pageIndex * pageSize).Take(pageSize).ToList());
        }
Esempio n. 2
0
        // TODO: Need separate methods to get and update
        public static string Update(DropDownList comboWorkingHours, string workingHours, bool addToVocabulary)
        {
            workingHours = workingHours.Trim();
            var workingHoursNonEmpty = !string.IsNullOrWhiteSpace(workingHours);

            if (comboWorkingHours.SelectedIndex <= 0 || workingHoursNonEmpty)
            {
                // TODO: Shouldn't we try to add term after updating main item?
                if (addToVocabulary && workingHoursNonEmpty)
                {
                    // try add new term to working hours vocabulary
                    var vocCtrl = new VocabularyController();
                    var voc     = vocCtrl.GetVocabularies().SingleOrDefault(v => v.Name == UniversityConfig.Instance.Vocabularies.WorkingHours);
                    if (voc != null)
                    {
                        var termCtrl = new TermController();
                        termCtrl.AddTerm(new Term(workingHours, "", voc.VocabularyId));
                        vocCtrl.ClearVocabularyCache();
                    }
                }

                return(workingHours);
            }

            // else: get working hours from a combo
            return(comboWorkingHours.SelectedItem.Text);
        }
        protected override void OnInit()
        {
            base.OnInit();

            if (View.Model.Vocabulary == null)
            {
                View.Model.Vocabulary = VocabularyController.GetVocabularies().Where(v => v.VocabularyId == VocabularyId).SingleOrDefault();
                View.Model.Terms      = TermController.GetTermsByVocabulary(VocabularyId).ToList();
            }
        }
        public void VocabularyController_GetVocabularies_Returns_List_Of_Vocabularies()
        {
            // Arrange
            var mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetVocabularies()).Returns(MockHelper.CreateValidVocabulariesReader(Constants.VOCABULARY_ValidCount));
            var vocabularyController = new VocabularyController(mockDataService.Object);

            // Act
            IQueryable<Vocabulary> vocabularys = vocabularyController.GetVocabularies();

            // Assert
            Assert.AreEqual(Constants.VOCABULARY_ValidCount, vocabularys.Count());
        }
Esempio n. 5
0
        protected IEnumerable <Term> GetTerms()
        {
            var terms   = new List <Term> ();
            var vocCtrl = new VocabularyController();
            var vocs    = vocCtrl.GetVocabularies();

            foreach (var voc in vocs)
            {
                if (!voc.IsSystem)
                {
                    terms.AddRange(voc.Terms);
                }
            }
            return(terms.OrderBy(t => t.Name));
        }