69 lines
2.7 KiB
C#
69 lines
2.7 KiB
C#
using Lactose.Models;
|
|
|
|
namespace Lactose.Repositories;
|
|
|
|
/// <summary>
|
|
/// Interface for user repository operations.
|
|
/// </summary>
|
|
public interface IUserRepository : IDisposable {
|
|
/// <summary>
|
|
/// Return the list of all users.
|
|
/// </summary>
|
|
/// <param name="cancellationToken">Token to cancel the operation.</param>
|
|
/// <returns>The list of all users.</returns>
|
|
Task<List<User>> GetAllAsync(CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Insert a new user.
|
|
/// </summary>
|
|
/// <param name="user">The user to insert.</param>
|
|
void Insert(User user);
|
|
|
|
/// <summary>
|
|
/// Saves all the changes to the Model.
|
|
/// </summary>
|
|
/// <param name="cancellationToken">Token to cancel the operation.</param>
|
|
Task SaveAsync(CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Get the user from the database.
|
|
/// </summary>
|
|
/// <param name="id">The user ID.</param>
|
|
/// <param name="cancellationToken">Token to cancel the operation.</param>
|
|
/// <returns>Returns the user if exist.</returns>
|
|
Task<User?> FindAsync(Guid id, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Find a user by email, expects that the email is unique.
|
|
/// </summary>
|
|
/// <param name="email">The email address.</param>
|
|
/// <param name="cancellationToken">Token to cancel the operation.</param>
|
|
/// <returns>Returns the user if found.</returns>
|
|
Task<User?> FindByEmailAsync(string email, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Find a user by username, expects that the username is unique.
|
|
/// </summary>
|
|
/// <param name="username">The username.</param>
|
|
/// <param name="cancellationToken">Token to cancel the operation.</param>
|
|
/// <returns>Returns the user if found.</returns>
|
|
Task<User?> FindByUsernameAsync(string username, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Get the user with their maintained persons eagerly loaded.
|
|
/// </summary>
|
|
/// <param name="id">The user ID.</param>
|
|
/// <param name="cancellationToken">Token to cancel the operation.</param>
|
|
/// <returns>Returns the user with maintained persons if found.</returns>
|
|
Task<User?> FindWithMaintainedPersonsAsync(Guid id, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Sets the list of person (cosplayer) IDs that a user maintains.
|
|
/// Replaces any existing maintainer assignments.
|
|
/// </summary>
|
|
/// <param name="userId">The user ID.</param>
|
|
/// <param name="personIds">The person IDs to assign.</param>
|
|
/// <param name="cancellationToken">Token to cancel the operation.</param>
|
|
Task SetMaintainedPersonsAsync(Guid userId, IEnumerable<Guid> personIds, CancellationToken cancellationToken);
|
|
}
|