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

namespace adas_core.Application.Repositories.Interfaces;

public interface IDeviceRepository : IMongoRepository<Device>
{
    /// <summary>
    /// Asynchronously retrieves a device matching the specified MAC address, returning null if no matching device is found.
    /// </summary>
    /// <param name="deviceDtoMacAddr">The MAC address used to look up the device.</param>
    /// <returns>A task that represents the asynchronous operation, containing the matching <see cref="Device"/> or null when no device is found.</returns>
    Task<Device?> FindByMacAddr(string deviceDtoMacAddr);
    /// <summary>
    /// Finds and returns the device matching the specified serial number, or <c>null</c> if no matching device is found.
    /// </summary>
    /// <param name="deviceDtoSerialNumber">The serial number used to look up the device.</param>
    /// <returns>A <see cref="Device"/> instance if a match is found; otherwise, <c>null</c>.</returns>
    Task<Device?> FindBySerialNumber(string deviceDtoSerialNumber);
    /// <summary>
    /// Asynchronously finds a device by its unique identifier (UUID) and returns the matching device, or null if no device is found.
    /// </summary>
    /// <param name="deviceDtoUuid">The UUID string used to look up the device.</param>
    /// <returns>A <see cref="Task{Device}"/> that resolves to the matching <see cref="Device"/>, or null when no device matches the provided UUID.</returns>
    Task<Device?> FindByUuid(string deviceDtoUuid);
    /// <summary>
    /// Retrieves a device by its unique key identifier.
    /// </summary>
    /// <param name="deviceDtoKey">The key identifier of the device to look up.</param>
    /// <returns>A task that represents the asynchronous operation. The task result contains the <see cref="Device"/> if a matching device is found, or <c>null</c> if no device corresponds to the specified key.</returns>
    Task<Device?> FindByKey(string deviceDtoKey);
    /// <summary>
    /// Updates the statistics of an existing device identified by the specified identifier.
    /// </summary>
    /// <param name="id">The unique identifier of the device whose statistics will be updated.</param>
    /// <param name="deviceExist">The device data transfer object representing the existing device to be updated.</param>
    /// <returns>A task that represents the asynchronous update operation.</returns>
    Task UpdateDeviceStats(ObjectId id,DeviceDto deviceExist);
}