using ManagerService.DTOs; using NetTopologySuite.Geometries; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; namespace ManagerService.Data.SubSection { /// /// Section event /// public class SectionEvent : Section { public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public List Programme { get; set; } = new(); [Column(TypeName = "jsonb")] public List ParcoursIds { get; set; } = new(); // Liens vers GeoPoints spécifiques public class ProgrammeBlock { [Key] public string Id { get; set; } [Column(TypeName = "jsonb")] public List Title { get; set; } [Column(TypeName = "jsonb")] public List Description { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public List MapAnnotations { get; set; } public ProgrammeBlockDTO ToDTO() { return new ProgrammeBlockDTO { Id = this.Id, Title = this.Title, Description = this.Description, StartTime = this.StartTime, EndTime = this.EndTime, MapAnnotations = this.MapAnnotations?.Select(ma => ma.ToDTO()).ToList() }; } public ProgrammeBlock FromDTO(ProgrammeBlockDTO dto) { return new ProgrammeBlock { Id = dto.Id, Title = dto.Title, Description = dto.Description, StartTime = dto.StartTime, EndTime = dto.EndTime, //MapAnnotations = dto.MapAnnotations?.Select(ma => new MapAnnotation.FromDTO(ma)).ToList() // Other method }; } } public class MapAnnotation { [Key] public string Id { get; set; } [Column(TypeName = "jsonb")] public List Type { get; set; } // "first_aid", "parking", etc. [Column(TypeName = "jsonb")] public List Label { get; set; } public GeometryType GeometryType { get; set; } public Geometry Geometry { get; set; } // Peut être Point, LineString, Polygon public string PolyColor { get; set; } public string Icon { get; set; } // icon material if point public string IconResourceId { get; set; } // Icon resource id public Resource IconResource { get; set; } // Icon resource public MapAnnotationDTO ToDTO() { return new MapAnnotationDTO { Id = Id, Type = Type, Label = Label, GeometryType = GeometryType, Geometry = Geometry, PolyColor = PolyColor, Icon = Icon, IconResourceId = IconResourceId, IconResource = IconResource?.ToDTO() }; } public MapAnnotation FromDTO(MapAnnotationDTO dto) { return new MapAnnotation { Id = dto.Id, Type = dto.Type, Label = dto.Label, GeometryType = dto.GeometryType, Geometry = dto.Geometry, PolyColor = dto.PolyColor, Icon = dto.Icon, IconResourceId = dto.IconResourceId, //IconResource = dto.IconResource?.ToModel() }; } } public enum GeometryType { Point, Polyline, Circle, Polygon } /*public EventDTO ToDTO() { return new EventDTO() { id = Id, label = Label, title = Title.ToList(), description = Description.ToList(), order = Order, type = Type, imageId = ImageId, imageSource = ImageSource, configurationId = ConfigurationId, isSubSection = IsSubSection, parentId = ParentId, dateCreation = DateCreation, instanceId = InstanceId, isBeacon = IsBeacon, beaconId = BeaconId, latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, }; }*/ } }