示例#1
0
        private async Task BuildApiScopePropertiesViewModelAsync(ApiScopePropertiesDto apiScopeProperties)
        {
            var apiResourcePropertiesDto = await GetApiScopePropertiesAsync(apiScopeProperties.ApiScopeId);

            apiScopeProperties.ApiScopeProperties.AddRange(apiResourcePropertiesDto.ApiScopeProperties);
            apiScopeProperties.TotalCount = apiResourcePropertiesDto.TotalCount;
        }
        public async Task <IActionResult> ApiScopePropertyDelete(ApiScopePropertiesDto apiScopeProperty)
        {
            await _apiScopeService.DeleteApiScopePropertyAsync(apiScopeProperty);

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

            return(RedirectToAction(nameof(ApiScopeProperties), new { Id = apiScopeProperty.ApiScopeId }));
        }
示例#3
0
        public virtual async Task <int> DeleteApiScopePropertyAsync(ApiScopePropertiesDto apiScopeProperty)
        {
            var propertyEntity = apiScopeProperty.ToEntity();

            var deleted = await ApiScopeRepository.DeleteApiScopePropertyAsync(propertyEntity);

            await AuditEventLogger.LogEventAsync(new ApiScopePropertyDeletedEvent(apiScopeProperty));

            return(deleted);
        }
        public async Task <IActionResult> ApiScopeProperties(ApiScopePropertiesDto apiScopeProperty)
        {
            if (!ModelState.IsValid)
            {
                return(View(apiScopeProperty));
            }

            await _apiScopeService.AddApiScopePropertyAsync(apiScopeProperty);

            SuccessNotification(string.Format(_localizer["SuccessAddApiScopeProperty"], apiScopeProperty.Key, apiScopeProperty.ApiScopeName), _localizer["SuccessTitle"]);

            return(RedirectToAction(nameof(ApiScopeProperties), new { Id = apiScopeProperty.ApiScopeId }));
        }
示例#5
0
        public virtual async Task <int> AddApiScopePropertyAsync(ApiScopePropertiesDto apiScopeProperties)
        {
            var canInsert = await CanInsertApiScopePropertyAsync(apiScopeProperties);

            if (!canInsert)
            {
                await BuildApiScopePropertiesViewModelAsync(apiScopeProperties);

                throw new UserFriendlyViewException(string.Format(ApiScopeServiceResources.ApiScopePropertyExistsValue().Description, apiScopeProperties.Key), ApiScopeServiceResources.ApiScopePropertyExistsKey().Description, apiScopeProperties);
            }

            var apiScopeProperty = apiScopeProperties.ToEntity();

            var saved = await ApiScopeRepository.AddApiScopePropertyAsync(apiScopeProperties.ApiScopeId, apiScopeProperty);

            await AuditEventLogger.LogEventAsync(new ApiScopePropertyAddedEvent(apiScopeProperties));

            return(saved);
        }
示例#6
0
 public static ApiScopeProperty ToEntity(this ApiScopePropertiesDto resource)
 {
     return(resource == null ? null : Mapper.Map <ApiScopeProperty>(resource));
 }
示例#7
0
 public ApiScopePropertiesRequestedEvent(int apiScopeId, ApiScopePropertiesDto apiScopeProperties)
 {
     ApiScopeId            = apiScopeId;
     ApiResourceProperties = apiScopeProperties;
 }
示例#8
0
 public ApiScopePropertyAddedEvent(ApiScopePropertiesDto apiScopeProperty)
 {
     ApiScopeProperty = apiScopeProperty;
 }
示例#9
0
 public ApiScopePropertyRequestedEvent(int apiScopePropertyId, ApiScopePropertiesDto apiScopeProperty)
 {
     ApiScopePropertyId = apiScopePropertyId;
     ApiScopeProperty   = apiScopeProperty;
 }
示例#10
0
        public virtual async Task <bool> CanInsertApiScopePropertyAsync(ApiScopePropertiesDto apiResourceProperty)
        {
            var resource = apiResourceProperty.ToEntity();

            return(await ApiScopeRepository.CanInsertApiScopePropertyAsync(resource));
        }
 public ApiScopePropertyDeletedEvent(ApiScopePropertiesDto apiScopeProperty)
 {
     ApiScopeProperty = apiScopeProperty;
 }