namespace OmsorgCore.Application.Services;

using OmsorgCore.Domain.Entities;

public interface IAssignmentService
{
    Task<(IReadOnlyList<Assignment> Items, int TotalCount)> GetPagedAsync(
        Guid? orderId = null,
        Guid? employeeId = null,
        DateOnly? fromDate = null,
        DateOnly? toDate = null,
        int page = 1,
        int pageSize = 20,
        CancellationToken cancellationToken = default);

    Task<Assignment?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);

    Task<CreateAssignmentResult> CreateAsync(Guid orderId, Guid employeeId, DateOnly startDate, DateOnly endDate, string? note, CancellationToken cancellationToken = default);

    /// <summary>
    /// Führt dieselben FR-EM-3-Konfliktprüfungen wie <see cref="CreateAsync"/> aus, ohne eine
    /// Zuweisung anzulegen - für die Live-Vorschau im Anlegen-/Bearbeiten-Dialog. Liefert eine
    /// leere Liste, wenn Auftrag/Mitarbeiter (noch) nicht existieren oder der Zeitraum ungültig ist
    /// (diese Fälle werden im Formular bereits über Pflichtfelder/Min-Max abgefangen).
    /// </summary>
    Task<IReadOnlyList<AssignmentConflict>> CheckConflictsAsync(
        Guid orderId,
        Guid employeeId,
        DateOnly startDate,
        DateOnly endDate,
        Guid? excludeAssignmentId = null,
        CancellationToken cancellationToken = default);

    Task<Assignment?> UpdateAsync(Guid id, string? note, CancellationToken cancellationToken = default);

    Task<bool> DeleteAsync(Guid id, CancellationToken cancellationToken = default);

    Task<IReadOnlyList<Assignment>> GetDeletedAsync(string? search = null, CancellationToken cancellationToken = default);

    Task<bool> RestoreAsync(Guid id, CancellationToken cancellationToken = default);

    Task SaveChangesAsync(CancellationToken cancellationToken = default);
}
