DeutschLernen/GermanApp/Domain/Entities/Lesson.cs
Lasse Rune Hansen 5a514c5a2d feat(backend/story-integration): Phase 1 - Database & Models
Implement story integration foundation:
- Create Domain/Entities/StorySegment.cs with full CRUD methods
- Create Domain/Entities/StoryProgress.cs for user story progress tracking
- Create Application/DTOs/StorySegmentDto.cs with multiple DTO types
- Create Domain/Interfaces/IStoryRepository.cs
- Create Domain/Interfaces/IStoryProgressRepository.cs
- Create Infrastructure/Data/Repositories/StoryRepository.cs
- Create Infrastructure/Data/Repositories/StoryProgressRepository.cs
- Add DbSets and entity configurations to AppDbContext
- Add navigation properties to Level, Lesson, and User entities

Next: Phase 2 - Backend Services (StoryService, StoryGenerationService)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-13 13:23:12 +02:00

113 lines
3.1 KiB
C#

namespace GermanApp.Domain.Entities;
/// <summary>
/// Represents a lesson in the DeutschLernen system.
/// Lessons are organized within CEFR levels and must be completed in order.
/// </summary>
public class Lesson
{
public int Id { get; private set; }
public int LevelId { get; private set; }
public string Title { get; private set; } = string.Empty;
public int Order { get; private set; }
public string Topic { get; private set; } = string.Empty;
public string Description { get; private set; } = string.Empty;
public bool IsActive { get; private set; } = true;
public DateTime CreatedAt { get; private set; }
public DateTime? UpdatedAt { get; private set; }
// Navigation property (EF Core will handle this)
public virtual Level? Level { get; private set; }
/// <summary>
/// Constructor for EF Core deserialization.
/// </summary>
private Lesson() { }
/// <summary>
/// Factory method to create a new lesson.
/// </summary>
/// <param name="levelId">ID of the parent level</param>
/// <param name="title">Title of the lesson</param>
/// <param name="order">Sort order within the level</param>
/// <param name="topic">Main topic covered in the lesson</param>
/// <param name="description">Description of what the lesson covers</param>
public static Lesson Create(int levelId, string title, int order, string topic, string description = "")
{
return new Lesson
{
LevelId = levelId,
Title = title,
Order = order,
Topic = topic,
Description = description,
CreatedAt = DateTime.UtcNow
};
}
/// <summary>
/// Updates the lesson's title.
/// </summary>
public void UpdateTitle(string newTitle)
{
Title = newTitle;
UpdatedAt = DateTime.UtcNow;
}
/// <summary>
/// Updates the lesson's topic.
/// </summary>
public void UpdateTopic(string newTopic)
{
Topic = newTopic;
UpdatedAt = DateTime.UtcNow;
}
/// <summary>
/// Updates the lesson's description.
/// </summary>
public void UpdateDescription(string newDescription)
{
Description = newDescription;
UpdatedAt = DateTime.UtcNow;
}
/// <summary>
/// Updates the lesson's sort order.
/// </summary>
public void UpdateOrder(int newOrder)
{
Order = newOrder;
UpdatedAt = DateTime.UtcNow;
}
/// <summary>
/// Updates the lesson's level.
/// </summary>
public void UpdateLevel(int newLevelId)
{
LevelId = newLevelId;
UpdatedAt = DateTime.UtcNow;
}
/// <summary>
/// Activates the lesson.
/// </summary>
public void Activate()
{
IsActive = true;
UpdatedAt = DateTime.UtcNow;
}
/// <summary>
/// Deactivates the lesson.
/// </summary>
public void Deactivate()
{
IsActive = false;
UpdatedAt = DateTime.UtcNow;
}
// Navigation properties
public virtual ICollection<StorySegment> StorySegments { get; private set; } = new List<StorySegment>();
}