- Domain layer: Lesson entity, GermanWord value object, repository interfaces - Application layer: CQRS commands, DTOs with mapping - Infrastructure layer: EF Core with SQLite, LessonRepository - Presentation layer: Minimal API endpoints for lessons CRUD Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
namespace GermanApp.Domain.Entities;
|
|
|
|
/// <summary>
|
|
/// Represents a German language lesson in the system.
|
|
/// </summary>
|
|
public class Lesson
|
|
{
|
|
// Private setter for domain behavior, but internal for EF Core
|
|
public int Id { get; private set; }
|
|
public string Title { get; private set; } = string.Empty;
|
|
public string Description { get; private set; } = string.Empty;
|
|
public int Level { get; private set; }
|
|
public DateTime CreatedAt { get; private set; }
|
|
public DateTime? UpdatedAt { get; private set; }
|
|
|
|
// Navigation properties would go here in EF Core
|
|
// public ICollection<VocabularyWord> Words { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Constructor for EF Core deserialization.
|
|
/// </summary>
|
|
private Lesson() { }
|
|
|
|
/// <summary>
|
|
/// Factory method to create a new lesson.
|
|
/// </summary>
|
|
public static Lesson Create(string title, string description, int level)
|
|
{
|
|
return new Lesson
|
|
{
|
|
Title = title,
|
|
Description = description,
|
|
Level = level,
|
|
CreatedAt = DateTime.UtcNow
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the lesson details.
|
|
/// </summary>
|
|
public void Update(string title, string description, int level)
|
|
{
|
|
Title = title;
|
|
Description = description;
|
|
Level = level;
|
|
UpdatedAt = DateTime.UtcNow;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Domain behavior: Check if lesson is at beginner level.
|
|
/// </summary>
|
|
public bool IsBeginnerLevel() => Level <= 2;
|
|
|
|
/// <summary>
|
|
/// Domain behavior: Check if lesson is at advanced level.
|
|
/// </summary>
|
|
public bool IsAdvancedLevel() => Level >= 4;
|
|
}
|