public async Task <Scope> UpdateAsync(Scope updatedScope) { var scope = await _scopeRepository.FindAsync(updatedScope.ScopeId); if (scope == null) { throw new BadRequestException("Scope does not exist."); } return(await UpdateAsync(scope, updatedScope)); }
public async Task <Scope> FindAsync(Guid scopeId) { var scope = await _scopeRepository.FindAsync(scopeId); if (scope == null) { throw new NotFoundException(); } return(scope); }
private async Task <List <Scope> > AddScopeRelationAsync(Role role, Guid scopeId) { if (!role.Scopes.Any(s => s.ScopeId == scopeId)) { var scope = await _scopeRepository.FindAsync(scopeId); if (scope == null) { throw new NotFoundException(); } role.Scopes.Add(scope); await _roleRepository.SaveAsync(); } return(role.Scopes.ToList()); }
private async Task <List <Scope> > DeleteScopeRelationAsync(Role role, Guid scopeId) { if (role.Scopes.Any(s => s.ScopeId == scopeId)) { var scope = await _scopeRepository.FindAsync(scopeId); if (scope == null) { throw new BadRequestException("Scope not found."); } role.Scopes.Remove(scope); await _roleRepository.SaveAsync(); } return(role.Scopes.ToList()); }
public async Task DeleteAsync(Guid scopeId) { var scope = await _scopeRepository.FindAsync(scopeId); await DeleteAsync(scope); }