using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
namespace ECMJobRunner.Domain.Interfaces
{
///
/// Generic repository interface for data access operations
///
/// Entity type
public interface IRepository where TEntity : class
{
///
/// Get entity by ID asynchronously
///
Task GetByIdAsync(long id, CancellationToken cancellationToken = default);
///
/// Get all entities asynchronously
///
Task> GetAllAsync(CancellationToken cancellationToken = default);
///
/// Find entities by predicate asynchronously
///
Task> FindAsync(Expression> predicate, CancellationToken cancellationToken = default);
///
/// Get single entity by predicate asynchronously
///
Task SingleOrDefaultAsync(Expression> predicate, CancellationToken cancellationToken = default);
///
/// Add new entity from DTO asynchronously
/// Maps DTO to entity and adds it
///
/// DTO type
/// DTO containing values for new entity
/// Cancellation token
/// Created entity
Task AddAsync(TDto dto, CancellationToken cancellationToken = default) where TDto : class;
///
/// Add multiple entities from DTOs asynchronously
/// Maps DTOs to entities and adds them
///
/// DTO type
/// DTOs containing values for new entities
/// Cancellation token
/// Number of entities added
Task AddRangeAsync(IEnumerable dtos, CancellationToken cancellationToken = default) where TDto : class;
///
/// Update entities matching predicate with DTO values asynchronously
/// Maps DTO properties onto matching entities
///
/// DTO type
/// Predicate to find entities
/// DTO containing values to update
/// Cancellation token
/// Number of entities updated
Task UpdateAsync(Expression> predicate, TDto dto, CancellationToken cancellationToken = default) where TDto : class;
///
/// Update single entity matching predicate with DTO values asynchronously
/// Throws exception if multiple entities match
///
/// DTO type
/// Predicate to find entity
/// DTO containing values to update
/// Cancellation token
/// True if entity was found and updated, false otherwise
Task UpdateSingleAsync(Expression> predicate, TDto dto, CancellationToken cancellationToken = default) where TDto : class;
///
/// Delete entities matching predicate asynchronously (hard delete)
///
/// Predicate to find entities to delete
/// Cancellation token
/// Number of entities deleted
Task DeleteAsync(Expression> predicate, CancellationToken cancellationToken = default);
///
/// Delete single entity matching predicate asynchronously (hard delete)
/// Throws exception if multiple entities match
///
/// Predicate to find entity to delete
/// Cancellation token
/// True if entity was found and deleted, false otherwise
Task DeleteSingleAsync(Expression> predicate, CancellationToken cancellationToken = default);
}
}