2025-08-20 14:35:37 +02:00

80 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using ManagerService.DTOs;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace ManagerService.Data.SubSection
{
public class GuidedPath // Parcours
{
[Key]
public string Id { get; set; }
[Required]
public string InstanceId { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
// Lié à une carte (optionnel)
public string? SectionMapId { get; set; }
[ForeignKey("SectionMapId")]
public SectionMap? SectionMap { get; set; }
// Lié à un événement (optionnel)
public string? SectionEventId { get; set; }
[ForeignKey("SectionEventId")]
public SectionEvent? SectionEvent { get; set; }
// Type de parcours
public bool IsLinear { get; set; } = true; // Avancer dans lordre - Ordre obligatoire
public bool RequireSuccessToAdvance { get; set; } = false; // Par exemple: résoudre une énigme
public bool HideNextStepsUntilComplete { get; set; } = false; // Étapes cachées tant que non terminées
public int Order { get; set; }
public List<GuidedStep> Steps { get; set; } = new();
public GuidedPathDTO ToDTO()
{
return new GuidedPathDTO
{
id = Id,
instanceId = InstanceId,
title = Title,
description = Description,
sectionMapId = SectionMapId,
sectionEventId = SectionEventId,
isLinear = IsLinear,
requireSuccessToAdvance = RequireSuccessToAdvance,
hideNextStepsUntilComplete = HideNextStepsUntilComplete,
order = Order,
steps = Steps?.Select(s => s.ToDTO()).ToList()
};
}
public GuidedPath FromDTO(GuidedPathDTO dto)
{
if (dto == null) return null;
InstanceId = dto.instanceId;
Title = dto.title ?? new List<TranslationDTO>();
Description = dto.description ?? new List<TranslationDTO>();
SectionMapId = dto.sectionMapId;
SectionEventId = dto.sectionEventId;
IsLinear = dto.isLinear;
RequireSuccessToAdvance = dto.requireSuccessToAdvance;
HideNextStepsUntilComplete = dto.hideNextStepsUntilComplete;
Order = dto.order;
//Steps = dto.Steps?.Select(s => s.FromDTO()).ToList() ?? new List<GuidedStep>() // Other method
return this;
}
}
}