Beispiel #1
0
        public async Task <string> GetOrganizationSettingByNameAsync(string name)
        {
            var org = await _currentOrganizationAccessorService.GetCurrentOrganizationAsync();

            if (org == null)
            {
                return(null);
            }

            var settings = await _organizationSettingsCache.GetAllSettingsForOrganizationAsync(org.OrganizationId);

            return(settings.FirstOrDefault(s => s.Name == name)?.Value);
        }
        public async Task <OrganizationSettingDto[]> List(int organizationId, CancellationToken cancellationToken)
        {
            await _organizationRetrievalService
            .GetOrganizationByIdAsync(organizationId,
                                      cancellationToken : cancellationToken); // to check for org existence

            var settings = await _organizationSettingsCache
                           .GetAllSettingsForOrganizationAsync(organizationId);

            var values = settings.ToDictionary(
                s => s.Name,
                s => s.Value);

            return(_organizationSettingsRegistry.GetEntries()
                   .OrderBy(e => e.Section)
                   .ThenBy(e => e.Name)
                   .Select(e => new OrganizationSettingDto(e)
            {
                Value = values.ContainsKey(e.Name) ? values[e.Name] : null
            }).ToArray());
        }