85 lines
2.9 KiB
C#
85 lines
2.9 KiB
C#
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; }
|
||
|
||
// Lié à une section game (optionnel) => Escape game / geolocalisé ou non
|
||
public string? SectionGameId { get; set; }
|
||
[ForeignKey("SectionGameId")]
|
||
public SectionGame? SectionGame { 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<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;
|
||
}
|
||
|
||
}
|
||
}
|