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);
}
///
/// Repository interface for QuizQuestion entities.
///
public interface IQuizQuestionRepository : IRepository
{
///
/// Gets quiz questions by lesson ID.
///
Task> GetByLessonAsync(int lessonId, CancellationToken cancellationToken = default);
///
/// Gets all quiz questions ordered by lesson and question order.
///
Task> GetAllOrderedAsync(CancellationToken cancellationToken = default);
///
/// Gets active quiz questions by lesson ID.
///
Task> GetActiveByLessonAsync(int lessonId, CancellationToken cancellationToken = default);
///
/// Gets a random set of quiz questions for a lesson.
///
Task> GetRandomQuestionsForLessonAsync(int lessonId, int count, CancellationToken cancellationToken = default);
///
/// Gets quiz questions by difficulty level.
///
Task> GetByDifficultyAsync(int difficulty, CancellationToken cancellationToken = default);
///
/// Gets quiz questions by type.
///
Task> GetByTypeAsync(QuestionType type, CancellationToken cancellationToken = default);
///
/// Checks if a quiz question with the given order exists in a lesson.
///
Task OrderExistsInLessonAsync(int lessonId, int order, int? excludeId = null, CancellationToken cancellationToken = default);
}
///
/// Repository interface for QuizOption entities.
///
public interface IQuizOptionRepository : IRepository
{
///
/// Gets quiz options by question ID.
///
Task> GetByQuestionAsync(int questionId, CancellationToken cancellationToken = default);
///
/// Gets the correct option for a question.
///
Task GetCorrectOptionAsync(int questionId, CancellationToken cancellationToken = default);
///
/// Gets all correct options for a question (for MultipleSelect type).
///
Task> GetCorrectOptionsAsync(int questionId, CancellationToken cancellationToken = default);
///
/// Deletes all options for a question.
///
Task DeleteByQuestionAsync(int questionId, CancellationToken cancellationToken = default);
///
/// Checks if the order exists for a question.
///
Task OrderExistsForQuestionAsync(int questionId, int order, int? excludeId = null, CancellationToken cancellationToken = default);
}