diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs
index 0f8100f..485d0c9 100644
--- a/ManagerService/Controllers/SectionController.cs
+++ b/ManagerService/Controllers/SectionController.cs
@@ -1,5 +1,6 @@
using Manager.DTOs;
using Manager.Helpers;
+using Manager.Interfaces.Models;
using Manager.Services;
using ManagerService.Data;
using ManagerService.Data.SubSection;
@@ -14,7 +15,9 @@ using Newtonsoft.Json;
using NSwag.Annotations;
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using System.Text.Json;
namespace ManagerService.Controllers
{
@@ -46,13 +49,17 @@ namespace ManagerService.Controllers
/// id instance
[ProducesResponseType(typeof(List), 200)]
[ProducesResponseType(typeof(string), 500)]
+ [ProducesResponseType(typeof(string), 400)]
[HttpGet]
public ObjectResult Get([FromQuery] string instanceId)
{
try
{
+ if (instanceId == null)
+ throw new ArgumentNullException("Param is null");
+
//List sections = _sectionService.GetAll(instanceId);
- List sections = _myInfoMateDbContext.Sections.ToList();
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.InstanceId == instanceId).ToList();
/* CLEAN ARTICLE AUDIO - Init new field AudioIds */
@@ -202,7 +209,9 @@ namespace ManagerService.Controllers
if (section == null)
throw new KeyNotFoundException("This section was not found");
- return new OkObjectResult(section.ToDTO());
+ var dto = SectionFactory.ToDTO(section);
+
+ return new OkObjectResult(dto);
/*switch (section.Type) {
case SectionType.Map:
MapDTO mapDTO = JsonConvert.DeserializeObject(section.Data);
@@ -295,21 +304,16 @@ namespace ManagerService.Controllers
if (newSection.configurationId == null)
throw new ArgumentNullException("Configuration param is null");
- if (!_configurationService.IsExist(newSection.configurationId) )
+ var configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == newSection.configurationId);
+ if (configuration == null)
throw new KeyNotFoundException("Configuration does not exist");
// Todo add some verification ?
- Section section = SectionFactory.Create(newSection);
+ Section section = new Section();
// Preparation
List languages = _configuration.GetSection("SupportedLanguages").Get>();
- var contentArticle = new List();
-
- section.Title = LanguageInit.Init("Title", languages);
- section.Description = LanguageInit.Init("Description", languages);
- contentArticle = LanguageInit.Init("Content", languages);
-
switch (newSection.type) {
case SectionType.Map:
section = new SectionMap
@@ -357,7 +361,7 @@ namespace ManagerService.Controllers
section = new SectionArticle
{
ArticleContents = new List(),
- ArticleContent = contentArticle,
+ ArticleContent = LanguageInit.Init("Content", languages),
ArticleAudioIds = LanguageInit.Init("Audio", languages, true)
};
break;
@@ -394,11 +398,8 @@ namespace ManagerService.Controllers
section.IsSubSection = newSection.isSubSection;
section.ParentId = newSection.parentId;
section.Type = newSection.type;
- section.Title = new List();
- section.Description = new List();
- section.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection);
- //section.Order = _sectionService.GetAllFromConfiguration(newSection.configurationId).Count;
+ section.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection)+1;
section.IsBeacon = newSection.isBeacon;
section.BeaconId = newSection.beaconId;
@@ -406,45 +407,10 @@ namespace ManagerService.Controllers
section.Longitude = newSection.longitude;
section.MeterZoneGPS = newSection.meterZoneGPS;
- /*foreach (var language in languages)
- {
- TranslationDTO title = new TranslationDTO();
- TranslationDTO description = new TranslationDTO();
- TranslationDTO content = new TranslationDTO();
- title.language = language.ToUpper();
- description.language = language.ToUpper();
- content.language = language.ToUpper();
- switch (language.ToUpper())
- {
- case "FR":
- title.value = "Titre en français";
- description.value = "Description en français";
- content.value = "Contenu en français";
- break;
- case "EN":
- title.value = "Title in english";
- description.value = "Description en anglais";
- content.value = "Contenu en anglais";
- break;
- case "NL":
- title.value = "Titre in dutch";
- description.value = "Description en néerlandais";
- content.value = "Contenu en néerlandais";
- break;
- case "DE":
- title.value = "Titre en allemand";
- description.value = "Description en allemand";
- content.value = "Contenu en allemand";
- break;
- }
- section.Title.Add(title);
- section.Description.Add(description);
- contentArticle.Add(content);
- }*/
-
- section.Title = section.Title.OrderBy(t => t.Language).ToList();
- section.Description = section.Description.OrderBy(d => d.Language).ToList();
+ section.Title = LanguageInit.Init("Title", languages);
+ section.Description = LanguageInit.Init("Description", languages);
+ section.Id = idService.GenerateHexId();
//_sectionService.Create(section);
_myInfoMateDbContext.Add(section);
_myInfoMateDbContext.SaveChanges();
@@ -526,23 +492,36 @@ namespace ManagerService.Controllers
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut]
- public ObjectResult Update([FromBody] SectionDTO updatedSection)
+ public ObjectResult Update([FromBody] dynamic updatedSection)
{
try
{
- if (updatedSection == null)
+ if (updatedSection.ValueKind == JsonValueKind.Null)
throw new ArgumentNullException("Section param is null");
- //OldSection section = _sectionService.GetById(updatedSection.id);
- Section existingSection = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == updatedSection.id);
+ SectionDTO sectionDTO;
+ if (updatedSection is JsonElement jsonElement)
+ {
+ if (jsonElement.ValueKind == JsonValueKind.Null)
+ throw new ArgumentNullException("Section param is null");
+
+ // Désérialisation de jsonElement en SectionDTO
+ sectionDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ }
+ else
+ {
+ throw new InvalidOperationException("Expected a JsonElement");
+ }
+
+ Section existingSection = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == sectionDTO.id);
if (existingSection == null)
throw new KeyNotFoundException("Section does not exist");
- if (existingSection.Type != updatedSection.type)
+ if (existingSection.Type != sectionDTO.type)
return BadRequest("Type mismatch: cannot change section type");
- var updatedSectionDB = SectionFactory.Create(updatedSection);
+ var updatedSectionDB = SectionFactory.Create(updatedSection, sectionDTO);
// Todo add some verification ?
/*section.InstanceId = updatedSection.instanceId;
@@ -583,7 +562,7 @@ namespace ManagerService.Controllers
// Ajoute d'autres types ici
}
- _myInfoMateDbContext.Entry(existingSection).CurrentValues.SetValues(updatedSection);
+ _myInfoMateDbContext.Entry(existingSection).CurrentValues.SetValues(updatedSectionDB);
_myInfoMateDbContext.SaveChanges();
//Section sectionModified = _sectionService.Update(updatedSection.id, section);
diff --git a/ManagerService/DTOs/SectionDTO.cs b/ManagerService/DTOs/SectionDTO.cs
index 038f3e4..0475433 100644
--- a/ManagerService/DTOs/SectionDTO.cs
+++ b/ManagerService/DTOs/SectionDTO.cs
@@ -1,5 +1,4 @@
-using ManagerService.Data;
-using System;
+using System;
using System.Collections.Generic;
namespace ManagerService.DTOs
diff --git a/ManagerService/Data/Section.cs b/ManagerService/Data/Section.cs
index 00d9311..8ea8b81 100644
--- a/ManagerService/Data/Section.cs
+++ b/ManagerService/Data/Section.cs
@@ -33,10 +33,8 @@ namespace ManagerService.Data
[Required]
public string ConfigurationId { get; set; } // Parent id
- [Required]
public string ImageId { get; set; }
- [Required]
public string ImageSource { get; set; }
[Required]
diff --git a/ManagerService/Migrations/20250320154439_UpdateMix1.Designer.cs b/ManagerService/Migrations/20250320154439_UpdateMix1.Designer.cs
new file mode 100644
index 0000000..3a23f48
--- /dev/null
+++ b/ManagerService/Migrations/20250320154439_UpdateMix1.Designer.cs
@@ -0,0 +1,815 @@
+//
+using System;
+using System.Collections.Generic;
+using Manager.DTOs;
+using ManagerService.DTOs;
+using ManagerService.Data;
+using ManagerService.Data.SubSection;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace ManagerService.Migrations
+{
+ [DbContext(typeof(MyInfoMateDbContext))]
+ [Migration("20250320154439_UpdateMix1")]
+ partial class UpdateMix1
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.2")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("ManagerService.Data.Configuration", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("DateCreation")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ImageId")
+ .HasColumnType("text");
+
+ b.Property("ImageSource")
+ .HasColumnType("text");
+
+ b.Property("InstanceId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsDate")
+ .HasColumnType("boolean");
+
+ b.Property("IsHour")
+ .HasColumnType("boolean");
+
+ b.Property("IsMobile")
+ .HasColumnType("boolean");
+
+ b.Property("IsOffline")
+ .HasColumnType("boolean");
+
+ b.Property("IsSectionImageBackground")
+ .HasColumnType("boolean");
+
+ b.Property("IsTablet")
+ .HasColumnType("boolean");
+
+ b.Property("Label")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.PrimitiveCollection>("Languages")
+ .HasColumnType("text[]");
+
+ b.Property("LoaderImageId")
+ .HasColumnType("text");
+
+ b.Property("LoaderImageUrl")
+ .HasColumnType("text");
+
+ b.Property("PrimaryColor")
+ .HasColumnType("text");
+
+ b.Property("RoundedValue")
+ .HasColumnType("integer");
+
+ b.Property("ScreenPercentageSectionsMainPage")
+ .HasColumnType("integer");
+
+ b.Property("SecondaryColor")
+ .HasColumnType("text");
+
+ b.Property>("Title")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.HasKey("Id");
+
+ b.ToTable("Configurations");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.Device", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("BatteryLevel")
+ .HasColumnType("text");
+
+ b.Property("ConfigurationId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Connected")
+ .HasColumnType("boolean");
+
+ b.Property("ConnectionLevel")
+ .HasColumnType("text");
+
+ b.Property("DateCreation")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateUpdate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Identifier")
+ .HasColumnType("text");
+
+ b.Property("InstanceId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IpAddressETH")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IpAddressWLAN")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("LastBatteryLevel")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("LastConnectionLevel")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Name")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ConfigurationId");
+
+ b.ToTable("Devices");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.Instance", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("DateCreation")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("PinCode")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Instances");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.Resource", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("DateCreation")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("InstanceId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Label")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("Url")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Resources");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.Section", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("BeaconId")
+ .HasColumnType("integer");
+
+ b.Property("ConfigurationId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("DateCreation")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property>("Description")
+ .HasColumnType("jsonb");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(8)
+ .HasColumnType("character varying(8)");
+
+ b.Property("ImageId")
+ .HasColumnType("text");
+
+ b.Property("ImageSource")
+ .HasColumnType("text");
+
+ b.Property("InstanceId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsBeacon")
+ .HasColumnType("boolean");
+
+ b.Property("IsSubSection")
+ .HasColumnType("boolean");
+
+ b.Property("Label")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Latitude")
+ .HasColumnType("text");
+
+ b.Property("Longitude")
+ .HasColumnType("text");
+
+ b.Property("MeterZoneGPS")
+ .HasColumnType("integer");
+
+ b.Property("Order")
+ .HasColumnType("integer");
+
+ b.Property("ParentId")
+ .HasColumnType("text");
+
+ b.Property("SectionMenuId")
+ .HasColumnType("text");
+
+ b.Property>("Title")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SectionMenuId");
+
+ b.ToTable("Sections");
+
+ b.HasDiscriminator().HasValue("Base");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Icon")
+ .HasColumnType("text");
+
+ b.Property>("Label")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("Order")
+ .HasColumnType("integer");
+
+ b.Property("ResourceId")
+ .HasColumnType("text");
+
+ b.Property("SectionMapId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ResourceId");
+
+ b.HasIndex("SectionMapId");
+
+ b.ToTable("Categorie");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.Content", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property>("Description")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("Order")
+ .HasColumnType("integer");
+
+ b.Property("ResourceId")
+ .HasColumnType("text");
+
+ b.Property("SectionArticleId")
+ .HasColumnType("text");
+
+ b.Property("SectionSliderId")
+ .HasColumnType("text");
+
+ b.Property>("Title")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ResourceId");
+
+ b.HasIndex("SectionArticleId");
+
+ b.HasIndex("SectionSliderId");
+
+ b.ToTable("Content");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("CategorieId")
+ .HasColumnType("integer");
+
+ b.Property>("Contents")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("Description")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("Email")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("ImageResourceId")
+ .HasColumnType("text");
+
+ b.Property("ImageUrl")
+ .HasColumnType("text");
+
+ b.Property("Latitude")
+ .HasColumnType("text");
+
+ b.Property("Longitude")
+ .HasColumnType("text");
+
+ b.Property>("Phone")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("Prices")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("Schedules")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("SectionMapId")
+ .HasColumnType("text");
+
+ b.Property>("Site")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("Title")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SectionMapId");
+
+ b.ToTable("GeoPoint");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Order")
+ .HasColumnType("integer");
+
+ b.Property("SectionPdfId")
+ .HasColumnType("text");
+
+ b.Property>("TranslationAndResources")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SectionPdfId");
+
+ b.ToTable("OrderedTranslationAndResource");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property>("Label")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("Order")
+ .HasColumnType("integer");
+
+ b.Property("ResourceId")
+ .HasColumnType("text");
+
+ b.Property>("Responses")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("SectionQuizId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ResourceId");
+
+ b.HasIndex("SectionQuizId");
+
+ b.ToTable("QuizQuestion");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.User", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("DateCreation")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("FirstName")
+ .HasColumnType("text");
+
+ b.Property("InstanceId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("LastName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Token")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionAgenda", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property("AgendaMapProvider")
+ .HasColumnType("integer");
+
+ b.Property>("AgendaResourceIds")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.HasDiscriminator().HasValue("Agenda");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property>("ArticleAudioIds")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("ArticleContent")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("ArticleIsContentTop")
+ .HasColumnType("boolean");
+
+ b.Property("ArticleIsReadAudioAuto")
+ .HasColumnType("boolean");
+
+ b.HasDiscriminator().HasValue("Article");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property("MapCenterLatitude")
+ .HasColumnType("text");
+
+ b.Property("MapCenterLongitude")
+ .HasColumnType("text");
+
+ b.Property("MapMapProvider")
+ .HasColumnType("integer");
+
+ b.Property("MapMapType")
+ .HasColumnType("integer");
+
+ b.Property("MapResourceId")
+ .HasColumnType("text");
+
+ b.Property("MapTypeMapbox")
+ .HasColumnType("integer");
+
+ b.Property("MapZoom")
+ .HasColumnType("integer");
+
+ b.HasIndex("MapResourceId");
+
+ b.HasDiscriminator().HasValue("Map");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.HasDiscriminator().HasValue("Menu");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.HasDiscriminator().HasValue("PDF");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property("PuzzleCols")
+ .HasColumnType("integer");
+
+ b.Property("PuzzleImageId")
+ .HasColumnType("text");
+
+ b.Property>("PuzzleMessageDebut")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("PuzzleMessageFin")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property("PuzzleRows")
+ .HasColumnType("integer");
+
+ b.HasIndex("PuzzleImageId");
+
+ b.HasDiscriminator().HasValue("Puzzle");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property>("QuizBadLevel")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("QuizGoodLevel")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("QuizGreatLevel")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.Property>("QuizMediumLevel")
+ .IsRequired()
+ .HasColumnType("jsonb");
+
+ b.HasDiscriminator().HasValue("Quiz");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.HasDiscriminator().HasValue("Slider");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionVideo", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property("VideoSource")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasDiscriminator().HasValue("Video");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeather", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property("WeatherCity")
+ .HasColumnType("text");
+
+ b.Property("WeatherResult")
+ .HasColumnType("text");
+
+ b.Property("WeatherUpdatedDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasDiscriminator().HasValue("Weather");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeb", b =>
+ {
+ b.HasBaseType("ManagerService.Data.Section");
+
+ b.Property("WebSource")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasDiscriminator().HasValue("Web");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.Device", b =>
+ {
+ b.HasOne("ManagerService.Data.Configuration", "Configuration")
+ .WithMany()
+ .HasForeignKey("ConfigurationId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Configuration");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.Section", b =>
+ {
+ b.HasOne("ManagerService.Data.SubSection.SectionMenu", null)
+ .WithMany("MenuSections")
+ .HasForeignKey("SectionMenuId");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b =>
+ {
+ b.HasOne("ManagerService.Data.Resource", "Resource")
+ .WithMany()
+ .HasForeignKey("ResourceId");
+
+ b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
+ .WithMany("MapCategories")
+ .HasForeignKey("SectionMapId");
+
+ b.Navigation("Resource");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.Content", b =>
+ {
+ b.HasOne("ManagerService.Data.Resource", "Resource")
+ .WithMany()
+ .HasForeignKey("ResourceId");
+
+ b.HasOne("ManagerService.Data.SubSection.SectionArticle", null)
+ .WithMany("ArticleContents")
+ .HasForeignKey("SectionArticleId");
+
+ b.HasOne("ManagerService.Data.SubSection.SectionSlider", null)
+ .WithMany("SliderContents")
+ .HasForeignKey("SectionSliderId");
+
+ b.Navigation("Resource");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b =>
+ {
+ b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
+ .WithMany("MapPoints")
+ .HasForeignKey("SectionMapId");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b =>
+ {
+ b.HasOne("ManagerService.Data.SubSection.SectionPdf", null)
+ .WithMany("PDFOrderedTranslationAndResources")
+ .HasForeignKey("SectionPdfId");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b =>
+ {
+ b.HasOne("ManagerService.Data.Resource", "Resource")
+ .WithMany()
+ .HasForeignKey("ResourceId");
+
+ b.HasOne("ManagerService.Data.SubSection.SectionQuiz", null)
+ .WithMany("QuizQuestions")
+ .HasForeignKey("SectionQuizId");
+
+ b.Navigation("Resource");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
+ {
+ b.HasOne("ManagerService.Data.Resource", "MapResource")
+ .WithMany()
+ .HasForeignKey("MapResourceId");
+
+ b.Navigation("MapResource");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
+ {
+ b.HasOne("ManagerService.Data.Resource", "PuzzleImage")
+ .WithMany()
+ .HasForeignKey("PuzzleImageId");
+
+ b.Navigation("PuzzleImage");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b =>
+ {
+ b.Navigation("ArticleContents");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
+ {
+ b.Navigation("MapCategories");
+
+ b.Navigation("MapPoints");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b =>
+ {
+ b.Navigation("MenuSections");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b =>
+ {
+ b.Navigation("PDFOrderedTranslationAndResources");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
+ {
+ b.Navigation("QuizQuestions");
+ });
+
+ modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b =>
+ {
+ b.Navigation("SliderContents");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/ManagerService/Migrations/20250320154439_UpdateMix1.cs b/ManagerService/Migrations/20250320154439_UpdateMix1.cs
new file mode 100644
index 0000000..63e0d64
--- /dev/null
+++ b/ManagerService/Migrations/20250320154439_UpdateMix1.cs
@@ -0,0 +1,54 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace ManagerService.Migrations
+{
+ ///
+ public partial class UpdateMix1 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "ImageSource",
+ table: "Sections",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+
+ migrationBuilder.AlterColumn(
+ name: "ImageId",
+ table: "Sections",
+ type: "text",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "text");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "ImageSource",
+ table: "Sections",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "ImageId",
+ table: "Sections",
+ type: "text",
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "text",
+ oldNullable: true);
+ }
+ }
+}
diff --git a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs
index c3dd844..b7ebaef 100644
--- a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs
+++ b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs
@@ -222,11 +222,9 @@ namespace ManagerService.Migrations
.HasColumnType("character varying(8)");
b.Property("ImageId")
- .IsRequired()
.HasColumnType("text");
b.Property("ImageSource")
- .IsRequired()
.HasColumnType("text");
b.Property("InstanceId")
diff --git a/ManagerService/Services/SectionFactory.cs b/ManagerService/Services/SectionFactory.cs
index 3ab181c..5bf877a 100644
--- a/ManagerService/Services/SectionFactory.cs
+++ b/ManagerService/Services/SectionFactory.cs
@@ -2,20 +2,74 @@
using ManagerService.Data;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
+using MongoDB.Bson;
+using Newtonsoft.Json;
using System;
using System.Linq;
+using System.Text.Json;
namespace ManagerService.Services
{
public static class SectionFactory
{
- public static Section Create(SectionDTO dto)
+ public static Section Create(JsonElement jsonElement, SectionDTO dto)
{
+ AgendaDTO agendaDTO = new AgendaDTO();
+ ArticleDTO articleDTO = new ArticleDTO();
+ MapDTO mapDTO = new MapDTO();
+ MenuDTO menuDTO = new MenuDTO();
+ PdfDTO pdfDTO = new PdfDTO();
+ PuzzleDTO puzzleDTO = new PuzzleDTO();
+ QuizDTO quizDTO = new QuizDTO();
+ SliderDTO sliderDTO = new SliderDTO();
+ VideoDTO videoDTO = new VideoDTO();
+ WeatherDTO weatherDTO = new WeatherDTO();
+ WebDTO webDTO = new WebDTO();
+
+ switch (dto.type)
+ {
+ case SectionType.Agenda:
+ agendaDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Article:
+ articleDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Map:
+ mapDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Menu:
+ menuDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.PDF:
+ pdfDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Puzzle:
+ puzzleDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Quiz:
+ quizDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Slider:
+ sliderDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Video:
+ videoDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Weather:
+ weatherDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ case SectionType.Web:
+ webDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
+ }
+
return dto.type switch
{
SectionType.Agenda => new SectionAgenda
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -30,12 +84,14 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- AgendaResourceIds = ((AgendaDTO)dto).resourceIds.Select(r => new Translation().FromDTO(r)).ToList(),
- AgendaMapProvider = ((AgendaDTO)dto).agendaMapProvider
+ AgendaResourceIds = agendaDTO.resourceIds.Select(r => new Translation().FromDTO(r)).ToList(),
+ AgendaMapProvider = agendaDTO.agendaMapProvider
},
SectionType.Article => new SectionArticle
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -50,15 +106,17 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- ArticleContent = ((ArticleDTO)dto).content.Select(r => new Translation().FromDTO(r)).ToList(),
- ArticleIsContentTop = ((ArticleDTO)dto).isContentTop,
- ArticleAudioIds = ((ArticleDTO)dto).audioIds.Select(a => new Translation().FromDTO(a)).ToList(),
- ArticleIsReadAudioAuto = ((ArticleDTO)dto).isReadAudioAuto,
- ArticleContents = ((ArticleDTO)dto).contents.Select(c => new Content().FromDTO(c)).ToList()
+ ArticleContent = articleDTO.content.Select(r => new Translation().FromDTO(r)).ToList(),
+ ArticleIsContentTop = articleDTO.isContentTop,
+ ArticleAudioIds = articleDTO.audioIds.Select(a => new Translation().FromDTO(a)).ToList(),
+ ArticleIsReadAudioAuto = articleDTO.isReadAudioAuto,
+ ArticleContents = articleDTO.contents.Select(c => new Content().FromDTO(c)).ToList()
},
SectionType.Map => new SectionMap
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -73,19 +131,21 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- MapZoom = ((MapDTO)dto).zoom,
- MapMapType = ((MapDTO)dto).mapType,
- MapTypeMapbox = ((MapDTO)dto).mapTypeMapbox,
- MapMapProvider = ((MapDTO)dto).mapProvider,
- MapResourceId = ((MapDTO)dto).iconResourceId,
- MapCenterLatitude = ((MapDTO)dto).centerLatitude,
- MapCenterLongitude = ((MapDTO)dto).centerLongitude,
+ MapZoom = mapDTO.zoom,
+ MapMapType = mapDTO.mapType,
+ MapTypeMapbox = mapDTO.mapTypeMapbox,
+ MapMapProvider = mapDTO.mapProvider,
+ MapResourceId = mapDTO.iconResourceId,
+ MapCenterLatitude = mapDTO.centerLatitude,
+ MapCenterLongitude = mapDTO.centerLongitude,
MapCategories = null, //((MapDTO)dto).categories, // TODO specific
MapPoints = null // ((MapDTO)dto).points, // TODO specific
},
SectionType.Menu => new SectionMenu
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -105,6 +165,8 @@ namespace ManagerService.Services
SectionType.PDF => new SectionPdf
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -119,11 +181,13 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- PDFOrderedTranslationAndResources = ((PdfDTO)dto).pdfs.Select(p => new OrderedTranslationAndResource().FromDTO(p)).ToList()
+ PDFOrderedTranslationAndResources = pdfDTO.pdfs.Select(p => new OrderedTranslationAndResource().FromDTO(p)).ToList()
},
SectionType.Puzzle => new SectionPuzzle
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -138,15 +202,17 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- PuzzleMessageDebut = ((PuzzleDTO)dto).messageDebut.Select(md => new TranslationAndResource().FromDTO(md)).ToList(),
- PuzzleMessageFin = ((PuzzleDTO)dto).messageFin.Select(mf => new TranslationAndResource().FromDTO(mf)).ToList(),
- PuzzleImageId = ((PuzzleDTO)dto).puzzleImageId,
- PuzzleRows = ((PuzzleDTO)dto).rows,
- PuzzleCols = ((PuzzleDTO)dto).cols
+ PuzzleMessageDebut = puzzleDTO.messageDebut.Select(md => new TranslationAndResource().FromDTO(md)).ToList(),
+ PuzzleMessageFin = puzzleDTO.messageFin.Select(mf => new TranslationAndResource().FromDTO(mf)).ToList(),
+ PuzzleImageId = puzzleDTO.puzzleImageId,
+ PuzzleRows = puzzleDTO.rows,
+ PuzzleCols = puzzleDTO.cols
},
SectionType.Quiz => new SectionQuiz
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -161,15 +227,17 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- QuizBadLevel = ((QuizDTO)dto).bad_level.Select(bl => new TranslationAndResource().FromDTO(bl)).ToList(),
- QuizMediumLevel = ((QuizDTO)dto).medium_level.Select(ml => new TranslationAndResource().FromDTO(ml)).ToList(),
- QuizGoodLevel = ((QuizDTO)dto).good_level.Select(gol => new TranslationAndResource().FromDTO(gol)).ToList(),
- QuizGreatLevel = ((QuizDTO)dto).great_level.Select(gl => new TranslationAndResource().FromDTO(gl)).ToList(),
+ QuizBadLevel = quizDTO.bad_level.Select(bl => new TranslationAndResource().FromDTO(bl)).ToList(),
+ QuizMediumLevel = quizDTO.medium_level.Select(ml => new TranslationAndResource().FromDTO(ml)).ToList(),
+ QuizGoodLevel = quizDTO.good_level.Select(gol => new TranslationAndResource().FromDTO(gol)).ToList(),
+ QuizGreatLevel = quizDTO.great_level.Select(gl => new TranslationAndResource().FromDTO(gl)).ToList(),
//Questions = ((QuizDTO)dto).questions, // TODO specific
},
SectionType.Slider => new SectionSlider
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -184,11 +252,13 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- SliderContents = ((SliderDTO)dto).contents.Select(c => new Content().FromDTO(c)).ToList(), // TODO TEST
+ SliderContents = sliderDTO.contents.Select(c => new Content().FromDTO(c)).ToList(), // TODO TEST
},
SectionType.Video => new SectionVideo
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -203,12 +273,14 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- VideoSource = ((VideoDTO)dto).source,
+ VideoSource = videoDTO.source,
},
SectionType.Weather => new SectionWeather
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -223,13 +295,15 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- WeatherCity = ((WeatherDTO)dto).city,
- WeatherUpdatedDate = ((WeatherDTO)dto).updatedDate,
- WeatherResult = ((WeatherDTO)dto).result
+ WeatherCity = weatherDTO.city,
+ WeatherUpdatedDate = weatherDTO.updatedDate,
+ WeatherResult = weatherDTO.result
},
SectionType.Web => new SectionWeb
{
Id = dto.id,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
Label = dto.label,
Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
@@ -244,9 +318,261 @@ namespace ManagerService.Services
Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
- WebSource = ((WebDTO)dto).source,
+ WebSource = webDTO.source,
},
+ _ => throw new NotImplementedException("Section type not handled")
+ };
+ }
+ public static SectionDTO ToDTO(Section section)
+ {
+ return section switch
+ {
+ SectionAgenda agenda => new AgendaDTO
+ {
+ id = agenda.Id,
+ configurationId = agenda.ConfigurationId,
+ instanceId = agenda.InstanceId,
+ label = agenda.Label,
+ title = agenda.Title.Select(t => t.ToDTO()).ToList(),
+ description = agenda.Description.Select(t => t.ToDTO()).ToList(),
+ order = agenda.Order,
+ imageId = agenda.ImageId,
+ imageSource = agenda.ImageSource,
+ isSubSection = agenda.IsSubSection,
+ parentId = agenda.ParentId,
+ isBeacon = agenda.IsBeacon,
+ beaconId = agenda.BeaconId,
+ latitude = agenda.Latitude,
+ longitude = agenda.Longitude,
+ meterZoneGPS = agenda.MeterZoneGPS,
+ type = agenda.Type,
+ resourceIds = agenda.AgendaResourceIds.Select(r => r.ToDTO()).ToList(),
+ agendaMapProvider = agenda.AgendaMapProvider
+ },
+ SectionArticle article => new ArticleDTO
+ {
+ id = article.Id,
+ configurationId = article.ConfigurationId,
+ instanceId = agenda.InstanceId,
+ label = article.Label,
+ title = article.Title.Select(t => t.ToDTO()).ToList(),
+ description = article.Description.Select(d => d.ToDTO()).ToList(),
+ order = article.Order,
+ imageId = article.ImageId,
+ imageSource = article.ImageSource,
+ isSubSection = article.IsSubSection,
+ parentId = article.ParentId,
+ isBeacon = article.IsBeacon,
+ beaconId = article.BeaconId,
+ latitude = article.Latitude,
+ longitude = article.Longitude,
+ meterZoneGPS = article.MeterZoneGPS,
+ type = article.Type,
+ content = article.ArticleContent.Select(r => r.ToDTO()).ToList(),
+ isContentTop = article.ArticleIsContentTop,
+ audioIds = article.ArticleAudioIds.Select(a => a.ToDTO()).ToList(),
+ isReadAudioAuto = article.ArticleIsReadAudioAuto,
+ contents = article.ArticleContents.Select(c => c.ToDTO()).ToList()
+ },
+ SectionMap map => new MapDTO
+ {
+ id = map.Id,
+ configurationId = map.ConfigurationId,
+ label = map.Label,
+ title = map.Title.Select(t => t.ToDTO()).ToList(),
+ description = map.Description.Select(d => d.ToDTO()).ToList(),
+ order = map.Order,
+ imageId = map.ImageId,
+ imageSource = map.ImageSource,
+ isSubSection = map.IsSubSection,
+ parentId = map.ParentId,
+ isBeacon = map.IsBeacon,
+ beaconId = map.BeaconId,
+ latitude = map.Latitude,
+ longitude = map.Longitude,
+ meterZoneGPS = map.MeterZoneGPS,
+ type = map.Type,
+ zoom = map.MapZoom,
+ mapType = map.MapMapType,
+ mapTypeMapbox = map.MapTypeMapbox,
+ mapProvider = map.MapMapProvider,
+ iconResourceId = map.MapResourceId,
+ centerLatitude = map.MapCenterLatitude,
+ centerLongitude = map.MapCenterLongitude,
+ categories = null, // map.MapCategories, // TODO specific
+ points = null // map.MapPoints // TODO specific
+ },
+ SectionMenu menu => new MenuDTO
+ {
+ id = menu.Id,
+ configurationId = menu.ConfigurationId,
+ label = menu.Label,
+ title = menu.Title.Select(t => t.ToDTO()).ToList(),
+ description = menu.Description.Select(d => d.ToDTO()).ToList(),
+ order = menu.Order,
+ imageId = menu.ImageId,
+ imageSource = menu.ImageSource,
+ isSubSection = menu.IsSubSection,
+ parentId = menu.ParentId,
+ isBeacon = menu.IsBeacon,
+ beaconId = menu.BeaconId,
+ latitude = menu.Latitude,
+ longitude = menu.Longitude,
+ meterZoneGPS = menu.MeterZoneGPS,
+ type = menu.Type,
+ sections = null // menu.Sections, // TODO specific
+ },
+ SectionPdf pdf => new PdfDTO
+ {
+ id = pdf.Id,
+ configurationId = pdf.ConfigurationId,
+ label = pdf.Label,
+ title = pdf.Title.Select(t => t.ToDTO()).ToList(),
+ description = pdf.Description.Select(d => d.ToDTO()).ToList(),
+ order = pdf.Order,
+ imageId = pdf.ImageId,
+ imageSource = pdf.ImageSource,
+ isSubSection = pdf.IsSubSection,
+ parentId = pdf.ParentId,
+ isBeacon = pdf.IsBeacon,
+ beaconId = pdf.BeaconId,
+ latitude = pdf.Latitude,
+ longitude = pdf.Longitude,
+ meterZoneGPS = pdf.MeterZoneGPS,
+ type = pdf.Type,
+ pdfs = pdf.PDFOrderedTranslationAndResources.Select(p => p.ToDTO()).ToList()
+ },
+ SectionPuzzle puzzle => new PuzzleDTO
+ {
+ id = puzzle.Id,
+ configurationId = puzzle.ConfigurationId,
+ label = puzzle.Label,
+ title = puzzle.Title.Select(t => t.ToDTO()).ToList(),
+ description = puzzle.Description.Select(d => d.ToDTO()).ToList(),
+ order = puzzle.Order,
+ imageId = puzzle.ImageId,
+ imageSource = puzzle.ImageSource,
+ isSubSection = puzzle.IsSubSection,
+ parentId = puzzle.ParentId,
+ isBeacon = puzzle.IsBeacon,
+ beaconId = puzzle.BeaconId,
+ latitude = puzzle.Latitude,
+ longitude = puzzle.Longitude,
+ meterZoneGPS = puzzle.MeterZoneGPS,
+ type = puzzle.Type,
+ messageDebut = puzzle.PuzzleMessageDebut.Select(md => md.ToDTO()).ToList(),
+ messageFin = puzzle.PuzzleMessageFin.Select(mf => mf.ToDTO()).ToList(),
+ puzzleImageId = puzzle.PuzzleImageId,
+ rows = puzzle.PuzzleRows,
+ cols = puzzle.PuzzleCols
+ },
+ SectionQuiz quiz => new QuizDTO
+ {
+ id = quiz.Id,
+ configurationId = quiz.ConfigurationId,
+ label = quiz.Label,
+ title = quiz.Title.Select(t => t.ToDTO()).ToList(),
+ description = quiz.Description.Select(d => d.ToDTO()).ToList(),
+ order = quiz.Order,
+ imageId = quiz.ImageId,
+ imageSource = quiz.ImageSource,
+ isSubSection = quiz.IsSubSection,
+ parentId = quiz.ParentId,
+ isBeacon = quiz.IsBeacon,
+ beaconId = quiz.BeaconId,
+ latitude = quiz.Latitude,
+ longitude = quiz.Longitude,
+ meterZoneGPS = quiz.MeterZoneGPS,
+ type = quiz.Type,
+ bad_level = quiz.QuizBadLevel.Select(bl => bl.ToDTO()).ToList(),
+ medium_level = quiz.QuizMediumLevel.Select(ml => ml.ToDTO()).ToList(),
+ good_level = quiz.QuizGoodLevel.Select(gol => gol.ToDTO()).ToList(),
+ great_level = quiz.QuizGreatLevel.Select(gl => gl.ToDTO()).ToList(),
+ questions = null // quiz.Questions, // TODO specific
+ },
+ SectionSlider slider => new SliderDTO
+ {
+ id = slider.Id,
+ configurationId = slider.ConfigurationId,
+ label = slider.Label,
+ title = slider.Title.Select(t => t.ToDTO()).ToList(),
+ description = slider.Description.Select(d => d.ToDTO()).ToList(),
+ order = slider.Order,
+ imageId = slider.ImageId,
+ imageSource = slider.ImageSource,
+ isSubSection = slider.IsSubSection,
+ parentId = slider.ParentId,
+ isBeacon = slider.IsBeacon,
+ beaconId = slider.BeaconId,
+ latitude = slider.Latitude,
+ longitude = slider.Longitude,
+ meterZoneGPS = slider.MeterZoneGPS,
+ type = slider.Type,
+ contents = slider.SliderContents.Select(c => c.ToDTO()).ToList()
+ },
+ SectionVideo video => new VideoDTO
+ {
+ id = video.Id,
+ configurationId = video.ConfigurationId,
+ label = video.Label,
+ title = video.Title.Select(t => t.ToDTO()).ToList(),
+ description = video.Description.Select(d => d.ToDTO()).ToList(),
+ order = video.Order,
+ imageId = video.ImageId,
+ imageSource = video.ImageSource,
+ isSubSection = video.IsSubSection,
+ parentId = video.ParentId,
+ isBeacon = video.IsBeacon,
+ beaconId = video.BeaconId,
+ latitude = video.Latitude,
+ longitude = video.Longitude,
+ meterZoneGPS = video.MeterZoneGPS,
+ type = video.Type,
+ source = video.VideoSource
+ },
+ SectionWeather weather => new WeatherDTO
+ {
+ id = weather.Id,
+ configurationId = weather.ConfigurationId,
+ label = weather.Label,
+ title = weather.Title.Select(t => t.ToDTO()).ToList(),
+ description = weather.Description.Select(d => d.ToDTO()).ToList(),
+ order = weather.Order,
+ imageId = weather.ImageId,
+ imageSource = weather.ImageSource,
+ isSubSection = weather.IsSubSection,
+ parentId = weather.ParentId,
+ isBeacon = weather.IsBeacon,
+ beaconId = weather.BeaconId,
+ latitude = weather.Latitude,
+ longitude = weather.Longitude,
+ meterZoneGPS = weather.MeterZoneGPS,
+ type = weather.Type,
+ city = weather.WeatherCity,
+ updatedDate = weather.WeatherUpdatedDate,
+ result = weather.WeatherResult
+ },
+ SectionWeb web => new WebDTO
+ {
+ id = web.Id,
+ configurationId = web.ConfigurationId,
+ label = web.Label,
+ title = web.Title.Select(t => t.ToDTO()).ToList(),
+ description = web.Description.Select(d => d.ToDTO()).ToList(),
+ order = web.Order,
+ imageId = web.ImageId,
+ imageSource = web.ImageSource,
+ isSubSection = web.IsSubSection,
+ parentId = web.ParentId,
+ isBeacon = web.IsBeacon,
+ beaconId = web.BeaconId,
+ latitude = web.Latitude,
+ longitude = web.Longitude,
+ meterZoneGPS = web.MeterZoneGPS,
+ type = web.Type,
+ source = web.WebSource
+ },
_ => throw new NotImplementedException("Section type not handled")
};
}