# Interface IUserRepository

Namespace
  adas_core.Application.Repositories.Interfaces

Assembly
  adas-core.Application.dll

    public interface IUserRepository : IMongoRepository<User>

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

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

## Methods

### GetById(ObjectId)

Retrieves a user by their unique identifier asynchronously.

    Task<User?> GetById(ObjectId id)

#### Parameters

`id` ObjectId

  The unique identifier of the user to retrieve.

#### Returns

Task<User>

  A task that represents the asynchronous operation. The task result contains the User if found; otherwise, null.

### GetByName(string)

Asynchronously retrieves a user by their name, returning null if no matching user is found.

    Task<User?> GetByName(string name)

#### Parameters

`name` string

  The name of the user to look up.

#### Returns

Task<User>

  A task that represents the asynchronous operation. The task result contains the user with the specified name, or null if no matching user exists.

### GetByUserAndAuthoritesName(string)

Asynchronously retrieves the user associated with the specified authorities name.

    Task<User?> GetByUserAndAuthoritesName(string name)

#### Parameters

`name` string

  The authorities name used to look up the user.

#### Returns

Task<User>

  A task that represents the asynchronous operation. The task result contains the matching User if found; otherwise, `null`.

### GetByUserName(string)

Asynchronously retrieves a user matching the specified username. Returns `null` if no user is found.

    Task<User?> GetByUserName(string name)

#### Parameters

`name` string

  The username to look up.

#### Returns

Task<User>

  A task that represents the asynchronous operation, containing the matching User or `null` if not found.

### GetOrCreateSystemUser()

Retrieves the existing system user, creating a new one if it does not already exist.

    Task<User> GetOrCreateSystemUser()

#### Returns

Task<User>

  The existing or newly created system User.

### GetPaginatedUsers(PaginationFilter)

Retrieves a paginated, fluent queryable collection of User entities based on the supplied pagination filter.

    IFindFluent<User, User> GetPaginatedUsers(PaginationFilter filter)

#### Parameters

`filter` PaginationFilter

  The pagination filter that defines paging parameters such as page number and page size.

#### Returns

IFindFluent<User, User>

  An MongoDB.Driver.IFindFluent<TDocument, TProjection> representing the queryable, paginated user results.

### GetUser(string, string)

Asynchronously retrieves a user by validating the provided username and password credentials. Returns the matching user when authentication succeeds, or null if no user matches the supplied credentials.

    Task<User?> GetUser(string username, string password)

#### Parameters

`username` string

  The username used to look up the user account.

`password` string

  The password used to authenticate the user.

#### Returns

Task<User>

  A task that resolves to the authenticated User, or null if no user matches the provided credentials.

### UpdateUser(User, bool)

Updates an existing user in the system, optionally updating the user's password when the `updatePass` flag is set.

    Task<User?> UpdateUser(User user, bool updatePass)

#### Parameters

`user` User

  The user entity containing the updated information to be persisted.

`updatePass` bool

  A flag indicating whether the user's password should also be updated as part of this operation.

#### Returns

Task<User>

  A task that returns the updated User entity, or `null` if the user was not found.