Exemple #1
0
        public async Task <DocumentUpdateResultDto> UpdateAsync(ConfigurationSettingDto configurationSettingDto)
        {
            await ValidateConfigurationSettingAsync(configurationSettingDto);

            var configuration = await GetConfigurationSettingAsync(configurationSettingDto.Id);

            AssignConfigurationDtoToEntity(configuration, configurationSettingDto);
            return(await _dataContext.ReplaceDocumentAsync(configuration));
        }
        public async Task <DocumentUpdateResultDto> UpdateAsync(LocalisationTextDto localisationTextDto)
        {
            await CheckForDuplicates(localisationTextDto);

            var localisation = await GetLocalisationTextAsync(localisationTextDto.Id);

            AssignLocalisationDtoToEntity(localisation, localisationTextDto);
            return(await _dataContext.ReplaceDocumentAsync(localisation));
        }
        public async Task <DocumentUpdateResultDto> UpdateAsync(AlertTemplateDto dto)
        {
            ValidateDto(dto);
            await CheckForDuplicatesAsync(dto);

            var localisation = await GetAlertTemplateAsync(dto.Id);

            AssignDtoToEntity(localisation, dto);
            return(await _dataContext.ReplaceDocumentAsync(localisation));
        }
        public async Task DeleteAsync(params string[] ids)
        {
            var roleUpdateMessageDto = new RoleUpdateMessageDto {
                Roles = new List <string>()
            };

            var permissionConfigs = await _dataContext.GetDocumentsAsync <PermissionConfig, PermissionConfig>(q => q.Where(pc => ids.Contains(pc.Id)));

            foreach (var permissionConfig in permissionConfigs)
            {
                if (permissionConfig != null && !permissionConfig.IsDeleted)
                {
                    permissionConfig.IsDeleted = true;
                    await _dataContext.ReplaceDocumentAsync(permissionConfig);

                    if (permissionConfig.GroupId != "*" && permissionConfig.Permissions.Any(p => p.StartsWith("DEV_CAB")))
                    {
                        roleUpdateMessageDto.GroupId = permissionConfig.GroupId;

                        if (permissionConfig.Role == "*")
                        {
                            roleUpdateMessageDto.Roles.Clear();
                            roleUpdateMessageDto.Roles.AddRange(await GetRolesForGroup());
                        }
                        else if (!roleUpdateMessageDto.Roles.Contains(permissionConfig.Role))
                        {
                            roleUpdateMessageDto.Roles.Add(permissionConfig.Role);
                        }
                    }
                }
            }

            if (roleUpdateMessageDto.Roles.Any())
            {
                await _platformServiceBusService.TriggerPodAccessDefinitionGenerationAsync(roleUpdateMessageDto);
            }
        }
        public async Task <DocumentUpdateResultDto> UpdateAsync(LookupDto dto)
        {
            var lookup = await _dataContext.GetDocumentAsync <Lookup>(dto.Id);

            await CheckForDuplicates(dto.GroupId, dto.Culture, dto.Section, dto.Key, dto.Id);

            if (dto.Items != null)
            {
                CheckForCircularReference(dto.Key, dto.Items);
            }

            lookup.Culture      = dto.Culture;
            lookup.Section      = dto.Section;
            lookup.Key          = dto.Key;
            lookup.IncludeInPod = dto.IncludeInPod;
            lookup.Priority     = ConfigurationHelper.GetConfigurationPriority(dto.GroupId, dto.Culture, dto.Section);
            lookup.Items        = CreateLookupItems(dto.Items);
            lookup.ETag         = dto.ETag;

            var result = await _dataContext.ReplaceDocumentAsync(lookup);

            return(result);
        }