using adas_core.Application.Repositories.Interfaces;
using adas_core.Domain.Models.MongoModels;
using MongoDB.Bson;

namespace adas_core.LocalLogin;

/// <summary>
/// Interface for the LocalLoginRepository, which provides methods for managing user authentication and authorization data in a MongoDB database. 
/// This repository allows for operations such as retrieving all users, getting a user by ID or email, and updating or inserting user records.
/// It serves as an abstraction layer between the application and the MongoDB database, ensuring that the data access logic is encapsulated and can be easily maintained or modified in the future.
/// </summary>
public interface ILocalLoginRepository : IMongoRepository<User>
{
    /// <summary>
    /// Retrieves a list of all users from the MongoDB database. This method is asynchronous and returns a Task that resolves to a List of User objects.
    /// </summary>
    /// <returns>A Task that resolves to a List of User objects.</returns>
    Task<List<User>> GetAll();

    /// <summary>
    /// Retrieves a user from the MongoDB database by their unique identifier (ID). This method is asynchronous and returns a Task that resolves to a User object if found, or null if no user with the specified ID exists.
    /// </summary>
    /// <param name="id">The unique identifier of the user to retrieve.</param>
    /// <returns>A Task that resolves to a User object if found, or null if no user with the specified ID exists.</returns>
    Task<User?> GetById(ObjectId id);

    /// <summary>
    /// Retrieves a user from the MongoDB database by their email address. This method is asynchronous and returns a Task that resolves to a User object if found, or null if no user with the specified email exists.
    /// </summary>
    /// <param name="email">The email address of the user to retrieve.</param>
    /// <returns>A Task that resolves to a User object if found, or null if no user with the specified email exists.</returns>
    Task<User?> GetByEmail(string email);

    //User UpdateUser(User user);
    //User DeleteUser(ObjectId id);
    //User CreateUser(User user);
    //IMongoCollection<LocalLoginRepository> Collection { get; }

    /// <summary>
    /// Retrieves a user from the MongoDB database by their username. This method is asynchronous and returns a Task that resolves to a User object if found, or null if no user with the specified username exists.
    /// </summary>
    /// <param name="username">The username of the user to retrieve.</param>
    /// <returns>A Task that resolves to a User object if found, or null if no user with the specified username exists.</returns>
    Task<User?> GetByUsername(string username);

    /// <summary>
    /// Updates an existing user in the MongoDB database. This method is asynchronous and takes the user's unique identifier (ID) and the updated User object as parameters. 
    /// It returns a Task that resolves to a boolean value indicating whether the update was successful (true) or not (false).
    /// </summary>
    /// <param name="id">The unique identifier of the user to update.</param>
    /// <param name="user">The updated User object.</param>
    /// <returns>A Task that resolves to a boolean value indicating whether the update was successful (true) or not (false).</returns>
    Task<bool> UpdateOneUserAsync(ObjectId id, User user);

    /// <summary>
    /// Inserts a new user into the MongoDB database. This method is asynchronous and takes a User object as a parameter.
    /// </summary>
    /// <param name="user">The User object to insert into the database.</param>
    /// <returns>A Task that resolves to a boolean value indicating whether the insertion was successful (true) or not (false).</returns>
    Task<bool> InsertUserOneAsync(User user);
}