Ejemplo n.º 1
0
        public virtual async Task <int> DeleteApiResourceScopeAsync(ApiResourceScope apiResourceScope)
        {
            var resourceScopeToDelete = await DbContext.ApiResourceScopes.SingleOrDefaultAsync(x => x.Id == apiResourceScope.Id);

            DbContext.ApiResourceScopes.Remove(resourceScopeToDelete);
            return(await AutoSaveChangesAsync());
        }
Ejemplo n.º 2
0
        public virtual async Task <bool> CanInsertApiResourceScopeAsync(ApiResourceScope apiResourceScope)
        {
            var existsWithSameName = await DbContext.ApiResourceScopes
                                     .SingleOrDefaultAsync(x => x.Scope.Equals(apiResourceScope.Scope) && x.ApiResource.Id == apiResourceScope.ApiResourceId);

            return(existsWithSameName == null);
        }
Ejemplo n.º 3
0
    public virtual ApiResourceScope AddScope([NotNull] string scope)
    {
        var apiResourceScope = new ApiResourceScope(Id, scope);

        Scopes.Add(apiResourceScope);
        return(apiResourceScope);
    }
 public static ScopeModel FromEntity(ApiResourceScope apiScope)
 {
     return(new ScopeModel
     {
         Id = apiScope.Id,
         Scope = apiScope.Scope,
         ApiResourceId = apiScope.ApiResourceId,
         ApiResourceName = apiScope.ApiResource.Name,
         ApiResource = apiScope.ApiResource,
     });
 }
Ejemplo n.º 5
0
        public virtual async Task <int> AddApiResourceScopeAsync(int apiResourceId, ApiScope apiScope)
        {
            DbContext.ApiScopes.Add(apiScope);

            var apiResourceScope = new ApiResourceScope()
            {
                Id            = apiScope.Id,
                Scope         = apiScope.Name,
                ApiResourceId = apiResourceId
            };

            DbContext.ApiResourceScopes.Add(apiResourceScope);

            await AutoSaveChangesAsync();

            return(apiScope.Id);
        }
 public void UpdateEntity(ApiResourceScope entity)
 {
     entity.Scope = Scope;
 }
Ejemplo n.º 7
0
 // TODO: This is not a good mapping
 public static ApiResourceScopeModel ToModel(this ApiResourceScope scope)
 {
     return(Mapper.Map <ApiResourceScopeModel>(scope));
 }
Ejemplo n.º 8
0
 public async Task <bool> DeleteApiResourceScopeAsync(ApiResourceScope apiResourceScope)
 {
     return(await _repository.DeleteAsync(apiResourceScope));
 }
Ejemplo n.º 9
0
 public async Task <int> InsertApiResourceScopeAsync(ApiResourceScope apiResourceScope)
 {
     return(await _repository.InsertAsync(apiResourceScope));
 }
 public static ApiResourceScopeDto ToModel(this ApiResourceScope resource)
 {
     return(resource == null ? null : Mapper.Map <ApiResourceScopeDto>(resource));
 }