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 Title { get; set; } [Column(TypeName = "jsonb")] public List 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 l’ordre - 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 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(); Description = dto.description ?? new List(); 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() // Other method return this; } } }