Example #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());
        }
Example #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);
        }
Example #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,
     });
 }
Example #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;
 }
Example #7
0
 // TODO: This is not a good mapping
 public static ApiResourceScopeModel ToModel(this ApiResourceScope scope)
 {
     return(Mapper.Map <ApiResourceScopeModel>(scope));
 }
Example #8
0
 public async Task <bool> DeleteApiResourceScopeAsync(ApiResourceScope apiResourceScope)
 {
     return(await _repository.DeleteAsync(apiResourceScope));
 }
Example #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));
 }