# Interface IAuthorityRepository

Namespace
  adas_core.Application.Repositories.Interfaces

Assembly
  adas-core.Application.dll

    public interface IAuthorityRepository : IMongoRepository<Authorization>

Inherited Members
  IMongoRepository<Authorization>.Collection
  IMongoRepository<Authorization>.GetCollectionName()
  IMongoRepository<Authorization>.InsertOneAsync(Authorization)
  IMongoRepository<Authorization>.DeleteAsync(ObjectId)
  IMongoRepository<Authorization>.UpdateOneAsync(ObjectId, Authorization)

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Methods

### CreateNewAuthority(string, ObjectId)

Creates a new authority assignment for the specified user with the given role name.

    void CreateNewAuthority(string roleName, ObjectId userId)

#### Parameters

`roleName` string

  The name of the role to assign as the new authority.

`userId` ObjectId

  The identifier of the user to whom the authority will be assigned.

### DeleteAllAuthoritiesByDisplay(ObjectId)

Deletes all authorities associated with the specified display identifier.

    Task<bool> DeleteAllAuthoritiesByDisplay(ObjectId displayId)

#### Parameters

`displayId` ObjectId

  The identifier of the display whose related authorities should be removed.

#### Returns

Task<bool>

  A task that resolves to a boolean indicating the outcome of the deletion operation.

### DeleteAllAuthoritiesByUnit(ObjectId)

Deletes all authorities associated with the specified unit.

    Task<bool> DeleteAllAuthoritiesByUnit(ObjectId unitId)

#### Parameters

`unitId` ObjectId

  The unique identifier of the unit whose authorities should be removed.

#### Returns

Task<bool>

  A task that resolves to `true` if the authorities were successfully deleted; otherwise, `false`.

### DeleteAllAuthoritiesByUser(ObjectId)

Asynchronously deletes all authorities associated with the specified user.

    Task<bool> DeleteAllAuthoritiesByUser(ObjectId userId)

#### Parameters

`userId` ObjectId

  The unique identifier of the user whose authorities will be removed.

#### Returns

Task<bool>

  A task that represents the asynchronous operation. The task result is `true` if authorities were deleted; otherwise, `false`.

### GetAllAuthorities()

Asynchronously retrieves all available authorizations.

    Task<List<Authorization>> GetAllAuthorities()

#### Returns

Task<List<Authorization>>

  A task that represents the asynchronous operation. The task result contains a list of all Authorization objects.

### GetById(ObjectId)

Retrieves an Authorization entity by its unique identifier asynchronously.

    Task<Authorization> GetById(ObjectId authId)

#### Parameters

`authId` ObjectId

  The unique identifier of the authorization to retrieve.

#### Returns

Task<Authorization>

  A task that represents the asynchronous operation, containing the Authorization that matches the specified identifier.

### GetByUnitId(ObjectId)

Retrieves a list of authorizations associated with the specified unit identifier.

    Task<List<Authorization>> GetByUnitId(ObjectId unitId)

#### Parameters

`unitId` ObjectId

  The unique identifier of the unit whose authorizations are being requested.

#### Returns

Task<List<Authorization>>

  A task that represents the asynchronous operation, containing a list of Authorization objects matching the provided unit identifier.

### GetUserAuthorities(ObjectId)

Retrieves the list of authorizations (authorities/permissions) associated with the specified user.

    Task<List<Authorization>> GetUserAuthorities(ObjectId userId)

#### Parameters

`userId` ObjectId

  The unique identifier of the user whose authorities are being requested.

#### Returns

Task<List<Authorization>>

  A task that represents the asynchronous operation. The task result contains the list of Authorization entries assigned to the user.