62 lines
3.7 KiB
C#
62 lines
3.7 KiB
C#
using adas_core.Domain.Models.MongoModels;
|
|
using MongoDB.Bson;
|
|
|
|
namespace adas_core.Authentication.Interfaces;
|
|
|
|
public interface IAuthorityService
|
|
{
|
|
/// <summary>
|
|
/// Asynchronously retrieves the list of authorizations associated with the specified user.
|
|
/// </summary>
|
|
/// <param name="userId">The unique identifier of the user whose authorizations are being requested.</param>
|
|
/// <returns>A task that represents the asynchronous operation, containing a list of <see cref="Authorization"/> objects for the user.</returns>
|
|
public Task<List<Authorization>> GetUserAuthorities(ObjectId userId);
|
|
/// <summary>
|
|
/// Creates a new role with the specified name and associates it with the given user.
|
|
/// </summary>
|
|
/// <param name="roleName">The name of the role to create.</param>
|
|
/// <param name="userId">The identifier of the user to associate with the new role.</param>
|
|
public void CreateNew(string roleName, ObjectId userId);
|
|
/// <summary>
|
|
/// Inserts a new authorization record into the data store.
|
|
/// </summary>
|
|
/// <param name="authorization">The authorization entity to insert.</param>
|
|
/// <returns>A task that represents the asynchronous insert operation.</returns>
|
|
public Task InsertOne(Authorization authorization);
|
|
/// <summary>
|
|
/// Updates a single authorization record.
|
|
/// </summary>
|
|
/// <param name="authorization">The authorization object containing the data to be updated.</param>
|
|
public Task updateOne(Authorization authorization);
|
|
|
|
/// <summary>
|
|
/// Asynchronously retrieves all authorizations.
|
|
/// </summary>
|
|
/// <returns>A task that represents the asynchronous operation. The task result contains a list of all authorization objects.</returns>
|
|
public Task<List<Authorization>> GetAllAuthorities();
|
|
|
|
/// <summary>
|
|
/// Deletes all authorities associated with the user identified by the specified id.
|
|
/// </summary>
|
|
/// <param name="id">The unique identifier of the user whose authorities should be removed.</param>
|
|
/// <returns>A task that represents the asynchronous operation. The task result contains <c>true</c> if authorities were deleted; otherwise, <c>false</c>.</returns>
|
|
Task<bool> DeleteAuthoritiesForUser(ObjectId id);
|
|
/// <summary>
|
|
/// Creates a new user authority based on the provided <paramref name="authorization"/>.
|
|
/// </summary>
|
|
/// <param name="authorization">The authorization data used to create the new user authority.</param>
|
|
/// <returns>A task that represents the asynchronous operation. The task result contains the created <see cref="Authorization"/>, or <c>null</c> if the authority could not be created.</returns>
|
|
Task<Authorization?> CreateNewUserAuthority(Authorization authorization);
|
|
/// <summary>
|
|
/// Asynchronously deletes a user authority identified by the provided parsed identifier.
|
|
/// </summary>
|
|
/// <param name="userAuthorityIdParsed">The parsed identifier of the user authority to delete.</param>
|
|
/// <returns>A task that represents the asynchronous delete operation. The task result is <see langword="true"/> if the user authority was successfully deleted; otherwise, <see langword="false"/>.</returns>
|
|
Task<bool> DeleteUserAuthority(ObjectId userAuthorityIdParsed);
|
|
/// <summary>
|
|
/// Edits the user authority using the provided authorization data.
|
|
/// </summary>
|
|
/// <param name="authorization">The authorization object containing the user authority details to be updated.</param>
|
|
/// <returns>A task that represents the asynchronous operation. The task result contains the updated <see cref="Authorization"/>, or <c>null</c> if the authorization was not found.</returns>
|
|
Task<Authorization?> EditUserAuthority(Authorization authorization);
|
|
} |