147 lines
4.9 KiB
C#
147 lines
4.9 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Section event
|
|
/// </summary>
|
|
public class SectionEvent : Section
|
|
{
|
|
public DateTime StartDate { get; set; }
|
|
public DateTime EndDate { get; set; }
|
|
public List<ProgrammeBlock> Programme { get; set; } = new();
|
|
[Column(TypeName = "jsonb")]
|
|
public List<string> ParcoursIds { get; set; } = new(); // Liens vers GeoPoints spécifiques
|
|
|
|
public class ProgrammeBlock
|
|
{
|
|
[Key]
|
|
public string Id { get; set; }
|
|
[Column(TypeName = "jsonb")]
|
|
public List<TranslationDTO> Title { get; set; }
|
|
[Column(TypeName = "jsonb")]
|
|
public List<TranslationDTO> Description { get; set; }
|
|
public DateTime StartTime { get; set; }
|
|
public DateTime EndTime { get; set; }
|
|
public List<MapAnnotation> 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<TranslationDTO> Type { get; set; } // "first_aid", "parking", etc.
|
|
[Column(TypeName = "jsonb")]
|
|
public List<TranslationDTO> 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)
|
|
{
|
|
return new MapAnnotation
|
|
{
|
|
Id = dto.id,
|
|
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()
|
|
};
|
|
}
|
|
|
|
}
|
|
|
|
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,
|
|
};
|
|
}*/
|
|
}
|
|
}
|