diff --git a/Manager.Framework/Manager.Framework.csproj b/Manager.Framework/Manager.Framework.csproj
deleted file mode 100644
index f28511c..0000000
--- a/Manager.Framework/Manager.Framework.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- net8.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Manager.Interfaces/Manager.Data.csproj b/Manager.Interfaces/Manager.Data.csproj
deleted file mode 100644
index bef0c91..0000000
--- a/Manager.Interfaces/Manager.Data.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- net8.0
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs
index 8f0effc..f460a96 100644
--- a/ManagerService/Controllers/ResourceController.cs
+++ b/ManagerService/Controllers/ResourceController.cs
@@ -5,8 +5,10 @@ using System.Linq;
using Manager.DTOs;
using Manager.Services;
using ManagerService.Data;
+using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using ManagerService.Helpers;
+using ManagerService.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
@@ -20,20 +22,24 @@ namespace ManagerService.Controllers
[OpenApiTag("Resource", Description = "Resource management")]
public class ResourceController : ControllerBase
{
+ private readonly MyInfoMateDbContext _myInfoMateDbContext;
+
private ResourceDatabaseService _resourceService;
private SectionDatabaseService _sectionService;
private ConfigurationDatabaseService _configurationService;
private readonly ILogger _logger;
+ IHexIdGeneratorService idService = new HexIdGeneratorService();
private static int MaxWidth = 1024;
private static int MaxHeight = 1024;
- public ResourceController(ILogger logger, ResourceDatabaseService resourceService, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService)
+ public ResourceController(ILogger logger, ResourceDatabaseService resourceService, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService, MyInfoMateDbContext myInfoMateDbContext)
{
_logger = logger;
_resourceService = resourceService;
_sectionService = sectionService;
_configurationService = configurationService;
+ _myInfoMateDbContext = myInfoMateDbContext;
}
///
@@ -50,14 +56,17 @@ namespace ManagerService.Controllers
{
if (instanceId == null)
throw new ArgumentNullException("InstanceId needed");
- List resources = new List();
+ List resources = new List();
+
if (types.Count > 0)
{
- resources = _resourceService.GetAllByType(instanceId, types);
+ resources = _myInfoMateDbContext.Resources.Where(r => r.InstanceId == instanceId && types.Contains(r.Type)).ToList();
+ //resources = _resourceService.GetAllByType(instanceId, types);
}
else
{
- resources = _resourceService.GetAll(instanceId);
+ resources = _myInfoMateDbContext.Resources.Where(r => r.InstanceId == instanceId).ToList();
+ //resources = _resourceService.GetAll(instanceId);
}
List resourceDTOs = new List();
@@ -89,7 +98,8 @@ namespace ManagerService.Controllers
{
try
{
- OldResource resource = _resourceService.GetById(id);
+ Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == id);
+ //Resource resource = _resourceService.GetById(id);
if (resource == null)
throw new KeyNotFoundException("This resource was not found");
@@ -149,7 +159,8 @@ namespace ManagerService.Controllers
{
try
{
- OldResource resource = _resourceService.GetById(id);
+ Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == id);
+ //OldResource resource = _resourceService.GetById(id);
if (resource == null)
throw new KeyNotFoundException("This resource was not found");
@@ -219,7 +230,7 @@ namespace ManagerService.Controllers
throw new ArgumentNullException("One of resource params is null");
var resourceType = (ResourceType)Enum.Parse(typeof(ResourceType), type);
- List resources = new List();
+ List resources = new List();
foreach (var file in Request.Form.Files)
{
@@ -250,13 +261,18 @@ namespace ManagerService.Controllers
throw new FileLoadException(message: "Fichier inexistant ou trop volumineux (max 4Mb)");
}
// Todo add some verification ?
- OldResource resource = new OldResource();
+ Resource resource = new Resource();
resource.Label = label;
resource.Type = resourceType;
- resource.DateCreation = DateTime.Now;
+ resource.DateCreation = DateTime.Now.ToUniversalTime();
resource.InstanceId = instanceId;
- OldResource resourceCreated = _resourceService.Create(resource);
- resources.Add(resourceCreated);
+ resource.Id = idService.GenerateHexId();
+
+ _myInfoMateDbContext.Add(resource);
+ _myInfoMateDbContext.SaveChanges();
+
+ //Resource resourceCreated = _resourceService.Create(resource);
+ resources.Add(resource);
}
}
return Ok(resources.Select(r => r.ToDTO()));
@@ -296,18 +312,21 @@ namespace ManagerService.Controllers
throw new ArgumentNullException("Resource param is null");
// Todo add some verification ?
- OldResource resource = new OldResource();
+ Resource resource = new Resource();
resource.InstanceId = newResource.instanceId;
resource.Label = newResource.label;
resource.Type = newResource.type;
resource.Url = newResource.url;
- resource.DateCreation = DateTime.Now;
+ resource.DateCreation = DateTime.Now.ToUniversalTime();
//resource.Data = newResource.data;
resource.InstanceId = newResource.instanceId;
+ resource.Id = idService.GenerateHexId();
- OldResource resourceCreated = _resourceService.Create(resource);
+ _myInfoMateDbContext.Add(resource);
+ _myInfoMateDbContext.SaveChanges();
+ //OldResource resourceCreated = _resourceService.Create(resource);
- return new OkObjectResult(resourceCreated.ToDTO()); // WITHOUT DATA
+ return new OkObjectResult(resource.ToDTO()); // WITHOUT DATA
}
catch (ArgumentNullException ex)
{
@@ -340,21 +359,24 @@ namespace ManagerService.Controllers
if (updatedResource == null)
throw new ArgumentNullException("Resource param is null");
- OldResource resource = _resourceService.GetById(updatedResource.id);
+ //OldResource resource = _resourceService.GetById(updatedResource.id);
+ Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == updatedResource.id);
if (resource == null)
throw new KeyNotFoundException("Resource does not exist");
// Todo add some verification ?
- resource.InstanceId = updatedResource.instanceId;
- resource.Label = updatedResource.label;
- resource.Type = updatedResource.type;
- resource.Url = updatedResource.url;
+ resource.InstanceId = updatedResource.instanceId != null ? updatedResource.instanceId : resource.InstanceId;
+ resource.Label = updatedResource.label != null ? updatedResource.label : resource.Label;
+ resource.Type = updatedResource.type != null ? updatedResource.type : resource.Type;
+ resource.Url = updatedResource.url != null ? updatedResource.url: resource.Url;
//resource.Data = updatedResource.data; // NOT ALLOWED
- OldResource resourceModified = _resourceService.Update(updatedResource.id, resource);
+ _myInfoMateDbContext.SaveChanges();
- return new OkObjectResult(resourceModified.ToDTO());
+ //OldResource resourceModified = _resourceService.Update(updatedResource.id, resource);
+
+ return new OkObjectResult(resource.ToDTO());
}
catch (ArgumentNullException ex)
{
@@ -387,12 +409,14 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("Resource param is null");
- var ressource = _resourceService.GetById(id);
- if (ressource == null)
+ //var ressource = _resourceService.GetById(id);
+ Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == id);
+ if (resource == null)
throw new KeyNotFoundException("Resource does not exist");
- foreach (var configuration in _configurationService.GetAll(ressource.InstanceId))
+ List configurations = _myInfoMateDbContext.Configurations.Where(c => c.InstanceId == resource.InstanceId).ToList();
+ foreach (var configuration in configurations)
{
if (configuration.ImageId == id)
{
@@ -401,9 +425,9 @@ namespace ManagerService.Controllers
}
}
-
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.InstanceId == resource.InstanceId).ToList();
// Delete all resource occurence
- foreach (var section in _sectionService.GetAll(ressource.InstanceId))
+ foreach (var section in sections)
{
if (section.ImageId == id)
{
@@ -411,39 +435,40 @@ namespace ManagerService.Controllers
section.ImageSource = null;
}
- switch (section.Type)
+ switch (section)
{
- case SectionType.Map:
- MapDTO mapDTO = JsonConvert.DeserializeObject(section.Data);
- mapDTO.iconResourceId = mapDTO.iconResourceId == id ? null : mapDTO.iconResourceId;
- foreach (var point in mapDTO.points)
+ case SectionMap map:
+ //MapDTO mapDTO = JsonConvert.DeserializeObject(section.Data);
+ map.MapResourceId = map.MapResourceId == id ? null : map.MapResourceId;
+ foreach (var point in map.MapPoints)
{
- point.imageResourceId = point.imageResourceId == id ? null : point.imageResourceId;
- foreach (var content in point.contents)
+ point.ImageResourceId = point.ImageResourceId == id ? null : point.ImageResourceId;
+ foreach (var content in point.Contents)
{
- content.resourceUrl = content.resourceId == id ? null : content.resourceUrl;
- content.resourceId = content.resourceId == id ? null : content.resourceId;
+ content.Url = content.Id == id ? null : content.Url;
+ content.Id = content.Id == id ? null : content.Id;
}
}
- foreach (var categorie in mapDTO.categories)
+ foreach (var categorie in map.MapCategories)
{
// TODO
/*categorie.iconUrl = categorie.iconResourceId == id ? null : categorie.iconUrl;
categorie.iconResourceId = categorie.iconResourceId == id ? null : categorie.iconResourceId;*/
}
- section.Data = JsonConvert.SerializeObject(mapDTO);
+ //section.Data = JsonConvert.SerializeObject(mapDTO);
break;
- case SectionType.Slider:
- SliderDTO sliderDTO = JsonConvert.DeserializeObject(section.Data);
- List contentsToKeep = new List();
- foreach (var content in sliderDTO.contents)
+ case SectionSlider slider:
+ //SliderDTO sliderDTO = JsonConvert.DeserializeObject(section.Data);
+ /*List contentsToKeep = new List();
+ foreach (var content in slider.Contents)
{
- if (content.resourceId != id)
+ if (content.ResourceId != id)
contentsToKeep.Add(content);
- }
- sliderDTO.contents = contentsToKeep;
- section.Data = JsonConvert.SerializeObject(sliderDTO);
+ }*/
+ // TODO TEST
+ slider.SliderContents = slider.SliderContents.Where(c => c.ResourceId != id).ToList();
+ //section.Data = JsonConvert.SerializeObject(sliderDTO);
break;
// TODO
/*case SectionType.Quizz:
@@ -521,23 +546,28 @@ namespace ManagerService.Controllers
}
section.Data = JsonConvert.SerializeObject(quizzDTO);
break;*/
- case SectionType.Article:
- ArticleDTO articleDTO = JsonConvert.DeserializeObject(section.Data);
- List contentsArticleToKeep = new List();
- foreach (var content in articleDTO.contents)
+ case SectionArticle article:
+ /*ArticleDTO articleDTO = JsonConvert.DeserializeObject(section.Data);
+ List contentsArticleToKeep = new List();*/
+ /*foreach (var content in article.contents)
{
if (content.resourceId != id)
contentsArticleToKeep.Add(content);
- }
- articleDTO.contents = contentsArticleToKeep;
- section.Data = JsonConvert.SerializeObject(articleDTO);
+ }*/
+ // TODO TEEEEEEEEEEESST
+ //articleDTO.contents = contentsArticleToKeep;
+ article.ArticleContents = article.ArticleContents.Where(c => c.ResourceId != id).ToList();
+ //section.Data = JsonConvert.SerializeObject(articleDTO);
break;
}
- _sectionService.Update(section.Id, section);
+ _myInfoMateDbContext.SaveChanges();
+ //_sectionService.Update(section.Id, section);
}
- _resourceService.Remove(id);
+ //_resourceService.Remove(id);
+ _myInfoMateDbContext.Remove(resource);
+ _myInfoMateDbContext.SaveChanges();
return new ObjectResult("The resource has been deleted") { StatusCode = 202 };
diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs
index 1089d03..0f8100f 100644
--- a/ManagerService/Controllers/SectionController.cs
+++ b/ManagerService/Controllers/SectionController.cs
@@ -4,6 +4,7 @@ using Manager.Services;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
+using ManagerService.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
@@ -22,17 +23,21 @@ namespace ManagerService.Controllers
[OpenApiTag("Section", Description = "Section management")]
public class SectionController : ControllerBase
{
+ private readonly MyInfoMateDbContext _myInfoMateDbContext;
+
private SectionDatabaseService _sectionService;
private ConfigurationDatabaseService _configurationService;
private readonly ILogger _logger;
private readonly IConfiguration _configuration;
+ IHexIdGeneratorService idService = new HexIdGeneratorService();
- public SectionController(IConfiguration configuration, ILogger logger, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService)
+ public SectionController(IConfiguration configuration, ILogger logger, SectionDatabaseService sectionService, ConfigurationDatabaseService configurationService, MyInfoMateDbContext myInfoMateDbContext)
{
_logger = logger;
_configuration = configuration;
_sectionService = sectionService;
_configurationService = configurationService;
+ _myInfoMateDbContext = myInfoMateDbContext;
}
///
@@ -46,7 +51,8 @@ namespace ManagerService.Controllers
{
try
{
- List sections = _sectionService.GetAll(instanceId);
+ //List sections = _sectionService.GetAll(instanceId);
+ List sections = _myInfoMateDbContext.Sections.ToList();
/* CLEAN ARTICLE AUDIO - Init new field AudioIds */
@@ -92,9 +98,12 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("Param is null");
- if (_configurationService.IsExist(id))
+ Configuration configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == id);
+
+ if (configuration != null)
{
- List sections = _sectionService.GetAllFromConfiguration(id);
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && !s.IsSubSection).ToList();
+ //List sections = _sectionService.GetAllFromConfiguration(id);
return new OkObjectResult(sections.Select(r => r.ToDTO()));
}
@@ -126,7 +135,10 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("Param is null");
- _sectionService.DeleteAllFromConfiguration(id);
+ //_sectionService.DeleteAllFromConfiguration(id);
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id).ToList();
+ // TODO test
+ _myInfoMateDbContext.RemoveRange(sections);
return new ObjectResult("All section from the specified configuration has been deleted") { StatusCode = 202 };
}
@@ -155,7 +167,8 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("Param is null");
- List sections = _sectionService.GetAllSubSection(id);
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.ParentId == id && s.IsSubSection).ToList();
+ //List sections = _sectionService.GetAllSubSection(id);
return new OkObjectResult(sections.Select(r => r.ToDTO()));
}
@@ -183,7 +196,8 @@ namespace ManagerService.Controllers
{
try
{
- OldSection section = _sectionService.GetById(id);
+ //OldSection section = _sectionService.GetById(id);
+ Section section = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == id);
if (section == null)
throw new KeyNotFoundException("This section was not found");
@@ -245,9 +259,10 @@ namespace ManagerService.Controllers
{
try
{
- List sections = _sectionService.GetAll(instanceId);
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.InstanceId == instanceId && s.IsBeacon && s.BeaconId != null).ToList();
+ //List sections = _sectionService.GetAll(instanceId);
- sections = sections.Where(s => s.IsBeacon && s.BeaconId != null).ToList();
+ //sections = sections.Where(s => s.IsBeacon && s.BeaconId != null).ToList();
return new OkObjectResult(sections.Select(s => s.ToDTO()));
}
@@ -284,37 +299,113 @@ namespace ManagerService.Controllers
throw new KeyNotFoundException("Configuration does not exist");
// Todo add some verification ?
- Section section = new Section();
- section.InstanceId = newSection.instanceId;
- section.Label = newSection.label;
- section.ImageId = newSection.imageId;
- section.ImageSource = newSection.imageSource;
- section.ConfigurationId = newSection.configurationId;
- section.DateCreation = DateTime.Now;
- section.IsSubSection = newSection.isSubSection;
- section.ParentId = newSection.parentId;
- section.Type = newSection.type;
- section.Title = new List();
- section.Description = new List();
- section.Order = _sectionService.GetAllFromConfiguration(newSection.configurationId).Count;
- section.IsBeacon = newSection.isBeacon;
- section.BeaconId = newSection.beaconId;
- section.Latitude = newSection.latitude;
- section.Longitude = newSection.longitude;
- section.MeterZoneGPS = newSection.meterZoneGPS;
+ Section section = SectionFactory.Create(newSection);
// Preparation
List languages = _configuration.GetSection("SupportedLanguages").Get>();
var contentArticle = new List();
- var mapDTO = new MapDTO(); // For menu dto
- var sliderDTO = new SliderDTO(); // For menu dto
-
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
+ {
+ MapMapType = MapTypeApp.hybrid,
+ MapTypeMapbox = MapTypeMapBox.standard,
+ MapMapProvider = MapProvider.Google,
+ MapZoom = 18,
+ MapPoints = new List(),
+ MapCategories = new List()
+ };
+ break;
+ case SectionType.Slider:
+ section = new SectionSlider
+ {
+ SliderContents = new List()
+ };
+ break;
+ case SectionType.Video:
+ section = new SectionVideo
+ {
+ VideoSource = "",
+ };
+ break;
+ case SectionType.Web:
+ section = new SectionWeb
+ {
+ WebSource = "",
+ };
+ break;
+ case SectionType.Menu:
+ section = new SectionMenu
+ {
+ MenuSections = new List(),
+ };
+ break;
+ case SectionType.Quiz:
+ section = new SectionQuiz
+ {
+ QuizQuestions = new List(),
+ // TODO levels ?
+ };
+ break;
+ case SectionType.Article:
+ section = new SectionArticle
+ {
+ ArticleContents = new List(),
+ ArticleContent = contentArticle,
+ ArticleAudioIds = LanguageInit.Init("Audio", languages, true)
+ };
+ break;
+ case SectionType.PDF:
+ section = new SectionPdf
+ {
+ PDFOrderedTranslationAndResources = []
+ };
+ break;
+ case SectionType.Puzzle:
+ section = new SectionPuzzle
+ {
+ PuzzleMessageDebut = [],
+ PuzzleMessageFin = []
+ };
+ break;
+ case SectionType.Agenda:
+ section = new SectionAgenda
+ {
+ AgendaResourceIds = new List()
+ };
+ break;
+ case SectionType.Weather:
+ section = new SectionWeather();
+ break;
+ }
+
+ section.InstanceId = newSection.instanceId;
+ section.Label = newSection.label;
+ section.ImageId = newSection.imageId;
+ section.ImageSource = newSection.imageSource;
+ section.ConfigurationId = newSection.configurationId;
+ section.DateCreation = DateTime.Now.ToUniversalTime();
+ 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.IsBeacon = newSection.isBeacon;
+ section.BeaconId = newSection.beaconId;
+ section.Latitude = newSection.latitude;
+ section.Longitude = newSection.longitude;
+ section.MeterZoneGPS = newSection.meterZoneGPS;
+
/*foreach (var language in languages)
{
TranslationDTO title = new TranslationDTO();
@@ -354,99 +445,11 @@ namespace ManagerService.Controllers
section.Title = section.Title.OrderBy(t => t.Language).ToList();
section.Description = section.Description.OrderBy(d => d.Language).ToList();
- switch (newSection.type) {
- case SectionType.Map:
- mapDTO = new MapDTO();
- mapDTO.mapType = MapTypeApp.hybrid;
- mapDTO.mapTypeMapbox = MapTypeMapBox.standard;
- mapDTO.mapProvider = MapProvider.Google;
- mapDTO.zoom = 18;
+ //_sectionService.Create(section);
+ _myInfoMateDbContext.Add(section);
+ _myInfoMateDbContext.SaveChanges();
- mapDTO.points = new List();
- mapDTO.categories = new List();
-
- //section.Data = JsonConvert.SerializeObject(mapDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Slider:
- sliderDTO = new SliderDTO();
- sliderDTO.contents = new List();
-
- //section.Data = JsonConvert.SerializeObject(sliderDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Video:
- VideoDTO videoDTO = new VideoDTO();
- videoDTO.source = "";
- //section.Data = JsonConvert.SerializeObject(videoDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Web:
- WebDTO webDTO = new WebDTO();
- webDTO.source = "";
- //section.Data = JsonConvert.SerializeObject(webDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Menu:
- MenuDTO menuDTO = new MenuDTO();
- menuDTO.sections = new List();
- /*SectionDTO section0DTO = new SectionDTO();
- section0DTO.IsSubSection = true;
- section0DTO.Label = newSection.Label;
- section0DTO.ImageId = newSection.ImageId;
- section0DTO.ConfigurationId = newSection.ConfigurationId;
- section0DTO.DateCreation = DateTime.Now;
- section0DTO.ParentId = null;
- section0DTO.Type = SectionType.Map;
- section0DTO.Data = JsonConvert.SerializeObject(mapDTO);
-
-
- SectionDTO section1DTO = new SectionDTO();
- section0DTO.IsSubSection = true;
- section0DTO.Label = newSection.Label;
- section0DTO.ImageId = newSection.ImageId;
- section0DTO.ConfigurationId = newSection.ConfigurationId;
- section0DTO.DateCreation = DateTime.Now;
- section0DTO.ParentId = null;
- section0DTO.Type = SectionType.Slider;
- section1DTO.IsSubSection = true;
- section1DTO.Data = JsonConvert.SerializeObject(sliderDTO);*/
-
- /*menuDTO.Sections.Add(section0DTO);
- menuDTO.Sections.Add(section1DTO);*/
- //section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Quizz:
- QuizDTO quizzDTO = new QuizDTO();
- quizzDTO.questions = new List();
- //section.Data = JsonConvert.SerializeObject(quizzDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Article:
- ArticleDTO articleDTO = new ArticleDTO();
- articleDTO.contents = new List();
- articleDTO.content = contentArticle.Select(c => c.ToDTO()).ToList(); // TODO check
- articleDTO.audioIds = LanguageInit.Init("Audio", languages, true).Select(c => c.ToDTO()).ToList(); // TODO check
-
- //section.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON
- break;
- case SectionType.PDF:
- PdfDTO pdfDTO = new PdfDTO();
- //section.Data = JsonConvert.SerializeObject(pdfDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Puzzle:
- PuzzleDTO puzzleDTO = new PuzzleDTO();
- //section.Data = JsonConvert.SerializeObject(puzzleDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Agenda:
- AgendaDTO agendaDTO = new AgendaDTO();
- //section.Data = JsonConvert.SerializeObject(agendaDTO); // Include all info from specific section as JSON
- break;
- case SectionType.Weather:
- WeatherDTO weatherDTO = new WeatherDTO();
- //section.Data = JsonConvert.SerializeObject(weatherDTO); // Include all info from specific section as JSON
- break;
- }
-
- // TODO
- OldSection sectionCreated = new OldSection();//_sectionService.Create(section);
-
- return new OkObjectResult(sectionCreated.ToDTO());
+ return new OkObjectResult(section.ToDTO());
}
catch (ArgumentNullException ex)
{
@@ -530,11 +533,17 @@ namespace ManagerService.Controllers
if (updatedSection == null)
throw new ArgumentNullException("Section param is null");
- OldSection section = _sectionService.GetById(updatedSection.id);
+ //OldSection section = _sectionService.GetById(updatedSection.id);
+ Section existingSection = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == updatedSection.id);
- if (section == null)
+ if (existingSection == null)
throw new KeyNotFoundException("Section does not exist");
+ if (existingSection.Type != updatedSection.type)
+ return BadRequest("Type mismatch: cannot change section type");
+
+ var updatedSectionDB = SectionFactory.Create(updatedSection);
+
// Todo add some verification ?
/*section.InstanceId = updatedSection.instanceId;
section.Label = updatedSection.label;
@@ -546,20 +555,41 @@ namespace ManagerService.Controllers
section.ConfigurationId = updatedSection.configurationId;
section.IsSubSection = updatedSection.isSubSection;
section.ParentId = updatedSection.parentId;
- section.Data = updatedSection.data;
+ //section.Data = updatedSection.data;
section.IsBeacon = updatedSection.isBeacon;
section.BeaconId = updatedSection.beaconId;
section.Latitude = updatedSection.latitude;
section.Longitude = updatedSection.longitude;
- section.MeterZoneGPS = updatedSection.meterZoneGPS;
+ section.MeterZoneGPS = updatedSection.meterZoneGPS;*/
- Section sectionModified = _sectionService.Update(updatedSection.id, section);*/
- // todo
- Section sectionModified = new Section();
+ switch (updatedSectionDB)
+ {
+ case SectionMap map:
+ // TODO specific
- MqttClientService.PublishMessage($"config/{sectionModified.ConfigurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
+ /*map.Categories = [];
+ map.Points = [];*/
- return new OkObjectResult(sectionModified.ToDTO());
+ //weather.Latitude = updatedSection.latitude;
+ break;
+
+ case SectionMenu menu:
+ //menu.Sections = new List();
+ break;
+
+ case SectionQuiz quiz:
+ quiz.QuizQuestions = [];
+ break;
+
+ // Ajoute d'autres types ici
+ }
+ _myInfoMateDbContext.Entry(existingSection).CurrentValues.SetValues(updatedSection);
+ _myInfoMateDbContext.SaveChanges();
+ //Section sectionModified = _sectionService.Update(updatedSection.id, section);
+
+ MqttClientService.PublishMessage($"config/{existingSection.ConfigurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
+
+ return new OkObjectResult(updatedSectionDB.ToDTO());
}
catch (ArgumentNullException ex)
{
@@ -586,6 +616,7 @@ namespace ManagerService.Controllers
[HttpPut("order")]
public ObjectResult UpdateOrder([FromBody] List updatedSectionsOrder)
{
+ // TODO REWRITE LOGIC..
try
{
if (updatedSectionsOrder == null)
@@ -593,16 +624,19 @@ namespace ManagerService.Controllers
foreach (var section in updatedSectionsOrder)
{
- if (!_sectionService.IsExist(section.id))
+ var sectionDB = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == section.id);
+ if (sectionDB == null)
throw new KeyNotFoundException($"Section {section.label} with id {section.id} does not exist");
}
foreach (var updatedSection in updatedSectionsOrder)
{
- OldSection section = _sectionService.GetById(updatedSection.id);
+ var section = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == updatedSection.id);
+ //OldSection section = _sectionService.GetById(updatedSection.id);
section.Order = updatedSection.order.GetValueOrDefault();
+ _myInfoMateDbContext.SaveChanges();
- _sectionService.Update(section.Id, section);
+ //_sectionService.Update(section.Id, section);
}
if (updatedSectionsOrder.Count > 0) {
@@ -642,10 +676,23 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("Section param is null");
- if (!_sectionService.IsExist(id))
+ var section = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == id);
+ if (section == null)
throw new KeyNotFoundException("Section does not exist");
- _sectionService.Remove(id);
+ _myInfoMateDbContext.Remove(section);
+ //_sectionService.Remove(id);
+
+ // update order from rest // TODO TEST
+ List sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection).ToList();
+ int i = 1;
+ foreach (var sectionDb in sections.OrderBy(s => s.Order))
+ {
+ sectionDb.Order = i;
+ i++;
+ }
+
+ _myInfoMateDbContext.SaveChanges();
return new ObjectResult("The section has been deleted") { StatusCode = 202 };
diff --git a/ManagerService/DTOs/SectionType.cs b/ManagerService/DTOs/SectionType.cs
index e1b0b27..fc4cbb0 100644
--- a/ManagerService/DTOs/SectionType.cs
+++ b/ManagerService/DTOs/SectionType.cs
@@ -7,7 +7,7 @@
Video,
Web,
Menu,
- Quizz,
+ Quiz,
Article,
PDF,
Puzzle,
diff --git a/ManagerService/DTOs/SubSection/AgendaDTO.cs b/ManagerService/DTOs/SubSection/AgendaDTO.cs
index 201702b..1bd1f3c 100644
--- a/ManagerService/DTOs/SubSection/AgendaDTO.cs
+++ b/ManagerService/DTOs/SubSection/AgendaDTO.cs
@@ -6,6 +6,6 @@ namespace Manager.DTOs
public class AgendaDTO : SectionDTO
{
public List resourceIds { get; set; } // All json files for all languages
- public MapProvider? mapProvider { get; set; } // Default = Google
+ public MapProvider? agendaMapProvider { get; set; } // Default = Google
}
}
diff --git a/ManagerService/DTOs/SubSection/MapDTO.cs b/ManagerService/DTOs/SubSection/MapDTO.cs
index d123642..fadd556 100644
--- a/ManagerService/DTOs/SubSection/MapDTO.cs
+++ b/ManagerService/DTOs/SubSection/MapDTO.cs
@@ -1,5 +1,4 @@
-using Manager.Interfaces.Models;
-using ManagerService.Data;
+using ManagerService.Data;
using ManagerService.DTOs;
using System.Collections.Generic;
diff --git a/ManagerService/DTOs/SubSection/PuzzleDTO.cs b/ManagerService/DTOs/SubSection/PuzzleDTO.cs
index dd28d95..9c94ab9 100644
--- a/ManagerService/DTOs/SubSection/PuzzleDTO.cs
+++ b/ManagerService/DTOs/SubSection/PuzzleDTO.cs
@@ -7,7 +7,8 @@ namespace Manager.DTOs
{
public List messageDebut { get; set; }
public List messageFin { get; set; }
- public ContentDTO image { get; set; } // But only image is possible
+ public ResourceDTO puzzleImage { get; set; } // But only image is possible
+ public string puzzleImageId { get; set; } // But only image is possible
public int rows { get; set; } = 3;
public int cols { get; set; } = 3;
}
diff --git a/ManagerService/DTOs/SubSection/QuizzDTO.cs b/ManagerService/DTOs/SubSection/QuizzDTO.cs
index 017fa06..37c1123 100644
--- a/ManagerService/DTOs/SubSection/QuizzDTO.cs
+++ b/ManagerService/DTOs/SubSection/QuizzDTO.cs
@@ -7,10 +7,10 @@ namespace Manager.DTOs
public class QuizDTO : SectionDTO
{
public List questions { get; set; }
- public LevelDTO bad_level { get; set; }
- public LevelDTO medium_level { get; set; }
- public LevelDTO good_level { get; set; }
- public LevelDTO great_level { get; set; }
+ public List bad_level { get; set; }
+ public List medium_level { get; set; }
+ public List good_level { get; set; }
+ public List great_level { get; set; }
}
public class QuestionDTO
diff --git a/ManagerService/Data/SubSection/SectionAgenda.cs b/ManagerService/Data/SubSection/SectionAgenda.cs
index 268af6d..f0df0d2 100644
--- a/ManagerService/Data/SubSection/SectionAgenda.cs
+++ b/ManagerService/Data/SubSection/SectionAgenda.cs
@@ -16,9 +16,9 @@ namespace ManagerService.Data.SubSection
{
[Required]
[Column(TypeName = "jsonb")]
- public List resourceIds { get; set; } // All json files for all languages
+ public List AgendaResourceIds { get; set; } // All json files for all languages
- public MapProvider? mapProvider { get; set; } // Default = Google
+ public MapProvider? AgendaMapProvider { get; set; } // Default = Google
public AgendaDTO ToDTO()
{
@@ -42,8 +42,8 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- resourceIds = resourceIds.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
- mapProvider = mapProvider
+ resourceIds = AgendaResourceIds.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
+ agendaMapProvider = AgendaMapProvider
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionArticle.cs b/ManagerService/Data/SubSection/SectionArticle.cs
index b581226..d74f61c 100644
--- a/ManagerService/Data/SubSection/SectionArticle.cs
+++ b/ManagerService/Data/SubSection/SectionArticle.cs
@@ -16,18 +16,18 @@ namespace ManagerService.Data.SubSection
{
[Required]
[Column(TypeName = "jsonb")]
- public List content { get; set; }
+ public List ArticleContent { get; set; }
- public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise
+ public bool ArticleIsContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise
[Required]
[Column(TypeName = "jsonb")]
- public List audioIds { get; set; }
+ public List ArticleAudioIds { get; set; }
- public bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise
+ public bool ArticleIsReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise
[Required]
- public List contents { get; set; }
+ public List ArticleContents { get; set; }
public ArticleDTO ToDTO()
{
@@ -51,11 +51,11 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- content = content.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
- isContentTop = isContentTop,
- audioIds = audioIds.Select(a=> a.ToDTO()).ToList(),
- isReadAudioAuto = isReadAudioAuto,
- contents = contents.Select(c => c.ToDTO()).ToList(),
+ content = ArticleContent.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
+ isContentTop = ArticleIsContentTop,
+ audioIds = ArticleAudioIds.Select(a=> a.ToDTO()).ToList(),
+ isReadAudioAuto = ArticleIsReadAudioAuto,
+ contents = ArticleContents.Select(c => c.ToDTO()).ToList(),
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionMap.cs b/ManagerService/Data/SubSection/SectionMap.cs
index f256b10..fc5e7dd 100644
--- a/ManagerService/Data/SubSection/SectionMap.cs
+++ b/ManagerService/Data/SubSection/SectionMap.cs
@@ -14,16 +14,16 @@ namespace ManagerService.Data.SubSection
///
public class SectionMap : Section
{
- public int Zoom { get; set; } // Default = 18
- public MapTypeApp? MapType { get; set; } // Default = Hybrid for Google
+ public int MapZoom { get; set; } // Default = 18
+ public MapTypeApp? MapMapType { get; set; } // Default = Hybrid for Google
public MapTypeMapBox? MapTypeMapbox { get; set; } // Default = standard for MapBox
- public MapProvider? MapProvider { get; set; } // Default = Google
- public List Points { get; set; }
- public string ResourceId { get; set; }
- public Resource Resource { get; set; } // Icon
- public List Categories { get; set; }
- public string CenterLatitude { get; set; } // Center on
- public string CenterLongitude { get; set; } // Center on
+ public MapProvider? MapMapProvider { get; set; } // Default = Google
+ public List MapPoints { get; set; }
+ public string MapResourceId { get; set; }
+ public Resource MapResource { get; set; } // Icon
+ public List MapCategories { get; set; }
+ public string MapCenterLatitude { get; set; } // Center on
+ public string MapCenterLongitude { get; set; } // Center on
public MapDTO ToDTO()
@@ -48,15 +48,15 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- zoom = Zoom,
- mapType = MapType,
+ zoom = MapZoom,
+ mapType = MapMapType,
mapTypeMapbox = MapTypeMapbox,
- mapProvider = MapProvider,
+ mapProvider = MapMapProvider,
//points = Points.Select(p => p.ToDTO()).ToList(), // TODO
- iconResourceId = ResourceId,
- categories = Categories.Select(c => c.ToDTO()).ToList(),
- centerLatitude = CenterLatitude,
- centerLongitude = CenterLongitude
+ iconResourceId = MapResourceId,
+ categories = MapCategories.Select(c => c.ToDTO()).ToList(),
+ centerLatitude = MapCenterLatitude,
+ centerLongitude = MapCenterLongitude
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionMenu.cs b/ManagerService/Data/SubSection/SectionMenu.cs
index ef06735..328a7b6 100644
--- a/ManagerService/Data/SubSection/SectionMenu.cs
+++ b/ManagerService/Data/SubSection/SectionMenu.cs
@@ -15,7 +15,7 @@ namespace ManagerService.Data.SubSection
public class SectionMenu : Section
{
[Required]
- public List Sections { get; set; } // All json files for all languages
+ public List MenuSections { get; set; } // All json files for all languages
public MenuDTO ToDTO()
{
@@ -39,7 +39,7 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- sections = Sections.Select(s => s.ToDTO()).ToList()
+ sections = MenuSections.Select(s => s.ToDTO()).ToList()
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionPdf.cs b/ManagerService/Data/SubSection/SectionPdf.cs
index 9c8ce8b..da76d08 100644
--- a/ManagerService/Data/SubSection/SectionPdf.cs
+++ b/ManagerService/Data/SubSection/SectionPdf.cs
@@ -12,7 +12,7 @@ namespace ManagerService.Data.SubSection
public class SectionPdf : Section
{
[Required]
- public List orderedTranslationAndResources { get; set; } // All json files for all languages
+ public List PDFOrderedTranslationAndResources { get; set; } // All json files for all languages
public PdfDTO ToDTO()
{
@@ -36,7 +36,7 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- pdfs = orderedTranslationAndResources.Select(otar => otar.ToDTO()).ToList()
+ pdfs = PDFOrderedTranslationAndResources.Select(otar => otar.ToDTO()).ToList()
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionPuzzle.cs b/ManagerService/Data/SubSection/SectionPuzzle.cs
index 122bd80..89aaf94 100644
--- a/ManagerService/Data/SubSection/SectionPuzzle.cs
+++ b/ManagerService/Data/SubSection/SectionPuzzle.cs
@@ -16,20 +16,20 @@ namespace ManagerService.Data.SubSection
{
[Required]
[Column(TypeName = "jsonb")]
- public List MessageDebut { get; set; }
+ public List PuzzleMessageDebut { get; set; }
[Required]
[Column(TypeName = "jsonb")]
- public List MessageFin { get; set; }
+ public List PuzzleMessageFin { get; set; }
- public string ContentId { get; set; } // But only image is possible
- public Content Content { get; set; } // But only image is possible
+ public string PuzzleImageId { get; set; } // But only image is possible
+ public Resource PuzzleImage { get; set; } // But only image is possible
[Required]
- public int Rows { get; set; } = 3;
+ public int PuzzleRows { get; set; } = 3;
[Required]
- public int Cols { get; set; } = 3;
+ public int PuzzleCols { get; set; } = 3;
public PuzzleDTO ToDTO()
@@ -54,11 +54,12 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- messageDebut = MessageDebut.Select(md => md.ToDTO()).ToList(),
- messageFin = MessageFin.Select(mf => mf.ToDTO()).ToList(),
- image = Content.ToDTO(),
- rows = Rows,
- cols = Cols
+ messageDebut = PuzzleMessageDebut.Select(md => md.ToDTO()).ToList(),
+ messageFin = PuzzleMessageFin.Select(mf => mf.ToDTO()).ToList(),
+ puzzleImage = PuzzleImage.ToDTO(),
+ puzzleImageId = PuzzleImageId,
+ rows = PuzzleRows,
+ cols = PuzzleCols
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionQuiz.cs b/ManagerService/Data/SubSection/SectionQuiz.cs
index 57fec6d..24b540b 100644
--- a/ManagerService/Data/SubSection/SectionQuiz.cs
+++ b/ManagerService/Data/SubSection/SectionQuiz.cs
@@ -15,23 +15,23 @@ namespace ManagerService.Data.SubSection
public class SectionQuiz : Section
{
[Required]
- public List Questions { get; set; }
+ public List QuizQuestions { get; set; }
[Required]
[Column(TypeName = "jsonb")]
- public List BadLevel { get; set; }
+ public List QuizBadLevel { get; set; }
[Required]
[Column(TypeName = "jsonb")]
- public List MediumLevel { get; set; }
+ public List QuizMediumLevel { get; set; }
[Required]
[Column(TypeName = "jsonb")]
- public List GoodLevel { get; set; }
+ public List QuizGoodLevel { get; set; }
[Required]
[Column(TypeName = "jsonb")]
- public List GreatLevel { get; set; }
+ public List QuizGreatLevel { get; set; }
public QuizDTO ToDTO()
diff --git a/ManagerService/Data/SubSection/SectionSlider.cs b/ManagerService/Data/SubSection/SectionSlider.cs
index 05516f3..06e7ea5 100644
--- a/ManagerService/Data/SubSection/SectionSlider.cs
+++ b/ManagerService/Data/SubSection/SectionSlider.cs
@@ -15,7 +15,7 @@ namespace ManagerService.Data.SubSection
public class SectionSlider : Section
{
[Required]
- public List Contents { get; set; } // TODO check
+ public List SliderContents { get; set; } // TODO check
public SliderDTO ToDTO()
{
@@ -39,7 +39,7 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- contents = Contents.Select(c => c.ToDTO()).ToList(),
+ contents = SliderContents.Select(c => c.ToDTO()).ToList(),
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionVideo.cs b/ManagerService/Data/SubSection/SectionVideo.cs
index cea93b2..ed793c8 100644
--- a/ManagerService/Data/SubSection/SectionVideo.cs
+++ b/ManagerService/Data/SubSection/SectionVideo.cs
@@ -10,7 +10,7 @@ namespace ManagerService.Data.SubSection
public class SectionVideo : Section
{
[Required]
- public string Source { get; set; } // url to resource id (local) or on internet
+ public string VideoSource { get; set; } // url to resource id (local) or on internet
public VideoDTO ToDTO()
{
@@ -34,7 +34,7 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- source = Source
+ source = VideoSource
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionWeather.cs b/ManagerService/Data/SubSection/SectionWeather.cs
index 36f0839..8f9e0f2 100644
--- a/ManagerService/Data/SubSection/SectionWeather.cs
+++ b/ManagerService/Data/SubSection/SectionWeather.cs
@@ -14,11 +14,11 @@ namespace ManagerService.Data.SubSection
///
public class SectionWeather : Section
{
- public string City { get; set; } // Weather City
+ public string WeatherCity { get; set; } // Weather City
- public DateTimeOffset? UpdatedDate { get; set; } // Weather date update (to only refresh)
+ public DateTimeOffset? WeatherUpdatedDate { get; set; } // Weather date update (to only refresh)
- public string Result { get; set; } // Weather result
+ public string WeatherResult { get; set; } // Weather result
public WeatherDTO ToDTO()
{
@@ -42,9 +42,9 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- city = City,
- updatedDate = UpdatedDate,
- result = Result,
+ city = WeatherCity,
+ updatedDate = WeatherUpdatedDate,
+ result = WeatherResult,
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionWeb.cs b/ManagerService/Data/SubSection/SectionWeb.cs
index 73c64b1..68e60ec 100644
--- a/ManagerService/Data/SubSection/SectionWeb.cs
+++ b/ManagerService/Data/SubSection/SectionWeb.cs
@@ -11,7 +11,7 @@ namespace ManagerService.Data.SubSection
public class SectionWeb : Section
{
[Required]
- public string Source { get; set; } // url to resource id (local) or on internet
+ public string WebSource { get; set; } // url to resource id (local) or on internet
public WebDTO ToDTO()
{
@@ -35,7 +35,7 @@ namespace ManagerService.Data.SubSection
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
- source = Source
+ source = WebSource
};
}
}
diff --git a/ManagerService/Migrations/20250320151926_UpdateMix.Designer.cs b/ManagerService/Migrations/20250320151926_UpdateMix.Designer.cs
new file mode 100644
index 0000000..8d6dcd3
--- /dev/null
+++ b/ManagerService/Migrations/20250320151926_UpdateMix.Designer.cs
@@ -0,0 +1,817 @@
+//
+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("20250320151926_UpdateMix")]
+ partial class UpdateMix
+ {
+ ///
+ 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")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ImageSource")
+ .IsRequired()
+ .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/20250320151926_UpdateMix.cs b/ManagerService/Migrations/20250320151926_UpdateMix.cs
new file mode 100644
index 0000000..4497eb7
--- /dev/null
+++ b/ManagerService/Migrations/20250320151926_UpdateMix.cs
@@ -0,0 +1,368 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace ManagerService.Migrations
+{
+ ///
+ public partial class UpdateMix : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Sections_Content_ContentId1",
+ table: "Sections");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Sections_Resources_ResourceId",
+ table: "Sections");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Sections_ContentId1",
+ table: "Sections");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Sections_ResourceId",
+ table: "Sections");
+
+ migrationBuilder.DropColumn(
+ name: "Cols",
+ table: "Sections");
+
+ migrationBuilder.RenameColumn(
+ name: "resourceIds",
+ table: "Sections",
+ newName: "QuizMediumLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "mapProvider",
+ table: "Sections",
+ newName: "PuzzleRows");
+
+ migrationBuilder.RenameColumn(
+ name: "isReadAudioAuto",
+ table: "Sections",
+ newName: "ArticleIsReadAudioAuto");
+
+ migrationBuilder.RenameColumn(
+ name: "isContentTop",
+ table: "Sections",
+ newName: "ArticleIsContentTop");
+
+ migrationBuilder.RenameColumn(
+ name: "content",
+ table: "Sections",
+ newName: "QuizGreatLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "audioIds",
+ table: "Sections",
+ newName: "QuizGoodLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "Zoom",
+ table: "Sections",
+ newName: "PuzzleCols");
+
+ migrationBuilder.RenameColumn(
+ name: "UpdatedDate",
+ table: "Sections",
+ newName: "WeatherUpdatedDate");
+
+ migrationBuilder.RenameColumn(
+ name: "Source",
+ table: "Sections",
+ newName: "WebSource");
+
+ migrationBuilder.RenameColumn(
+ name: "SectionWeb_Source",
+ table: "Sections",
+ newName: "WeatherResult");
+
+ migrationBuilder.RenameColumn(
+ name: "Rows",
+ table: "Sections",
+ newName: "MapZoom");
+
+ migrationBuilder.RenameColumn(
+ name: "Result",
+ table: "Sections",
+ newName: "WeatherCity");
+
+ migrationBuilder.RenameColumn(
+ name: "ResourceId",
+ table: "Sections",
+ newName: "VideoSource");
+
+ migrationBuilder.RenameColumn(
+ name: "MessageFin",
+ table: "Sections",
+ newName: "QuizBadLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "MessageDebut",
+ table: "Sections",
+ newName: "PuzzleMessageFin");
+
+ migrationBuilder.RenameColumn(
+ name: "MediumLevel",
+ table: "Sections",
+ newName: "PuzzleMessageDebut");
+
+ migrationBuilder.RenameColumn(
+ name: "MapType",
+ table: "Sections",
+ newName: "MapMapType");
+
+ migrationBuilder.RenameColumn(
+ name: "MapProvider",
+ table: "Sections",
+ newName: "MapMapProvider");
+
+ migrationBuilder.RenameColumn(
+ name: "GreatLevel",
+ table: "Sections",
+ newName: "ArticleContent");
+
+ migrationBuilder.RenameColumn(
+ name: "GoodLevel",
+ table: "Sections",
+ newName: "ArticleAudioIds");
+
+ migrationBuilder.RenameColumn(
+ name: "ContentId1",
+ table: "Sections",
+ newName: "AgendaMapProvider");
+
+ migrationBuilder.RenameColumn(
+ name: "ContentId",
+ table: "Sections",
+ newName: "PuzzleImageId");
+
+ migrationBuilder.RenameColumn(
+ name: "City",
+ table: "Sections",
+ newName: "MapResourceId");
+
+ migrationBuilder.RenameColumn(
+ name: "CenterLongitude",
+ table: "Sections",
+ newName: "MapCenterLongitude");
+
+ migrationBuilder.RenameColumn(
+ name: "CenterLatitude",
+ table: "Sections",
+ newName: "MapCenterLatitude");
+
+ migrationBuilder.RenameColumn(
+ name: "BadLevel",
+ table: "Sections",
+ newName: "AgendaResourceIds");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Sections_MapResourceId",
+ table: "Sections",
+ column: "MapResourceId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Sections_PuzzleImageId",
+ table: "Sections",
+ column: "PuzzleImageId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Sections_Resources_MapResourceId",
+ table: "Sections",
+ column: "MapResourceId",
+ principalTable: "Resources",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Sections_Resources_PuzzleImageId",
+ table: "Sections",
+ column: "PuzzleImageId",
+ principalTable: "Resources",
+ principalColumn: "Id");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Sections_Resources_MapResourceId",
+ table: "Sections");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Sections_Resources_PuzzleImageId",
+ table: "Sections");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Sections_MapResourceId",
+ table: "Sections");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Sections_PuzzleImageId",
+ table: "Sections");
+
+ migrationBuilder.RenameColumn(
+ name: "WebSource",
+ table: "Sections",
+ newName: "Source");
+
+ migrationBuilder.RenameColumn(
+ name: "WeatherUpdatedDate",
+ table: "Sections",
+ newName: "UpdatedDate");
+
+ migrationBuilder.RenameColumn(
+ name: "WeatherResult",
+ table: "Sections",
+ newName: "SectionWeb_Source");
+
+ migrationBuilder.RenameColumn(
+ name: "WeatherCity",
+ table: "Sections",
+ newName: "Result");
+
+ migrationBuilder.RenameColumn(
+ name: "VideoSource",
+ table: "Sections",
+ newName: "ResourceId");
+
+ migrationBuilder.RenameColumn(
+ name: "QuizMediumLevel",
+ table: "Sections",
+ newName: "resourceIds");
+
+ migrationBuilder.RenameColumn(
+ name: "QuizGreatLevel",
+ table: "Sections",
+ newName: "content");
+
+ migrationBuilder.RenameColumn(
+ name: "QuizGoodLevel",
+ table: "Sections",
+ newName: "audioIds");
+
+ migrationBuilder.RenameColumn(
+ name: "QuizBadLevel",
+ table: "Sections",
+ newName: "MessageFin");
+
+ migrationBuilder.RenameColumn(
+ name: "PuzzleRows",
+ table: "Sections",
+ newName: "mapProvider");
+
+ migrationBuilder.RenameColumn(
+ name: "PuzzleMessageFin",
+ table: "Sections",
+ newName: "MessageDebut");
+
+ migrationBuilder.RenameColumn(
+ name: "PuzzleMessageDebut",
+ table: "Sections",
+ newName: "MediumLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "PuzzleImageId",
+ table: "Sections",
+ newName: "ContentId");
+
+ migrationBuilder.RenameColumn(
+ name: "PuzzleCols",
+ table: "Sections",
+ newName: "Zoom");
+
+ migrationBuilder.RenameColumn(
+ name: "MapZoom",
+ table: "Sections",
+ newName: "Rows");
+
+ migrationBuilder.RenameColumn(
+ name: "MapResourceId",
+ table: "Sections",
+ newName: "City");
+
+ migrationBuilder.RenameColumn(
+ name: "MapMapType",
+ table: "Sections",
+ newName: "MapType");
+
+ migrationBuilder.RenameColumn(
+ name: "MapMapProvider",
+ table: "Sections",
+ newName: "MapProvider");
+
+ migrationBuilder.RenameColumn(
+ name: "MapCenterLongitude",
+ table: "Sections",
+ newName: "CenterLongitude");
+
+ migrationBuilder.RenameColumn(
+ name: "MapCenterLatitude",
+ table: "Sections",
+ newName: "CenterLatitude");
+
+ migrationBuilder.RenameColumn(
+ name: "ArticleIsReadAudioAuto",
+ table: "Sections",
+ newName: "isReadAudioAuto");
+
+ migrationBuilder.RenameColumn(
+ name: "ArticleIsContentTop",
+ table: "Sections",
+ newName: "isContentTop");
+
+ migrationBuilder.RenameColumn(
+ name: "ArticleContent",
+ table: "Sections",
+ newName: "GreatLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "ArticleAudioIds",
+ table: "Sections",
+ newName: "GoodLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "AgendaResourceIds",
+ table: "Sections",
+ newName: "BadLevel");
+
+ migrationBuilder.RenameColumn(
+ name: "AgendaMapProvider",
+ table: "Sections",
+ newName: "ContentId1");
+
+ migrationBuilder.AddColumn(
+ name: "Cols",
+ table: "Sections",
+ type: "integer",
+ nullable: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Sections_ContentId1",
+ table: "Sections",
+ column: "ContentId1");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Sections_ResourceId",
+ table: "Sections",
+ column: "ResourceId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Sections_Content_ContentId1",
+ table: "Sections",
+ column: "ContentId1",
+ principalTable: "Content",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Sections_Resources_ResourceId",
+ table: "Sections",
+ column: "ResourceId",
+ principalTable: "Resources",
+ principalColumn: "Id");
+ }
+ }
+}
diff --git a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs
index 0aa7f3e..c3dd844 100644
--- a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs
+++ b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs
@@ -515,10 +515,10 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property("mapProvider")
+ b.Property("AgendaMapProvider")
.HasColumnType("integer");
- b.Property>("resourceIds")
+ b.Property>("AgendaResourceIds")
.IsRequired()
.HasColumnType("jsonb");
@@ -529,18 +529,18 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property>("audioIds")
+ b.Property>("ArticleAudioIds")
.IsRequired()
.HasColumnType("jsonb");
- b.Property>("content")
+ b.Property>("ArticleContent")
.IsRequired()
.HasColumnType("jsonb");
- b.Property("isContentTop")
+ b.Property("ArticleIsContentTop")
.HasColumnType("boolean");
- b.Property("isReadAudioAuto")
+ b.Property("ArticleIsReadAudioAuto")
.HasColumnType("boolean");
b.HasDiscriminator().HasValue("Article");
@@ -550,28 +550,28 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property("CenterLatitude")
+ b.Property("MapCenterLatitude")
.HasColumnType("text");
- b.Property("CenterLongitude")
+ b.Property("MapCenterLongitude")
.HasColumnType("text");
- b.Property("MapProvider")
+ b.Property("MapMapProvider")
.HasColumnType("integer");
- b.Property("MapType")
+ b.Property("MapMapType")
.HasColumnType("integer");
+ b.Property("MapResourceId")
+ .HasColumnType("text");
+
b.Property("MapTypeMapbox")
.HasColumnType("integer");
- b.Property("ResourceId")
- .HasColumnType("text");
-
- b.Property("Zoom")
+ b.Property("MapZoom")
.HasColumnType("integer");
- b.HasIndex("ResourceId");
+ b.HasIndex("MapResourceId");
b.HasDiscriminator().HasValue("Map");
});
@@ -594,27 +594,24 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property("Cols")
+ b.Property("PuzzleCols")
.HasColumnType("integer");
- b.Property("ContentId")
+ b.Property("PuzzleImageId")
.HasColumnType("text");
- b.Property("ContentId1")
- .HasColumnType("integer");
-
- b.Property>("MessageDebut")
+ b.Property>("PuzzleMessageDebut")
.IsRequired()
.HasColumnType("jsonb");
- b.Property>("MessageFin")
+ b.Property>("PuzzleMessageFin")
.IsRequired()
.HasColumnType("jsonb");
- b.Property("Rows")
+ b.Property("PuzzleRows")
.HasColumnType("integer");
- b.HasIndex("ContentId1");
+ b.HasIndex("PuzzleImageId");
b.HasDiscriminator().HasValue("Puzzle");
});
@@ -623,19 +620,19 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property>("BadLevel")
+ b.Property>("QuizBadLevel")
.IsRequired()
.HasColumnType("jsonb");
- b.Property>("GoodLevel")
+ b.Property>("QuizGoodLevel")
.IsRequired()
.HasColumnType("jsonb");
- b.Property>("GreatLevel")
+ b.Property>("QuizGreatLevel")
.IsRequired()
.HasColumnType("jsonb");
- b.Property>("MediumLevel")
+ b.Property>("QuizMediumLevel")
.IsRequired()
.HasColumnType("jsonb");
@@ -653,7 +650,7 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property("Source")
+ b.Property("VideoSource")
.IsRequired()
.HasColumnType("text");
@@ -664,13 +661,13 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property("City")
+ b.Property("WeatherCity")
.HasColumnType("text");
- b.Property("Result")
+ b.Property("WeatherResult")
.HasColumnType("text");
- b.Property("UpdatedDate")
+ b.Property("WeatherUpdatedDate")
.HasColumnType("timestamp with time zone");
b.HasDiscriminator().HasValue("Weather");
@@ -680,16 +677,10 @@ namespace ManagerService.Migrations
{
b.HasBaseType("ManagerService.Data.Section");
- b.Property("Source")
+ b.Property("WebSource")
.IsRequired()
.HasColumnType("text");
- b.ToTable("Sections", t =>
- {
- t.Property("Source")
- .HasColumnName("SectionWeb_Source");
- });
-
b.HasDiscriminator().HasValue("Web");
});
@@ -707,7 +698,7 @@ namespace ManagerService.Migrations
modelBuilder.Entity("ManagerService.Data.Section", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionMenu", null)
- .WithMany("Sections")
+ .WithMany("MenuSections")
.HasForeignKey("SectionMenuId");
});
@@ -718,7 +709,7 @@ namespace ManagerService.Migrations
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
- .WithMany("Categories")
+ .WithMany("MapCategories")
.HasForeignKey("SectionMapId");
b.Navigation("Resource");
@@ -731,11 +722,11 @@ namespace ManagerService.Migrations
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionArticle", null)
- .WithMany("contents")
+ .WithMany("ArticleContents")
.HasForeignKey("SectionArticleId");
b.HasOne("ManagerService.Data.SubSection.SectionSlider", null)
- .WithMany("Contents")
+ .WithMany("SliderContents")
.HasForeignKey("SectionSliderId");
b.Navigation("Resource");
@@ -744,14 +735,14 @@ namespace ManagerService.Migrations
modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
- .WithMany("Points")
+ .WithMany("MapPoints")
.HasForeignKey("SectionMapId");
});
modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionPdf", null)
- .WithMany("orderedTranslationAndResources")
+ .WithMany("PDFOrderedTranslationAndResources")
.HasForeignKey("SectionPdfId");
});
@@ -762,7 +753,7 @@ namespace ManagerService.Migrations
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionQuiz", null)
- .WithMany("Questions")
+ .WithMany("QuizQuestions")
.HasForeignKey("SectionQuizId");
b.Navigation("Resource");
@@ -770,52 +761,52 @@ namespace ManagerService.Migrations
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
- b.HasOne("ManagerService.Data.Resource", "Resource")
+ b.HasOne("ManagerService.Data.Resource", "MapResource")
.WithMany()
- .HasForeignKey("ResourceId");
+ .HasForeignKey("MapResourceId");
- b.Navigation("Resource");
+ b.Navigation("MapResource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
{
- b.HasOne("ManagerService.Data.SubSection.Content", "Content")
+ b.HasOne("ManagerService.Data.Resource", "PuzzleImage")
.WithMany()
- .HasForeignKey("ContentId1");
+ .HasForeignKey("PuzzleImageId");
- b.Navigation("Content");
+ b.Navigation("PuzzleImage");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b =>
{
- b.Navigation("contents");
+ b.Navigation("ArticleContents");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
- b.Navigation("Categories");
+ b.Navigation("MapCategories");
- b.Navigation("Points");
+ b.Navigation("MapPoints");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b =>
{
- b.Navigation("Sections");
+ b.Navigation("MenuSections");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b =>
{
- b.Navigation("orderedTranslationAndResources");
+ b.Navigation("PDFOrderedTranslationAndResources");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
{
- b.Navigation("Questions");
+ b.Navigation("QuizQuestions");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b =>
{
- b.Navigation("Contents");
+ b.Navigation("SliderContents");
});
#pragma warning restore 612, 618
}
diff --git a/ManagerService/Services/SectionFactory.cs b/ManagerService/Services/SectionFactory.cs
new file mode 100644
index 0000000..3ab181c
--- /dev/null
+++ b/ManagerService/Services/SectionFactory.cs
@@ -0,0 +1,255 @@
+using Manager.DTOs;
+using ManagerService.Data;
+using ManagerService.Data.SubSection;
+using ManagerService.DTOs;
+using System;
+using System.Linq;
+
+namespace ManagerService.Services
+{
+ public static class SectionFactory
+ {
+ public static Section Create(SectionDTO dto)
+ {
+ return dto.type switch
+ {
+ SectionType.Agenda => new SectionAgenda
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ AgendaResourceIds = ((AgendaDTO)dto).resourceIds.Select(r => new Translation().FromDTO(r)).ToList(),
+ AgendaMapProvider = ((AgendaDTO)dto).agendaMapProvider
+ },
+ SectionType.Article => new SectionArticle
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ 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()
+ },
+ SectionType.Map => new SectionMap
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ 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,
+ MapCategories = null, //((MapDTO)dto).categories, // TODO specific
+ MapPoints = null // ((MapDTO)dto).points, // TODO specific
+ },
+ SectionType.Menu => new SectionMenu
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ //Sections = ((MenuDTO)dto).sections, // TODO specific
+ },
+ SectionType.PDF => new SectionPdf
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ PDFOrderedTranslationAndResources = ((PdfDTO)dto).pdfs.Select(p => new OrderedTranslationAndResource().FromDTO(p)).ToList()
+ },
+ SectionType.Puzzle => new SectionPuzzle
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ 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
+ },
+ SectionType.Quiz => new SectionQuiz
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ 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(),
+ //Questions = ((QuizDTO)dto).questions, // TODO specific
+ },
+ SectionType.Slider => new SectionSlider
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ SliderContents = ((SliderDTO)dto).contents.Select(c => new Content().FromDTO(c)).ToList(), // TODO TEST
+ },
+ SectionType.Video => new SectionVideo
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ VideoSource = ((VideoDTO)dto).source,
+ },
+
+ SectionType.Weather => new SectionWeather
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ WeatherCity = ((WeatherDTO)dto).city,
+ WeatherUpdatedDate = ((WeatherDTO)dto).updatedDate,
+ WeatherResult = ((WeatherDTO)dto).result
+ },
+ SectionType.Web => new SectionWeb
+ {
+ Id = dto.id,
+ Label = dto.label,
+ Title = dto.title.Select(t => new Translation().FromDTO(t)).ToList(),
+ Description = dto.description.Select(d => new Translation().FromDTO(d)).ToList(),
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ WebSource = ((WebDTO)dto).source,
+ },
+
+ _ => throw new NotImplementedException("Section type not handled")
+ };
+ }
+ }
+
+}