Пример #1
0
        public async Task <ActionResult <ObjectSettingEntry[]> > GetGlobalModuleSettingsAsync(string id)
        {
            var criteria = new SettingsSearchCriteria
            {
                ModuleId = id,
                Take     = int.MaxValue
            };
            var result = await _settingsSearchService.SearchSettingsAsync(criteria);

            return(Ok(result.Results));
        }
Пример #2
0
        public async Task<GenericSearchResult<ObjectSettingEntry>> SearchSettingsAsync(SettingsSearchCriteria criteria)
        {
            var result = new GenericSearchResult<ObjectSettingEntry>();

            var query = _settingsManager.AllRegisteredSettings.AsQueryable();

            if (!string.IsNullOrEmpty(criteria.ModuleId))
            {
                query = query.Where(x => x.ModuleId == criteria.ModuleId);
            }

            var sortInfos = criteria.SortInfos;
            if (sortInfos.IsNullOrEmpty())
            {
                sortInfos = new[] { new SortInfo { SortColumn = "Name" } };
            }
            query = query.OrderBySortInfos(sortInfos);
            result.TotalCount = query.Count();
            var names = query.Skip(criteria.Skip).Take(criteria.Take).Select(x => x.Name).ToList();

            var settings = await _settingsManager.GetObjectSettingsAsync(names.ToArray());
            result.Results = settings.OrderBy(x => names.IndexOf(x.Name))
                                       .ToList();
            return result;
        }