using GermanApp.Domain.Entities; namespace GermanApp.Domain.Interfaces; /// /// Generic repository interface for domain entities. /// All repositories should implement this interface. /// /// The entity type /// The identifier type (usually int or Guid) public interface IRepository where TEntity : class { /// /// Gets an entity by its identifier. /// Task GetByIdAsync(TId id, CancellationToken cancellationToken = default); /// /// Gets all entities. /// Task> GetAllAsync(CancellationToken cancellationToken = default); /// /// Adds a new entity. /// Task AddAsync(TEntity entity, CancellationToken cancellationToken = default); /// /// Updates an existing entity. /// Task UpdateAsync(TEntity entity, CancellationToken cancellationToken = default); /// /// Deletes an entity. /// Task DeleteAsync(TEntity entity, CancellationToken cancellationToken = default); /// /// Checks if an entity with the given identifier exists. /// Task ExistsAsync(TId id, CancellationToken cancellationToken = default); } /// /// Repository interface for Level entities. /// public interface ILevelRepository : IRepository { /// /// Gets a level by its code (e.g., "A1", "B2"). /// Task GetByCodeAsync(string code, CancellationToken cancellationToken = default); /// /// Gets all levels ordered by their sort order. /// Task> GetAllOrderedAsync(CancellationToken cancellationToken = default); /// /// Gets the first level (lowest order number). /// Task GetFirstLevelAsync(CancellationToken cancellationToken = default); /// /// Gets the next level after the specified one. /// Task GetNextLevelAsync(int currentLevelId, CancellationToken cancellationToken = default); } /// /// Repository interface for Lesson entities. /// public interface ILessonRepository : IRepository { /// /// Gets lessons by level. /// Task> GetByLevelAsync(int levelId, CancellationToken cancellationToken = default); /// /// Gets all lessons ordered by level and lesson order. /// Task> GetAllOrderedAsync(CancellationToken cancellationToken = default); /// /// Gets the first lesson in a level. /// Task GetFirstLessonInLevelAsync(int levelId, CancellationToken cancellationToken = default); /// /// Gets the next lesson after the specified one (in the same level). /// Task GetNextLessonAsync(int currentLessonId, CancellationToken cancellationToken = default); /// /// Gets lessons that the user can access (completed previous lessons or first in level). /// Task> GetAccessibleLessonsAsync(int userId, CancellationToken cancellationToken = default); } /// /// Repository interface for UserProgress entities. /// public interface IUserProgressRepository : IRepository { /// /// Gets user progress for a specific user and lesson. /// Task GetByUserAndLessonAsync(int userId, int lessonId, CancellationToken cancellationToken = default); /// /// Gets all progress records for a user. /// Task> GetByUserAsync(int userId, CancellationToken cancellationToken = default); /// /// Gets progress for all lessons in a specific level for a user. /// Task> GetByUserAndLevelAsync(int userId, int levelId, CancellationToken cancellationToken = default); /// /// Checks if a user has completed a lesson (with 80% or higher score). /// Task HasUserCompletedLessonAsync(int userId, int lessonId, CancellationToken cancellationToken = default); /// /// Gets the user's average score for a level. /// Task GetAverageScoreForLevelAsync(int userId, int levelId, CancellationToken cancellationToken = default); /// /// Gets the percentage of lessons completed in a level. /// Task GetLevelCompletionPercentageAsync(int userId, int levelId, CancellationToken cancellationToken = default); }