# Interface IAuthorityService

Namespace
  adas_core.Authentication.Interfaces

Assembly
  adas-core.Authentication.dll

    public interface IAuthorityService

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

## Methods

### CreateNew(string, ObjectId)

Creates a new role with the specified name and associates it with the given user.

    void CreateNew(string roleName, ObjectId userId)

#### Parameters

`roleName` string

  The name of the role to create.

`userId` ObjectId

  The identifier of the user to associate with the new role.

### CreateNewUserAuthority(Authorization)

Creates a new user authority based on the provided `authorization`.

    Task<Authorization?> CreateNewUserAuthority(Authorization authorization)

#### Parameters

`authorization` Authorization

  The authorization data used to create the new user authority.

#### Returns

Task<Authorization>

  A task that represents the asynchronous operation. The task result contains the created Authorization, or `null` if the authority could not be created.

### DeleteAuthoritiesForUser(ObjectId)

Deletes all authorities associated with the user identified by the specified id.

    Task<bool> DeleteAuthoritiesForUser(ObjectId id)

#### Parameters

`id` ObjectId

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

#### Returns

Task<bool>

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

### DeleteUserAuthority(ObjectId)

Asynchronously deletes a user authority identified by the provided parsed identifier.

    Task<bool> DeleteUserAuthority(ObjectId userAuthorityIdParsed)

#### Parameters

`userAuthorityIdParsed` ObjectId

  The parsed identifier of the user authority to delete.

#### Returns

Task<bool>

  A task that represents the asynchronous delete operation. The task result is true if the user authority was successfully deleted; otherwise, false.

### EditUserAuthority(Authorization)

Edits the user authority using the provided authorization data.

    Task<Authorization?> EditUserAuthority(Authorization authorization)

#### Parameters

`authorization` Authorization

  The authorization object containing the user authority details to be updated.

#### Returns

Task<Authorization>

  A task that represents the asynchronous operation. The task result contains the updated Authorization, or `null` if the authorization was not found.

### GetAllAuthorities()

Asynchronously retrieves all 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.

### GetUserAuthorities(ObjectId)

Asynchronously retrieves the list of authorizations associated with the specified user.

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

#### Parameters

`userId` ObjectId

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

#### Returns

Task<List<Authorization>>

  A task that represents the asynchronous operation, containing a list of Authorization objects for the user.

### InsertOne(Authorization)

Inserts a new authorization record into the data store.

    Task InsertOne(Authorization authorization)

#### Parameters

`authorization` Authorization

  The authorization entity to insert.

#### Returns

Task

  A task that represents the asynchronous insert operation.

### updateOne(Authorization)

Updates a single authorization record.

    Task updateOne(Authorization authorization)

#### Parameters

`authorization` Authorization

  The authorization object containing the data to be updated.

#### Returns

Task