using adas_core.Domain.Models.MongoModels;
using MongoDB.Bson;

namespace adas_core.Application.Repositories.Interfaces;

public interface IAuthorityRepository : IMongoRepository<Authorization>
{
    /// <summary>
    /// Retrieves an <see cref="Authorization"/> entity by its unique identifier asynchronously.
    /// </summary>
    /// <param name="authId">The unique identifier of the authorization to retrieve.</param>
    /// <returns>A task that represents the asynchronous operation, containing the <see cref="Authorization"/> that matches the specified identifier.</returns>
    public Task<Authorization> GetById(ObjectId authId);
    /// <summary>
    /// Creates a new authority assignment for the specified user with the given role name.
    /// </summary>
    /// <param name="roleName">The name of the role to assign as the new authority.</param>
    /// <param name="userId">The identifier of the user to whom the authority will be assigned.</param>
    void CreateNewAuthority(string roleName, ObjectId userId);
    /// <summary>
    /// Retrieves the list of authorizations (authorities/permissions) associated with the specified user.
    /// </summary>
    /// <param name="userId">The unique identifier of the user whose authorities are being requested.</param>
    /// <returns>A task that represents the asynchronous operation. The task result contains the list of <see cref="Authorization"/> entries assigned to the user.</returns>
    public Task<List<Authorization>> GetUserAuthorities(ObjectId userId);
    /// <summary>
    /// Asynchronously retrieves all available authorizations.
    /// </summary>
    /// <returns>A task that represents the asynchronous operation. The task result contains a list of all <see cref="Authorization"/> objects.</returns>
    public Task<List<Authorization>> GetAllAuthorities();
    /// <summary>
    /// Asynchronously deletes all authorities associated with the specified user.
    /// </summary>
    /// <param name="userId">The unique identifier of the user whose authorities will be removed.</param>
    /// <returns>A task that represents the asynchronous operation. The task result is <c>true</c> if authorities were deleted; otherwise, <c>false</c>.</returns>
    public Task<bool> DeleteAllAuthoritiesByUser(ObjectId userId);
    /// <summary>
    /// Deletes all authorities associated with the specified unit.
    /// </summary>
    /// <param name="unitId">The unique identifier of the unit whose authorities should be removed.</param>
    /// <returns>A task that resolves to <c>true</c> if the authorities were successfully deleted; otherwise, <c>false</c>.</returns>
    Task<bool> DeleteAllAuthoritiesByUnit(ObjectId unitId);
    /// <summary>
    /// Deletes all authorities associated with the specified display identifier.
    /// </summary>
    /// <param name="displayId">The identifier of the display whose related authorities should be removed.</param>
    /// <returns>A task that resolves to a boolean indicating the outcome of the deletion operation.</returns>
    Task<bool> DeleteAllAuthoritiesByDisplay(ObjectId displayId);
    /// <summary>
    /// Retrieves a list of authorizations associated with the specified unit identifier.
    /// </summary>
    /// <param name="unitId">The unique identifier of the unit whose authorizations are being requested.</param>
    /// <returns>A task that represents the asynchronous operation, containing a list of <see cref="Authorization"/> objects matching the provided unit identifier.</returns>
    Task<List<Authorization>> GetByUnitId(ObjectId unitId);
}