public virtual async Task <bool> CanInsertApiScopePropertyAsync(ApiScopeProperty apiScopeProperty)
        {
            var existsWithSameName = await DbContext.ApiScopeProperties.Where(x => x.Key == apiScopeProperty.Key &&
                                                                              x.Scope.Id == apiScopeProperty.Scope.Id).SingleOrDefaultAsync();

            return(existsWithSameName == null);
        }
        public virtual async Task <int> DeleteApiScopePropertyAsync(ApiScopeProperty apiScopeProperty)
        {
            var propertyToDelete = await DbContext.ApiScopeProperties.Where(x => x.Id == apiScopeProperty.Id).SingleOrDefaultAsync();

            DbContext.ApiScopeProperties.Remove(propertyToDelete);

            return(await AutoSaveChangesAsync());
        }
        public virtual async Task <int> AddApiScopePropertyAsync(int apiScopeId, ApiScopeProperty apiScopeProperty)
        {
            var apiScope = await DbContext.ApiScopes.Where(x => x.Id == apiScopeId).SingleOrDefaultAsync();

            apiScopeProperty.Scope = apiScope;
            await DbContext.ApiScopeProperties.AddAsync(apiScopeProperty);

            return(await AutoSaveChangesAsync());
        }
예제 #4
0
 public static ApiScopePropertiesDto ToModel(this ApiScopeProperty scope)
 {
     return(scope == null ? null : Mapper.Map <ApiScopePropertiesDto>(scope));
 }