using ManagerService.DTOs;
using ManagerService.Helpers;
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)
{
Title = dto.title;
Description = dto.description;
StartTime = dto.startTime;
EndTime = dto.endTime;
//MapAnnotations = dto.MapAnnotations?.Select(ma => new MapAnnotation.FromDTO(ma)).ToList() // Other method
return this;
}
}
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.ToDto(),
polyColor = PolyColor,
icon = Icon,
iconResourceId = IconResourceId,
iconResource = IconResource?.ToDTO()
};
}
public MapAnnotation FromDTO(MapAnnotationDTO dto)
{
Type = dto.type;
Label = dto.label;
GeometryType = dto.geometryType;
Geometry = dto.geometry.FromDto();
PolyColor = dto.polyColor;
Icon = dto.icon;
IconResourceId = dto.iconResourceId;
//IconResource = dto.IconResource?.ToModel()
return this;
}
}
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,
};
}*/
}
}