DeutschLernen/GermanApp/Application/DTOs/LevelDto.cs
Lasse Rune Hansen be8c58671d feat(backend/application): add DTOs and services for Lesson Management
- Created LevelDto.cs with LevelDto, CreateLevelDto, UpdateLevelDto
- Created UserProgressDto.cs with UserProgressDto, UpdateUserProgressDto, LevelCompletionDto
- Created LevelService.cs with CRUD operations for CEFR levels
- Created LessonService.cs with CRUD operations and filtering by level
- Created ProgressService.cs with user progress tracking, completion percentage, and lesson unlocking logic
- Registered all new services in Program.cs
- Fixed UserProgressDto ToEntity/UpdateFromDto to use domain entity methods

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-08 20:51:38 +02:00

51 lines
1.2 KiB
C#

using GermanApp.Domain.Entities;
namespace GermanApp.Application.DTOs;
/// <summary>
/// Data Transfer Object for Level - used for API responses.
/// This is a read-only representation of a Level entity.
/// </summary>
public record LevelDto(
int Id,
string Name,
string Code,
int Order);
/// <summary>
/// Data Transfer Object for creating a new Level.
/// </summary>
public record CreateLevelDto(
string Name,
string Code,
int Order);
/// <summary>
/// Data Transfer Object for updating an existing Level.
/// </summary>
public record UpdateLevelDto(
string Name,
string Code,
int Order);
/// <summary>
/// Extension methods for mapping between Level entity and DTOs.
/// </summary>
public static class LevelDtoExtensions
{
public static LevelDto ToDto(this Level level) => new(
level.Id,
level.Name,
level.Code,
level.Order);
public static Level ToEntity(this CreateLevelDto dto) =>
Level.Create(dto.Name, dto.Code, dto.Order);
public static void UpdateFromDto(this Level level, UpdateLevelDto dto)
{
level.UpdateName(dto.Name);
level.UpdateCode(dto.Code);
level.UpdateOrder(dto.Order);
}
}