Пример #1
0
        public async Task <IActionResult> ApiResourcePropertyDelete(ApiResourcePropertiesDto apiResourceProperty)
        {
            await _apiResourceService.DeleteApiResourcePropertyAsync(apiResourceProperty);


            return(Success(new { Id = apiResourceProperty.ApiResourceId }));
        }
Пример #2
0
        private async Task BuildApiResourcePropertiesViewModelAsync(ApiResourcePropertiesDto apiResourceProperties)
        {
            var apiResourcePropertiesDto = await GetApiResourcePropertiesAsync(apiResourceProperties.ApiResourceId);

            apiResourceProperties.ApiResourceProperties.AddRange(apiResourcePropertiesDto.ApiResourceProperties);
            apiResourceProperties.TotalCount = apiResourcePropertiesDto.TotalCount;
        }
        public async Task <IActionResult> ApiResourcePropertyDelete(ApiResourcePropertiesDto apiResourceProperty)
        {
            await _apiResourceService.DeleteApiResourcePropertyAsync(apiResourceProperty);

            SuccessNotification(_localizer["SuccessDeleteApiResourceProperty"], _localizer["SuccessTitle"]);

            return(RedirectToAction(nameof(ApiResourceProperties), new { Id = apiResourceProperty.ApiResourceId }));
        }
        public virtual async Task <int> DeleteApiResourcePropertyAsync(ApiResourcePropertiesDto apiResourceProperty)
        {
            var propertyEntity = apiResourceProperty.ToEntity();

            var deleted = await ApiResourceRepository.DeleteApiResourcePropertyAsync(propertyEntity);

            return(deleted);
        }
Пример #5
0
        public virtual async Task <int> DeleteApiResourcePropertyAsync(ApiResourcePropertiesDto apiResourceProperty)
        {
            var propertyEntity = apiResourceProperty.ToEntity();

            var deleted = await ApiResourceRepository.DeleteApiResourcePropertyAsync(propertyEntity);

            await AuditEventLogger.LogEventAsync(new ApiResourcePropertyDeletedEvent(apiResourceProperty));

            return(deleted);
        }
        public async Task <IActionResult> DeleteProperty(int propertyId)
        {
            var apiResourceProperty = new ApiResourcePropertiesDto {
                ApiResourcePropertyId = propertyId
            };

            await _apiResourceService.GetApiResourcePropertyAsync(apiResourceProperty.ApiResourcePropertyId);

            await _apiResourceService.DeleteApiResourcePropertyAsync(apiResourceProperty);

            return(Ok());
        }
Пример #7
0
        public async Task <IActionResult> ApiResourceProperties(ApiResourcePropertiesDto apiResourceProperty)
        {
            if (!ModelState.IsValid)
            {
                return(Success(apiResourceProperty));
            }

            await _apiResourceService.AddApiResourcePropertyAsync(apiResourceProperty);


            return(Success(new { Id = apiResourceProperty.ApiResourceId }));
        }
        public async Task <IActionResult> ApiResourceProperties(ApiResourcePropertiesDto apiResourceProperty)
        {
            if (!ModelState.IsValid)
            {
                return(View(apiResourceProperty));
            }

            await _apiResourceService.AddApiResourcePropertyAsync(apiResourceProperty);

            SuccessNotification(string.Format(_localizer["SuccessAddApiResourceProperty"], apiResourceProperty.Key, apiResourceProperty.ApiResourceName), _localizer["SuccessTitle"]);

            return(RedirectToAction(nameof(ApiResourceProperties), new { Id = apiResourceProperty.ApiResourceId }));
        }
        public virtual async Task <int> AddApiResourcePropertyAsync(ApiResourcePropertiesDto apiResourceProperties)
        {
            var canInsert = await CanInsertApiResourcePropertyAsync(apiResourceProperties);

            if (!canInsert)
            {
                await BuildApiResourcePropertiesViewModelAsync(apiResourceProperties);

                throw new UserFriendlyViewException(string.Format(ApiResourceServiceResources.ApiResourcePropertyExistsValue().Description, apiResourceProperties.Key), ApiResourceServiceResources.ApiResourcePropertyExistsKey().Description, apiResourceProperties);
            }

            var apiResourceProperty = apiResourceProperties.ToEntity();

            return(await ApiResourceRepository.AddApiResourcePropertyAsync(apiResourceProperties.ApiResourceId, apiResourceProperty));
        }
Пример #10
0
 public ApiResourcePropertyDeletedEvent(ApiResourcePropertiesDto apiResourceProperty)
 {
     ApiResourceProperty = apiResourceProperty;
 }
Пример #11
0
        public virtual async Task <bool> CanInsertApiResourcePropertyAsync(ApiResourcePropertiesDto apiResourceProperty)
        {
            var resource = apiResourceProperty.ToEntity();

            return(await ApiResourceRepository.CanInsertApiResourcePropertyAsync(resource));
        }
 public ApiResourcePropertyRequestedEvent(int apiResourcePropertyId, ApiResourcePropertiesDto apiResourceProperties)
 {
     ApiResourcePropertyId = apiResourcePropertyId;
     ApiResourceProperties = apiResourceProperties;
 }
 public static ApiResourceProperty ToEntity(this ApiResourcePropertiesDto apiResourceProperties)
 {
     return(Mapper.Map <ApiResourceProperty>(apiResourceProperties));
 }
Пример #14
0
        public async Task <IActionResult> SaveApiResource([FromBody] ApiResourceRegistryDto api)
        {
            ApiResourcesDto targ = await _apiResourceService.GetApiResourcesAsync(api.Name, 1, 1);

            ApiResourceDto apiDto = ToApiResourceDto(api);
            int            apiId;

            if (targ.ApiResources.Count == 0)
            {
                apiId = await _apiResourceService.AddApiResourceAsync(apiDto);
            }
            else
            {
                apiId     = targ.ApiResources[0].Id;
                apiDto.Id = apiId;
                await _apiResourceService.UpdateApiResourceAsync(apiDto);
            }

            ApiScopesDto scopesInDb = await _apiResourceService.GetApiScopesAsync(apiId, 1, int.MaxValue);

            foreach (var sitem in api.Scopes)
            {
                if (scopesInDb.Scopes.Any(x => x.Name == sitem.Name))
                {
                    continue;
                }

                await _apiResourceService.AddApiScopeAsync(new ApiScopesDto()
                {
                    ApiResourceId           = apiId,
                    Description             = sitem.Description,
                    DisplayName             = sitem.DisplayName,
                    Emphasize               = sitem.Emphasize,
                    Name                    = sitem.Name,
                    Required                = sitem.Required,
                    ShowInDiscoveryDocument = sitem.ShowInDiscoveryDocument,
                    UserClaims              = sitem.UserClaims,
                });
            }

            foreach (var sitem in scopesInDb.Scopes)
            {
                if (api.Scopes.Any(x => x.Name == sitem.Name))
                {
                    continue;
                }

                var apiScope = new ApiScopesDto {
                    ApiResourceId = apiId, ApiScopeId = sitem.Id
                };
                await _apiResourceService.DeleteApiScopeAsync(apiScope);
            }

            ApiResourcePropertiesDto propertiesDto = await _apiResourceService.GetApiResourcePropertiesAsync(apiId, 1, int.MaxValue);

            ApiResourcePropertiesDto[] todele = propertiesDto.ApiResourceProperties.Where(x => api.Properties.ContainsKey(x.Key))
                                                .Select(x => new ApiResourcePropertiesDto()
            {
                ApiResourceId         = apiId,
                ApiResourcePropertyId = x.Id,
                Key   = x.Key,
                Value = x.Value
            }).ToArray();

            foreach (var prop in todele)
            {
                await _apiResourceService.DeleteApiResourcePropertyAsync(prop);
            }

            foreach (var item in api.Properties)
            {
                await _apiResourceService.AddApiResourcePropertyAsync(new ApiResourcePropertiesDto
                {
                    ApiResourceId = apiId,
                    Key           = item.Key,
                    Value         = item.Value
                });
            }

            return(Ok());
        }
        public async Task <int> DeleteApiResourcePropertyAsync(ApiResourcePropertiesDto apiResourceProperty)
        {
            var propertyEntity = apiResourceProperty.ToEntity();

            return(await _apiResourceRepository.DeleteApiResourcePropertyAsync(propertyEntity));
        }