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

106 lines
3.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 NetTopologySuite.Geometries;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using ManagerService.Helpers;
namespace ManagerService.Data.SubSection
{
public class GuidedStep // Étape dun parcours
{
[Key]
public string Id { get; set; }
[Required]
public string GuidedPathId { get; set; }
[ForeignKey("GuidedPathId")]
public GuidedPath GuidedPath { get; set; }
public int Order { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
public Geometry Geometry { get; set; } // Polygon ou centre du cercle
public double? ZoneRadiusMeters { get; set; } // Optionnel, utile si zone cercle ou point
public string ImageUrl { get; set; }
public int? TriggerGeoPointId { get; set; } // Lieu lié à l'étape et genre si on veut plus d'info ou pourrait afficher les infos du geopoint.
[ForeignKey("TriggerGeoPointId")]
public GeoPoint TriggerGeoPoint { get; set; }
public bool IsHiddenInitially { get; set; } = false;
// Exemple pour escape game
public List<QuizQuestion>? QuizQuestions { get; set; } // One or multiple question
// Option : si true, cette étape a un compte à rebourds, false sinon
public bool IsStepTimer { get; set; } = false;
// Option : si true, cette étape doit être validée avant de passer à la suivante
public bool IsStepLocked { get; set; } = true;
// Timer en secondes (durée max pour valider cette étape, optionnel)
public int? TimerSeconds { get; set; }
// Option : message ou action à effectuer si timer expire (ex: afficher aide, fin du jeu...)
[Column(TypeName = "jsonb")]
public List<TranslationDTO> TimerExpiredMessage { get; set; }
public GuidedStepDTO ToDTO()
{
return new GuidedStepDTO
{
id = Id,
guidedPathId = GuidedPathId,
order = Order,
title = Title,
description = Description,
geometry = Geometry.ToDto(),
zoneRadiusMeters = ZoneRadiusMeters,
imageUrl = ImageUrl,
triggerGeoPointId = TriggerGeoPointId,
triggerGeoPoint = TriggerGeoPoint.ToDTO(),
isHiddenInitially = IsHiddenInitially,
isStepTimer = IsStepTimer,
isStepLocked = IsStepLocked,
timerSeconds = TimerSeconds,
timerExpiredMessage = TimerExpiredMessage,
quizQuestions = QuizQuestions
};
}
public GuidedStep FromDTO(GuidedStepDTO dto)
{
if (dto == null) return null;
GuidedPathId = dto.guidedPathId;
Title = dto.title ?? new List<TranslationDTO>();
Description = dto.description ?? new List<TranslationDTO>();
Geometry = dto.geometry.FromDto();
ZoneRadiusMeters = dto.zoneRadiusMeters;
ImageUrl = dto.imageUrl;
TriggerGeoPointId = dto.triggerGeoPointId;
IsHiddenInitially = dto.isHiddenInitially;
IsStepTimer = dto.isStepTimer;
IsStepLocked = dto.isStepLocked;
TimerSeconds = dto.timerSeconds;
TimerExpiredMessage = dto.timerExpiredMessage ?? new List<TranslationDTO>();
Order = dto.order;
QuizQuestions = dto.quizQuestions;
return this;
}
}
}