54 lines
2.2 KiB
C#
54 lines
2.2 KiB
C#
using Koogle.Domain.Entities;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Koogle.Domain.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// Generisches Repository-Interface für grundlegende CRUD-Operationen.
|
|
/// </summary>
|
|
/// <typeparam name="T">Der Entitätstyp, muss von BaseEntity erben.</typeparam>
|
|
public interface IRepository<T> where T : BaseEntity
|
|
{
|
|
/// <summary>
|
|
/// Ruft eine Entität anhand ihrer ID ab.
|
|
/// </summary>
|
|
/// <param name="id">Die eindeutige ID der Entität.</param>
|
|
/// <param name="cancellationToken">Token zur Abbruchsteuerung.</param>
|
|
/// <returns>Die gefundene Entität oder null.</returns>
|
|
Task<T?> GetByIdAsync(int id, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Ruft alle nicht gelöschten Entitäten ab.
|
|
/// </summary>
|
|
/// <param name="cancellationToken">Token zur Abbruchsteuerung.</param>
|
|
/// <returns>Eine Liste aller aktiven Entitäten.</returns>
|
|
Task<IReadOnlyList<T>> GetAllAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Fügt eine neue Entität hinzu.
|
|
/// </summary>
|
|
/// <param name="entity">Die hinzuzufügende Entität.</param>
|
|
/// <param name="cancellationToken">Token zur Abbruchsteuerung.</param>
|
|
/// <returns>Die hinzugefügte Entität mit generierter ID.</returns>
|
|
Task<T> AddAsync(T entity, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Aktualisiert eine bestehende Entität.
|
|
/// </summary>
|
|
/// <param name="entity">Die zu aktualisierende Entität.</param>
|
|
/// <param name="cancellationToken">Token zur Abbruchsteuerung.</param>
|
|
Task<T> UpdateAsync(T entity, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Führt ein Soft-Delete der Entität durch (setzt IsDeleted = true).
|
|
/// </summary>
|
|
/// <param name="id">Die ID der zu löschenden Entität.</param>
|
|
/// <param name="cancellationToken">Token zur Abbruchsteuerung.</param>
|
|
Task<T?> DeleteAsync(int id, CancellationToken cancellationToken = default);
|
|
}
|
|
}
|