diff --git a/ManagerService/Data/SubSection/GuidedPath.cs b/ManagerService/Data/SubSection/GuidedPath.cs new file mode 100644 index 0000000..31e34f4 --- /dev/null +++ b/ManagerService/Data/SubSection/GuidedPath.cs @@ -0,0 +1,79 @@ +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; + } + + } +} diff --git a/ManagerService/Data/SubSection/GuidedStep.cs b/ManagerService/Data/SubSection/GuidedStep.cs new file mode 100644 index 0000000..16eac10 --- /dev/null +++ b/ManagerService/Data/SubSection/GuidedStep.cs @@ -0,0 +1,105 @@ +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 d’un 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 Title { get; set; } + + [Column(TypeName = "jsonb")] + public List 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? 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 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(); + Description = dto.description ?? new List(); + 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(); + Order = dto.order; + QuizQuestions = dto.quizQuestions; + return this; + } + + } + +} diff --git a/ManagerService/Data/SubSection/SectionMap.cs b/ManagerService/Data/SubSection/SectionMap.cs index 8f60c6c..5372f9d 100644 --- a/ManagerService/Data/SubSection/SectionMap.cs +++ b/ManagerService/Data/SubSection/SectionMap.cs @@ -148,174 +148,6 @@ 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; - } - - } - - public class GuidedStep // Étape d’un 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 Title { get; set; } - - [Column(TypeName = "jsonb")] - public List 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? 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 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(); - Description = dto.description ?? new List(); - 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(); - Order = dto.order; - QuizQuestions = dto.quizQuestions; - return this; - } - - } - - - // SectionMap "normal" comme avant => Via geopoints. Si il y a des guidedPath lié à la sectionMap alors il y a un parcours lié à la sectionMap, tu peux aussi avoir des geopoints classique mis là + des parcours. et aussi lier un guidedstep à un geopoint (pour le trigger et aussi pour "afficher plus") // parcours libre diff --git a/ManagerService/Startup.cs b/ManagerService/Startup.cs index 45e9ed7..0b4a75d 100644 --- a/ManagerService/Startup.cs +++ b/ManagerService/Startup.cs @@ -188,7 +188,7 @@ namespace ManagerService app.UseCors( #if DEBUG options => options - .SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:52172") + .SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:64515") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()