From cef69a61df8bef6b96c62ff45d87a41dad13b3e1 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Mon, 24 Mar 2025 17:18:59 +0100 Subject: [PATCH] section (to be tested when front) + section map controller + section quiz controller + update useless entities to DTO --- .../Controllers/ConfigurationController.cs | 12 +- .../Controllers/ResourceController.cs | 8 +- .../Controllers/SectionAgendaController.cs | 292 ++++++ .../Controllers/SectionController.cs | 21 +- .../Controllers/SectionMapController.cs | 299 +++++++ .../Controllers/SectionMenuController.cs | 292 ++++++ .../Controllers/SectionQuizController.cs | 267 ++++++ ManagerService/DTOs/SubSection/MapDTO.cs | 8 +- ManagerService/DTOs/SubSection/QuizzDTO.cs | 5 +- ManagerService/Data/Configuration.cs | 6 +- ManagerService/Data/MyInfoMateDbContext.cs | 6 + ManagerService/Data/Section.cs | 8 +- ManagerService/Data/SubSection/Content.cs | 12 +- .../Data/SubSection/SectionAgenda.cs | 8 +- .../Data/SubSection/SectionArticle.cs | 17 +- ManagerService/Data/SubSection/SectionMap.cs | 18 +- ManagerService/Data/SubSection/SectionMenu.cs | 4 +- ManagerService/Data/SubSection/SectionPdf.cs | 11 +- .../Data/SubSection/SectionPuzzle.cs | 4 +- ManagerService/Data/SubSection/SectionQuiz.cs | 18 +- .../Data/SubSection/SectionSlider.cs | 9 +- .../Data/SubSection/SectionVideo.cs | 4 +- .../Data/SubSection/SectionWeather.cs | 4 +- ManagerService/Data/SubSection/SectionWeb.cs | 4 +- ManagerService/Data/SubSection/Translation.cs | 1 - ManagerService/Helpers/LanguageInit.cs | 8 +- .../20250324140608_UpdateMix2.Designer.cs | 828 ++++++++++++++++++ .../Migrations/20250324140608_UpdateMix2.cs | 60 ++ .../20250324144502_UpdateMix3.Designer.cs | 757 ++++++++++++++++ .../Migrations/20250324144502_UpdateMix3.cs | 190 ++++ .../20250324150634_UpdateMix4.Designer.cs | 713 +++++++++++++++ .../Migrations/20250324150634_UpdateMix4.cs | 71 ++ .../20250324151019_UpdateMix5.Designer.cs | 680 ++++++++++++++ .../Migrations/20250324151019_UpdateMix5.cs | 59 ++ .../20250324152734_UpdateMix6.Designer.cs | 680 ++++++++++++++ .../Migrations/20250324152734_UpdateMix6.cs | 108 +++ .../20250324154921_UpdateMix7.Designer.cs | 680 ++++++++++++++ .../Migrations/20250324154921_UpdateMix7.cs | 22 + .../MyInfoMateDbContextModelSnapshot.cs | 197 +---- ManagerService/Services/SectionFactory.cs | 142 +-- 40 files changed, 6212 insertions(+), 321 deletions(-) create mode 100644 ManagerService/Controllers/SectionAgendaController.cs create mode 100644 ManagerService/Controllers/SectionMapController.cs create mode 100644 ManagerService/Controllers/SectionMenuController.cs create mode 100644 ManagerService/Controllers/SectionQuizController.cs create mode 100644 ManagerService/Migrations/20250324140608_UpdateMix2.Designer.cs create mode 100644 ManagerService/Migrations/20250324140608_UpdateMix2.cs create mode 100644 ManagerService/Migrations/20250324144502_UpdateMix3.Designer.cs create mode 100644 ManagerService/Migrations/20250324144502_UpdateMix3.cs create mode 100644 ManagerService/Migrations/20250324150634_UpdateMix4.Designer.cs create mode 100644 ManagerService/Migrations/20250324150634_UpdateMix4.cs create mode 100644 ManagerService/Migrations/20250324151019_UpdateMix5.Designer.cs create mode 100644 ManagerService/Migrations/20250324151019_UpdateMix5.cs create mode 100644 ManagerService/Migrations/20250324152734_UpdateMix6.Designer.cs create mode 100644 ManagerService/Migrations/20250324152734_UpdateMix6.cs create mode 100644 ManagerService/Migrations/20250324154921_UpdateMix7.Designer.cs create mode 100644 ManagerService/Migrations/20250324154921_UpdateMix7.cs diff --git a/ManagerService/Controllers/ConfigurationController.cs b/ManagerService/Controllers/ConfigurationController.cs index a685637..a75bff6 100644 --- a/ManagerService/Controllers/ConfigurationController.cs +++ b/ManagerService/Controllers/ConfigurationController.cs @@ -230,7 +230,7 @@ namespace ManagerService.Controllers Configuration configuration = new Configuration(); configuration.InstanceId = newConfiguration.instanceId; configuration.Label = newConfiguration.label; - configuration.Title = new List(); + configuration.Title = new List(); configuration.ImageId = newConfiguration.imageId; configuration.ImageSource = newConfiguration.imageSource; configuration.PrimaryColor = newConfiguration.primaryColor; @@ -301,7 +301,7 @@ namespace ManagerService.Controllers // Todo add some verification ? configuration.InstanceId = updatedConfiguration.instanceId; configuration.Label = updatedConfiguration.label; - configuration.Title = updatedConfiguration.title.Select(t => new Translation().FromDTO(t)).ToList(); // TO CHEECK ! + configuration.Title = updatedConfiguration.title; configuration.ImageId = updatedConfiguration.imageId; configuration.ImageSource = updatedConfiguration.imageSource; configuration.PrimaryColor = updatedConfiguration.primaryColor; @@ -649,7 +649,7 @@ namespace ManagerService.Controllers configuration.Id = exportConfiguration.id; configuration.InstanceId = exportConfiguration.instanceId; configuration.Label = exportConfiguration.label; - configuration.Title = exportConfiguration.title.Select(t => new Translation().FromDTO(t)).ToList(); // TO CHEECK ! + configuration.Title = exportConfiguration.title; configuration.ImageId = exportConfiguration.imageId; configuration.ImageSource = exportConfiguration.imageSource; @@ -683,15 +683,15 @@ namespace ManagerService.Controllers //_configurationService.Create(configuration); var sectionsAlreadyInDB = _myInfoMateDbContext.Sections.Where(s => !exportConfiguration.sections.Select(s => s.id).Contains(s.Id)).Select(s => s.Id).ToList(); - // TODO TEST + foreach (var section in exportConfiguration.sections.Where(s => !sectionsAlreadyInDB.Contains(s.id))) { Section newSection = new Section(); newSection.Id = section.id; newSection.InstanceId = section.instanceId; newSection.Label = section.label; - newSection.Title = section.title.Select(t => new Translation().FromDTO(t)).ToList(); // TODO TEST - newSection.Description = section.description.Select(t => new Translation().FromDTO(t)).ToList(); // TODO TEST + newSection.Title = section.title; + newSection.Description = section.description; newSection.Order = section.order.GetValueOrDefault(); // if one day we can use same section in multiple configuration, need to change that newSection.Type = section.type; newSection.ImageId = section.imageId; diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs index f460a96..3da39ea 100644 --- a/ManagerService/Controllers/ResourceController.cs +++ b/ManagerService/Controllers/ResourceController.cs @@ -445,8 +445,8 @@ namespace ManagerService.Controllers point.ImageResourceId = point.ImageResourceId == id ? null : point.ImageResourceId; foreach (var content in point.Contents) { - content.Url = content.Id == id ? null : content.Url; - content.Id = content.Id == id ? null : content.Id; + content.resource.url = content.resourceId == id ? null : content.resource.url; + content.resourceId = content.resourceId == id ? null : content.resourceId; } } @@ -467,7 +467,7 @@ namespace ManagerService.Controllers contentsToKeep.Add(content); }*/ // TODO TEST - slider.SliderContents = slider.SliderContents.Where(c => c.ResourceId != id).ToList(); + slider.SliderContents = slider.SliderContents; //section.Data = JsonConvert.SerializeObject(sliderDTO); break; // TODO @@ -556,7 +556,7 @@ namespace ManagerService.Controllers }*/ // TODO TEEEEEEEEEEESST //articleDTO.contents = contentsArticleToKeep; - article.ArticleContents = article.ArticleContents.Where(c => c.ResourceId != id).ToList(); + article.ArticleContents = article.ArticleContents; //section.Data = JsonConvert.SerializeObject(articleDTO); break; } diff --git a/ManagerService/Controllers/SectionAgendaController.cs b/ManagerService/Controllers/SectionAgendaController.cs new file mode 100644 index 0000000..3981200 --- /dev/null +++ b/ManagerService/Controllers/SectionAgendaController.cs @@ -0,0 +1,292 @@ +using Manager.DTOs; +using Manager.Helpers; +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; +using Microsoft.Extensions.Logging; +using Mqtt.Client.AspNetCore.Services; +using Newtonsoft.Json; +using NSwag.Annotations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; + +namespace ManagerService.Controllers +{ + [Authorize] // TODO Add ROLES (Roles = "Admin") + [ApiController, Route("api/[controller]")] + [OpenApiTag("Section agenda", Description = "Section agenda management")] + public class SectionAgendaController : ControllerBase + { + private readonly MyInfoMateDbContext _myInfoMateDbContext; + + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + IHexIdGeneratorService idService = new HexIdGeneratorService(); + + public SectionAgendaController(IConfiguration configuration, ILogger logger, MyInfoMateDbContext myInfoMateDbContext) + { + _logger = logger; + _configuration = configuration; + _myInfoMateDbContext = myInfoMateDbContext; + } + + /// + /// Create a new section + /// + /// New section info + /*[ProducesResponseType(typeof(SectionDTO), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 409)] + [ProducesResponseType(typeof(string), 500)] + [HttpPost()] + public ObjectResult Create([FromBody] SectionDTO newSection) + { + try + { + if (newSection == null) + throw new ArgumentNullException("Section param is null"); + + if (newSection.configurationId == null) + throw new ArgumentNullException("Configuration param is null"); + + 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 = new Section(); + + // Preparation + List languages = _configuration.GetSection("SupportedLanguages").Get>(); + + 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 = LanguageInit.Init("Content", languages), + 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.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection) + 1; + + section.IsBeacon = newSection.isBeacon; + section.BeaconId = newSection.beaconId; + section.Latitude = newSection.latitude; + section.Longitude = newSection.longitude; + section.MeterZoneGPS = newSection.meterZoneGPS; + + section.Title = LanguageInit.Init("Title", languages); + section.Description = LanguageInit.Init("Description", languages); + + section.Id = idService.GenerateHexId(); + //_sectionService.Create(section); + _myInfoMateDbContext.Add(section); + _myInfoMateDbContext.SaveChanges(); + + return new OkObjectResult(section.ToDTO()); + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (InvalidOperationException ex) + { + return new ConflictObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + + /// + /// Update sections order + /// + /// New sections order + /*[ProducesResponseType(typeof(string), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpPut("order")] + public ObjectResult UpdateOrder([FromBody] List updatedSectionsOrder) + { + // TODO REWRITE LOGIC.. + try + { + if (updatedSectionsOrder == null) + throw new ArgumentNullException("Sections param is null"); + + foreach (var section in updatedSectionsOrder) + { + 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) + { + 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); + } + + if (updatedSectionsOrder.Count > 0) { + MqttClientService.PublishMessage($"config/{updatedSectionsOrder[0].configurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true })); + } + + return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 }; + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + + + /// + /// Delete a section + /// + /// Id of section to delete + /*[ProducesResponseType(typeof(string), 202)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpDelete("{id}")] + public ObjectResult Delete(string id) + { + try + { + if (id == null) + throw new ArgumentNullException("Section param is null"); + + var section = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == id); + if (section == null) + throw new KeyNotFoundException("Section does not exist"); + + _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 }; + + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + } +} diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index 485d0c9..a5e521a 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -323,13 +323,13 @@ namespace ManagerService.Controllers MapMapProvider = MapProvider.Google, MapZoom = 18, MapPoints = new List(), - MapCategories = new List() + MapCategories = new List() }; break; case SectionType.Slider: section = new SectionSlider { - SliderContents = new List() + SliderContents = new List() }; break; case SectionType.Video: @@ -360,7 +360,7 @@ namespace ManagerService.Controllers case SectionType.Article: section = new SectionArticle { - ArticleContents = new List(), + ArticleContents = new List(), ArticleContent = LanguageInit.Init("Content", languages), ArticleAudioIds = LanguageInit.Init("Audio", languages, true) }; @@ -381,7 +381,7 @@ namespace ManagerService.Controllers case SectionType.Agenda: section = new SectionAgenda { - AgendaResourceIds = new List() + AgendaResourceIds = new List() }; break; case SectionType.Weather: @@ -543,20 +543,25 @@ namespace ManagerService.Controllers switch (updatedSectionDB) { + case SectionAgenda agenda: + // TODO in future events + break; + case SectionMap map: - // TODO specific + // TODO Endpoint categories + // TODO Endpoint points /*map.Categories = []; map.Points = [];*/ - - //weather.Latitude = updatedSection.latitude; break; case SectionMenu menu: + // TODO Endpoint Sections menu //menu.Sections = new List
(); break; case SectionQuiz quiz: + // TODO Endpoint QuizQuestions quiz.QuizQuestions = []; break; @@ -568,7 +573,7 @@ namespace ManagerService.Controllers MqttClientService.PublishMessage($"config/{existingSection.ConfigurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true })); - return new OkObjectResult(updatedSectionDB.ToDTO()); + return new OkObjectResult(SectionFactory.ToDTO(existingSection)); } catch (ArgumentNullException ex) { diff --git a/ManagerService/Controllers/SectionMapController.cs b/ManagerService/Controllers/SectionMapController.cs new file mode 100644 index 0000000..5d85977 --- /dev/null +++ b/ManagerService/Controllers/SectionMapController.cs @@ -0,0 +1,299 @@ +using Manager.DTOs; +using ManagerService.Data; +using ManagerService.Data.SubSection; +using ManagerService.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using NSwag.Annotations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; + +namespace ManagerService.Controllers +{ + [Authorize] // TODO Add ROLES (Roles = "Admin") + [ApiController, Route("api/[controller]")] + [OpenApiTag("Section map", Description = "Section map management")] + public class SectionMapController : ControllerBase + { + private readonly MyInfoMateDbContext _myInfoMateDbContext; + + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + IHexIdGeneratorService idService = new HexIdGeneratorService(); + + public SectionMapController(IConfiguration configuration, ILogger logger, MyInfoMateDbContext myInfoMateDbContext) + { + _logger = logger; + _configuration = configuration; + _myInfoMateDbContext = myInfoMateDbContext; + } + + /// + /// Get all points from section + /// + /// Section id + [AllowAnonymous] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpGet("{sectionId}/points")] + public ObjectResult GetAllGeoPointsFromSection(string sectionId) + { + try + { + SectionMap sectionMap = _myInfoMateDbContext.Sections.OfType().Include(sm => sm.MapPoints).FirstOrDefault(sm => sm.Id == sectionId); + + List geoPointDTOs = new List(); + foreach (var point in sectionMap.MapPoints) + { + foreach (var content in point.Contents) { + var resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == content.resourceId); + if (resource != null) + { + content.resource = resource.ToDTO(); + } + } + + geoPointDTOs.Add(new GeoPointDTO() + { + id = point.Id, + title = point.Title, + description = point.Description, + contents = point.Contents, + categorieId = point.CategorieId, + latitude = point.Latitude, + longitude = point.Longitude, + imageResourceId = point.ImageResourceId, + imageUrl = point.ImageUrl, + schedules = point.Schedules, + prices = point.Prices, + phone = point.Phone, + email = point.Email, + site = point.Site + }); + } + + return new OkObjectResult(geoPointDTOs); + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + /// + /// Create new point + /// + /// Section Id + /// geoPoint + [ProducesResponseType(typeof(GeoPoint), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 409)] + [ProducesResponseType(typeof(string), 500)] + [HttpPost("{sectionId}/points")] + public ObjectResult Create(string sectionId, [FromBody] GeoPointDTO geoPointDTO) + { + try + { + if (sectionId == null) + throw new ArgumentNullException("Section param is null"); + + if (geoPointDTO == null) + throw new ArgumentNullException("GeoPoint is null"); + + var existingSection = _myInfoMateDbContext.Sections.OfType().Include(s => s.MapPoints).FirstOrDefault(s => s.Id == sectionId); + if (existingSection == null) + throw new KeyNotFoundException("Section map does not exist"); + + // TODO verification ? + GeoPoint geoPoint = new GeoPoint(); + geoPoint.Title = geoPointDTO.title; + geoPoint.Description = geoPointDTO.description; + geoPoint.Contents = geoPointDTO.contents; + geoPoint.CategorieId = geoPointDTO.categorieId; + geoPoint.Latitude = geoPointDTO.latitude; + geoPoint.Longitude = geoPointDTO.longitude; + geoPoint.ImageResourceId = geoPointDTO.imageResourceId; + geoPoint.ImageUrl = geoPointDTO.imageUrl; + geoPoint.Schedules = geoPointDTO.schedules; + geoPoint.Prices = geoPointDTO.prices; + geoPoint.Phone = geoPointDTO.phone; + geoPoint.Email = geoPointDTO.email; + geoPoint.Site = geoPointDTO.site; + + if (existingSection.MapPoints == null) + { + existingSection.MapPoints = []; + } + existingSection.MapPoints.Add(geoPoint); + + _myInfoMateDbContext.SaveChanges(); + + return new OkObjectResult(geoPoint); + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (InvalidOperationException ex) + { + return new ConflictObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + /// + /// Update a geo point + /// + /// GeoPoint to update + [ProducesResponseType(typeof(GeoPoint), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpPut] + public ObjectResult Update([FromBody] GeoPointDTO geoPointDTO) + { + try + { + if (geoPointDTO == null) + throw new ArgumentNullException("GeoPoint param is null"); + + var existingGeoPoint = _myInfoMateDbContext.GeoPoints.FirstOrDefault(gp => gp.Id == geoPointDTO.id); + if (existingGeoPoint == null) + throw new KeyNotFoundException("GeoPoint does not exist"); + + existingGeoPoint.Title = geoPointDTO.title; + existingGeoPoint.Description = geoPointDTO.description; + existingGeoPoint.Contents = geoPointDTO.contents; + existingGeoPoint.CategorieId = geoPointDTO.categorieId; + existingGeoPoint.Latitude = geoPointDTO.latitude; + existingGeoPoint.Longitude = geoPointDTO.longitude; + existingGeoPoint.ImageResourceId = geoPointDTO.imageResourceId; + existingGeoPoint.ImageUrl = geoPointDTO.imageUrl; + existingGeoPoint.Schedules = geoPointDTO.schedules; + existingGeoPoint.Prices = geoPointDTO.prices; + existingGeoPoint.Phone = geoPointDTO.phone; + existingGeoPoint.Email = geoPointDTO.email; + existingGeoPoint.Site = geoPointDTO.site; + + _myInfoMateDbContext.SaveChanges(); + + return new OkObjectResult(existingGeoPoint); + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + /// + /// Update sections order + /// + /// New sections order + /*[ProducesResponseType(typeof(string), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpPut("order")] + public ObjectResult UpdateOrder([FromBody] List updatedSectionsOrder) + { + // TODO REWRITE LOGIC.. + try + { + if (updatedSectionsOrder == null) + throw new ArgumentNullException("Sections param is null"); + + foreach (var section in updatedSectionsOrder) + { + 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) + { + 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); + } + + if (updatedSectionsOrder.Count > 0) { + MqttClientService.PublishMessage($"config/{updatedSectionsOrder[0].configurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true })); + } + + return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 }; + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + + + /// + /// Delete a geopoint + /// + /// Id of geopoint to delete + [ProducesResponseType(typeof(string), 202)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpDelete("points/delete/{geoPointId}")] + public ObjectResult Delete(int geoPointId) + { + try + { + var geoPoint = _myInfoMateDbContext.GeoPoints.FirstOrDefault(gp => gp.Id == geoPointId); + if (geoPoint == null) + throw new KeyNotFoundException("GeoPoint does not exist"); + + _myInfoMateDbContext.Remove(geoPoint); + _myInfoMateDbContext.SaveChanges(); + + return new ObjectResult("The geopoint has been deleted") { StatusCode = 202 }; + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + } +} diff --git a/ManagerService/Controllers/SectionMenuController.cs b/ManagerService/Controllers/SectionMenuController.cs new file mode 100644 index 0000000..0575a5d --- /dev/null +++ b/ManagerService/Controllers/SectionMenuController.cs @@ -0,0 +1,292 @@ +using Manager.DTOs; +using Manager.Helpers; +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; +using Microsoft.Extensions.Logging; +using Mqtt.Client.AspNetCore.Services; +using Newtonsoft.Json; +using NSwag.Annotations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; + +namespace ManagerService.Controllers +{ + [Authorize] // TODO Add ROLES (Roles = "Admin") + [ApiController, Route("api/[controller]")] + [OpenApiTag("Section menu", Description = "Section menu management")] + public class SectionMenuController : ControllerBase + { + private readonly MyInfoMateDbContext _myInfoMateDbContext; + + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + IHexIdGeneratorService idService = new HexIdGeneratorService(); + + public SectionMenuController(IConfiguration configuration, ILogger logger, MyInfoMateDbContext myInfoMateDbContext) + { + _logger = logger; + _configuration = configuration; + _myInfoMateDbContext = myInfoMateDbContext; + } + + /// + /// Create a new section + /// + /// New section info + /*[ProducesResponseType(typeof(SectionDTO), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 409)] + [ProducesResponseType(typeof(string), 500)] + [HttpPost()] + public ObjectResult Create([FromBody] SectionDTO newSection) + { + try + { + if (newSection == null) + throw new ArgumentNullException("Section param is null"); + + if (newSection.configurationId == null) + throw new ArgumentNullException("Configuration param is null"); + + 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 = new Section(); + + // Preparation + List languages = _configuration.GetSection("SupportedLanguages").Get>(); + + 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 = LanguageInit.Init("Content", languages), + 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.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection) + 1; + + section.IsBeacon = newSection.isBeacon; + section.BeaconId = newSection.beaconId; + section.Latitude = newSection.latitude; + section.Longitude = newSection.longitude; + section.MeterZoneGPS = newSection.meterZoneGPS; + + section.Title = LanguageInit.Init("Title", languages); + section.Description = LanguageInit.Init("Description", languages); + + section.Id = idService.GenerateHexId(); + //_sectionService.Create(section); + _myInfoMateDbContext.Add(section); + _myInfoMateDbContext.SaveChanges(); + + return new OkObjectResult(section.ToDTO()); + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (InvalidOperationException ex) + { + return new ConflictObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + + /// + /// Update sections order + /// + /// New sections order + /*[ProducesResponseType(typeof(string), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpPut("order")] + public ObjectResult UpdateOrder([FromBody] List updatedSectionsOrder) + { + // TODO REWRITE LOGIC.. + try + { + if (updatedSectionsOrder == null) + throw new ArgumentNullException("Sections param is null"); + + foreach (var section in updatedSectionsOrder) + { + 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) + { + 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); + } + + if (updatedSectionsOrder.Count > 0) { + MqttClientService.PublishMessage($"config/{updatedSectionsOrder[0].configurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true })); + } + + return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 }; + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + + + /// + /// Delete a section + /// + /// Id of section to delete + /*[ProducesResponseType(typeof(string), 202)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpDelete("{id}")] + public ObjectResult Delete(string id) + { + try + { + if (id == null) + throw new ArgumentNullException("Section param is null"); + + var section = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == id); + if (section == null) + throw new KeyNotFoundException("Section does not exist"); + + _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 }; + + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + } +} diff --git a/ManagerService/Controllers/SectionQuizController.cs b/ManagerService/Controllers/SectionQuizController.cs new file mode 100644 index 0000000..d84c401 --- /dev/null +++ b/ManagerService/Controllers/SectionQuizController.cs @@ -0,0 +1,267 @@ +using Manager.DTOs; +using Manager.Helpers; +using ManagerService.Data; +using ManagerService.Data.SubSection; +using ManagerService.DTOs; +using ManagerService.Services; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Mqtt.Client.AspNetCore.Services; +using Newtonsoft.Json; +using NSwag.Annotations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Text.Json; + +namespace ManagerService.Controllers +{ + [Authorize] // TODO Add ROLES (Roles = "Admin") + [ApiController, Route("api/[controller]")] + [OpenApiTag("Section quiz", Description = "Section quiz management")] + public class SectionQuizController : ControllerBase + { + private readonly MyInfoMateDbContext _myInfoMateDbContext; + + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + IHexIdGeneratorService idService = new HexIdGeneratorService(); + + public SectionQuizController(IConfiguration configuration, ILogger logger, MyInfoMateDbContext myInfoMateDbContext) + { + _logger = logger; + _configuration = configuration; + _myInfoMateDbContext = myInfoMateDbContext; + } + + /// + /// Get all quiz questions from section + /// + /// Section id + [AllowAnonymous] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpGet("{sectionId}/questions")] + public ObjectResult GetAllQuizQuestionFromSection(string sectionId) + { + try + { + SectionQuiz sectionQuiz = _myInfoMateDbContext.Sections.OfType().Include(sq => sq.QuizQuestions).ThenInclude(qq => qq.Resource).FirstOrDefault(sq => sq.Id == sectionId); + + List questionDTOs = new List(); + foreach (var question in sectionQuiz.QuizQuestions) + { + questionDTOs.Add(new QuestionDTO() + { + id = question.Id, + label = question.Label, + responses = question.Responses, + imageBackgroundResourceId = question.ResourceId, + imageBackgroundResourceType = question.Resource.Type, + imageBackgroundResourceUrl = question.Resource.Url, + order = question.Order + }); + } + + return new OkObjectResult(questionDTOs); + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + /// + /// Create new question + /// + /// Section Id + /// question + [ProducesResponseType(typeof(QuizQuestion), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 409)] + [ProducesResponseType(typeof(string), 500)] + [HttpPost("{sectionId}/questions")] + public ObjectResult Create(string sectionId, [FromBody] QuestionDTO questionDTO) + { + try + { + if (sectionId == null) + throw new ArgumentNullException("Section param is null"); + + if (questionDTO == null) + throw new ArgumentNullException("Question is null"); + + var existingSection = _myInfoMateDbContext.Sections.OfType().Include(sq => sq.QuizQuestions).ThenInclude(qq => qq.Resource).FirstOrDefault(sq => sq.Id == sectionId); + if (existingSection == null) + throw new KeyNotFoundException("Section quiz does not exist"); + + // TODO verification ? + QuizQuestion quizQuestion = new QuizQuestion(); + quizQuestion.Label = questionDTO.label; + quizQuestion.Responses = questionDTO.responses; + quizQuestion.ResourceId = questionDTO.imageBackgroundResourceId; + quizQuestion.Order = questionDTO.order; + + existingSection.QuizQuestions.Add(quizQuestion); + + _myInfoMateDbContext.SaveChanges(); + + return new OkObjectResult(quizQuestion); + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (InvalidOperationException ex) + { + return new ConflictObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + /// + /// Update a quiz question + /// + /// QuizQuestion to update + [ProducesResponseType(typeof(QuizQuestion), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpPut] + public ObjectResult Update([FromBody] QuestionDTO questionDTO) + { + try + { + if (questionDTO == null) + throw new ArgumentNullException("Question param is null"); + + var existingQuestion = _myInfoMateDbContext.QuizQuestions.FirstOrDefault(qq => qq.Id == questionDTO.id); + if (existingQuestion == null) + throw new KeyNotFoundException("Question quiz does not exist"); + + existingQuestion.Label = questionDTO.label; + existingQuestion.Responses = questionDTO.responses; + existingQuestion.Order = questionDTO.order; + existingQuestion.ResourceId = questionDTO.imageBackgroundResourceId; + + _myInfoMateDbContext.SaveChanges(); + + return new OkObjectResult(existingQuestion); + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + + /// + /// Update sections order + /// + /// New sections order + /*[ProducesResponseType(typeof(string), 200)] + [ProducesResponseType(typeof(string), 400)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpPut("order")] + public ObjectResult UpdateOrder([FromBody] List updatedSectionsOrder) + { + // TODO REWRITE LOGIC.. + try + { + if (updatedSectionsOrder == null) + throw new ArgumentNullException("Sections param is null"); + + foreach (var section in updatedSectionsOrder) + { + 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) + { + 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); + } + + if (updatedSectionsOrder.Count > 0) { + MqttClientService.PublishMessage($"config/{updatedSectionsOrder[0].configurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true })); + } + + return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 }; + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + }*/ + + + /// + /// Delete a quiz question + /// + /// Id of quizQuestion to delete + [ProducesResponseType(typeof(string), 202)] + [ProducesResponseType(typeof(string), 404)] + [ProducesResponseType(typeof(string), 500)] + [HttpDelete("questions/delete/{quizQuestionId}")] + public ObjectResult Delete(int quizQuestionId) + { + try + { + var quizQuestion = _myInfoMateDbContext.QuizQuestions.FirstOrDefault(qq => qq.Id == quizQuestionId); + if (quizQuestion == null) + throw new KeyNotFoundException("QuizQuestion does not exist"); + + _myInfoMateDbContext.Remove(quizQuestion); + _myInfoMateDbContext.SaveChanges(); + + return new ObjectResult("The quiz question has been deleted") { StatusCode = 202 }; + } + catch (ArgumentNullException ex) + { + return new BadRequestObjectResult(ex.Message) { }; + } + catch (KeyNotFoundException ex) + { + return new NotFoundObjectResult(ex.Message) { }; + } + catch (Exception ex) + { + return new ObjectResult(ex.Message) { StatusCode = 500 }; + } + } + } +} diff --git a/ManagerService/DTOs/SubSection/MapDTO.cs b/ManagerService/DTOs/SubSection/MapDTO.cs index fadd556..fee530d 100644 --- a/ManagerService/DTOs/SubSection/MapDTO.cs +++ b/ManagerService/DTOs/SubSection/MapDTO.cs @@ -1,4 +1,5 @@ using ManagerService.Data; +using ManagerService.Data.SubSection; using ManagerService.DTOs; using System.Collections.Generic; @@ -23,8 +24,7 @@ namespace Manager.DTOs public int? id { get; set; } public List title { get; set; } public List description { get; set; } - public List contents { get; set; } - public CategorieDTO categorie { get; set; } // TO DELETE IN FUTURE + public List contents { get; set; } public int? categorieId { get; set; } public string latitude { get; set; } public string longitude { get; set; } @@ -46,13 +46,13 @@ namespace Manager.DTOs public int? order { get; set; } // Order to show } - public class ContentGeoPoint + /*public class ContentGeoPoint { public string resourceId { get; set; } public ResourceType resourceType { get; set; } public string resourceUrl { get; set; } // url to firebase storage or on internet public string resourceName { get; set; } - } + }*/ public enum MapTypeApp { diff --git a/ManagerService/DTOs/SubSection/QuizzDTO.cs b/ManagerService/DTOs/SubSection/QuizzDTO.cs index 37c1123..0a968bc 100644 --- a/ManagerService/DTOs/SubSection/QuizzDTO.cs +++ b/ManagerService/DTOs/SubSection/QuizzDTO.cs @@ -1,6 +1,6 @@ -using ManagerService.DTOs; +using ManagerService.Data; +using ManagerService.DTOs; using System.Collections.Generic; -using System.Security.AccessControl; namespace Manager.DTOs { @@ -15,6 +15,7 @@ namespace Manager.DTOs public class QuestionDTO { + public int id { get; set; } public List label { get; set; } public List responses { get; set; } public string imageBackgroundResourceId { get; set; } // question image background diff --git a/ManagerService/Data/Configuration.cs b/ManagerService/Data/Configuration.cs index 89a67c1..c99f570 100644 --- a/ManagerService/Data/Configuration.cs +++ b/ManagerService/Data/Configuration.cs @@ -30,7 +30,7 @@ namespace ManagerService.Data [BsonRequired]*/ [Required] [Column(TypeName = "jsonb")] - public List Title { get; set; } + public List Title { get; set; } /*[BsonElement("ImageId")]*/ public string ImageId { get; set; } @@ -91,7 +91,7 @@ namespace ManagerService.Data { id = Id, label = Label, - title = Title.Select(c => c.ToDTO()).ToList(), + title = Title, imageId = ImageId, imageSource = ImageSource, loaderImageId = LoaderImageId, @@ -118,7 +118,7 @@ namespace ManagerService.Data { id = Id, label = Label, - title= Title.Select(c => c.ToDTO()).ToList(), + title= Title, imageId = ImageId, imageSource = ImageSource, loaderImageId = LoaderImageId, diff --git a/ManagerService/Data/MyInfoMateDbContext.cs b/ManagerService/Data/MyInfoMateDbContext.cs index f20cd93..05229bb 100644 --- a/ManagerService/Data/MyInfoMateDbContext.cs +++ b/ManagerService/Data/MyInfoMateDbContext.cs @@ -14,6 +14,12 @@ namespace ManagerService.Data public DbSet Resources { get; set; } public DbSet Users { get; set; } + // MAP + public DbSet GeoPoints { get; set; } + + // QUIZ + public DbSet QuizQuestions { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/ManagerService/Data/Section.cs b/ManagerService/Data/Section.cs index 8ea8b81..c1654aa 100644 --- a/ManagerService/Data/Section.cs +++ b/ManagerService/Data/Section.cs @@ -23,10 +23,10 @@ namespace ManagerService.Data [Required] [Column(TypeName = "jsonb")] - public List Title { get; set; } + public List Title { get; set; } [Column(TypeName = "jsonb")] - public List Description { get; set; } + public List Description { get; set; } public int Order { get; set; } @@ -66,8 +66,8 @@ namespace ManagerService.Data { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title, + description = Description, order = Order, type = Type, imageId = ImageId, diff --git a/ManagerService/Data/SubSection/Content.cs b/ManagerService/Data/SubSection/Content.cs index ee9dea5..dc2b41b 100644 --- a/ManagerService/Data/SubSection/Content.cs +++ b/ManagerService/Data/SubSection/Content.cs @@ -19,11 +19,11 @@ namespace ManagerService.Data.SubSection [Required] [Column(TypeName = "jsonb")] - public List Title { get; set; } + public List Title { get; set; } [Required] [Column(TypeName = "jsonb")] - public List Description { get; set; } + public List Description { get; set; } public string ResourceId { get; set; } public Resource Resource { get; set; } @@ -34,8 +34,8 @@ namespace ManagerService.Data.SubSection { return new ContentDTO() { - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description, order = Order, resourceId = ResourceId, resource = Resource.ToDTO() @@ -46,8 +46,8 @@ namespace ManagerService.Data.SubSection { return new Content() { - Title = contentDTO.title.Select(t => new Translation().FromDTO(t)).ToList(), - Description = contentDTO.description.Select(t => new Translation().FromDTO(t)).ToList(), + Title = contentDTO.title, + Description = contentDTO.description, Order = contentDTO.order, ResourceId = contentDTO.resourceId }; diff --git a/ManagerService/Data/SubSection/SectionAgenda.cs b/ManagerService/Data/SubSection/SectionAgenda.cs index f0df0d2..173de51 100644 --- a/ManagerService/Data/SubSection/SectionAgenda.cs +++ b/ManagerService/Data/SubSection/SectionAgenda.cs @@ -16,7 +16,7 @@ namespace ManagerService.Data.SubSection { [Required] [Column(TypeName = "jsonb")] - public List AgendaResourceIds { get; set; } // All json files for all languages + public List AgendaResourceIds { get; set; } // All json files for all languages public MapProvider? AgendaMapProvider { get; set; } // Default = Google @@ -26,8 +26,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, @@ -42,7 +42,7 @@ namespace ManagerService.Data.SubSection latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, - resourceIds = AgendaResourceIds.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), + resourceIds = AgendaResourceIds, agendaMapProvider = AgendaMapProvider }; } diff --git a/ManagerService/Data/SubSection/SectionArticle.cs b/ManagerService/Data/SubSection/SectionArticle.cs index d74f61c..ced6b26 100644 --- a/ManagerService/Data/SubSection/SectionArticle.cs +++ b/ManagerService/Data/SubSection/SectionArticle.cs @@ -16,18 +16,19 @@ namespace ManagerService.Data.SubSection { [Required] [Column(TypeName = "jsonb")] - public List ArticleContent { get; set; } + public List ArticleContent { get; set; } public bool ArticleIsContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise [Required] [Column(TypeName = "jsonb")] - public List ArticleAudioIds { get; set; } + public List ArticleAudioIds { get; set; } public bool ArticleIsReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise [Required] - public List ArticleContents { get; set; } + [Column(TypeName = "jsonb")] + public List ArticleContents { get; set; } public ArticleDTO ToDTO() { @@ -35,8 +36,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title, + description = Description, order = Order, type = Type, imageId = ImageId, @@ -51,11 +52,11 @@ namespace ManagerService.Data.SubSection latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, - content = ArticleContent.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), + content = ArticleContent, isContentTop = ArticleIsContentTop, - audioIds = ArticleAudioIds.Select(a=> a.ToDTO()).ToList(), + audioIds = ArticleAudioIds, isReadAudioAuto = ArticleIsReadAudioAuto, - contents = ArticleContents.Select(c => c.ToDTO()).ToList(), + contents = ArticleContents, }; } } diff --git a/ManagerService/Data/SubSection/SectionMap.cs b/ManagerService/Data/SubSection/SectionMap.cs index fc5e7dd..8784406 100644 --- a/ManagerService/Data/SubSection/SectionMap.cs +++ b/ManagerService/Data/SubSection/SectionMap.cs @@ -21,7 +21,9 @@ namespace ManagerService.Data.SubSection public List MapPoints { get; set; } public string MapResourceId { get; set; } public Resource MapResource { get; set; } // Icon - public List MapCategories { get; set; } + [Required] + [Column(TypeName = "jsonb")] + public List MapCategories { get; set; } public string MapCenterLatitude { get; set; } // Center on public string MapCenterLongitude { get; set; } // Center on @@ -32,8 +34,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, @@ -52,9 +54,8 @@ namespace ManagerService.Data.SubSection mapType = MapMapType, mapTypeMapbox = MapTypeMapbox, mapProvider = MapMapProvider, - //points = Points.Select(p => p.ToDTO()).ToList(), // TODO iconResourceId = MapResourceId, - categories = MapCategories.Select(c => c.ToDTO()).ToList(), + categories = MapCategories, centerLatitude = MapCenterLatitude, centerLongitude = MapCenterLongitude }; @@ -68,16 +69,15 @@ namespace ManagerService.Data.SubSection [Required] [Column(TypeName = "jsonb")] - public List Title { get; set; } + public List Title { get; set; } [Required] [Column(TypeName = "jsonb")] - public List Description { get; set; } + public List Description { get; set; } - //TODO [Required] [Column(TypeName = "jsonb")] - public List Contents { get; set; } // Contentsgeopoint + public List Contents { get; set; } public int? CategorieId { get; set; } diff --git a/ManagerService/Data/SubSection/SectionMenu.cs b/ManagerService/Data/SubSection/SectionMenu.cs index 328a7b6..c68a714 100644 --- a/ManagerService/Data/SubSection/SectionMenu.cs +++ b/ManagerService/Data/SubSection/SectionMenu.cs @@ -23,8 +23,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, diff --git a/ManagerService/Data/SubSection/SectionPdf.cs b/ManagerService/Data/SubSection/SectionPdf.cs index da76d08..9edcf72 100644 --- a/ManagerService/Data/SubSection/SectionPdf.cs +++ b/ManagerService/Data/SubSection/SectionPdf.cs @@ -1,6 +1,8 @@ using Manager.DTOs; +using ManagerService.DTOs; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; @@ -12,7 +14,8 @@ namespace ManagerService.Data.SubSection public class SectionPdf : Section { [Required] - public List PDFOrderedTranslationAndResources { get; set; } // All json files for all languages + [Column(TypeName = "jsonb")] + public List PDFOrderedTranslationAndResources { get; set; } // All json files for all languages public PdfDTO ToDTO() { @@ -20,8 +23,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, @@ -36,7 +39,7 @@ namespace ManagerService.Data.SubSection latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, - pdfs = PDFOrderedTranslationAndResources.Select(otar => otar.ToDTO()).ToList() + pdfs = PDFOrderedTranslationAndResources }; } } diff --git a/ManagerService/Data/SubSection/SectionPuzzle.cs b/ManagerService/Data/SubSection/SectionPuzzle.cs index 89aaf94..a800aac 100644 --- a/ManagerService/Data/SubSection/SectionPuzzle.cs +++ b/ManagerService/Data/SubSection/SectionPuzzle.cs @@ -38,8 +38,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, diff --git a/ManagerService/Data/SubSection/SectionQuiz.cs b/ManagerService/Data/SubSection/SectionQuiz.cs index 24b540b..38e544f 100644 --- a/ManagerService/Data/SubSection/SectionQuiz.cs +++ b/ManagerService/Data/SubSection/SectionQuiz.cs @@ -19,19 +19,19 @@ namespace ManagerService.Data.SubSection [Required] [Column(TypeName = "jsonb")] - public List QuizBadLevel { get; set; } + public List QuizBadLevel { get; set; } [Required] [Column(TypeName = "jsonb")] - public List QuizMediumLevel { get; set; } + public List QuizMediumLevel { get; set; } [Required] [Column(TypeName = "jsonb")] - public List QuizGoodLevel { get; set; } + public List QuizGoodLevel { get; set; } [Required] [Column(TypeName = "jsonb")] - public List QuizGreatLevel { get; set; } + public List QuizGreatLevel { get; set; } public QuizDTO ToDTO() @@ -40,8 +40,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, @@ -56,8 +56,10 @@ namespace ManagerService.Data.SubSection latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, - //questions = Questions.Select(q => q.tod) - // TODO + bad_level = QuizBadLevel.ToList(), + medium_level = QuizMediumLevel.ToList(), + good_level = QuizGoodLevel.ToList(), + great_level = QuizGreatLevel.ToList() }; } } diff --git a/ManagerService/Data/SubSection/SectionSlider.cs b/ManagerService/Data/SubSection/SectionSlider.cs index 06e7ea5..53890b9 100644 --- a/ManagerService/Data/SubSection/SectionSlider.cs +++ b/ManagerService/Data/SubSection/SectionSlider.cs @@ -15,7 +15,8 @@ namespace ManagerService.Data.SubSection public class SectionSlider : Section { [Required] - public List SliderContents { get; set; } // TODO check + [Column(TypeName = "jsonb")] + public List SliderContents { get; set; } // TODO check public SliderDTO ToDTO() { @@ -23,8 +24,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title, + description = Description, order = Order, type = Type, imageId = ImageId, @@ -39,7 +40,7 @@ namespace ManagerService.Data.SubSection latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, - contents = SliderContents.Select(c => c.ToDTO()).ToList(), + contents = SliderContents, }; } } diff --git a/ManagerService/Data/SubSection/SectionVideo.cs b/ManagerService/Data/SubSection/SectionVideo.cs index ed793c8..884087c 100644 --- a/ManagerService/Data/SubSection/SectionVideo.cs +++ b/ManagerService/Data/SubSection/SectionVideo.cs @@ -18,8 +18,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, diff --git a/ManagerService/Data/SubSection/SectionWeather.cs b/ManagerService/Data/SubSection/SectionWeather.cs index 8f9e0f2..2aebde5 100644 --- a/ManagerService/Data/SubSection/SectionWeather.cs +++ b/ManagerService/Data/SubSection/SectionWeather.cs @@ -26,8 +26,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, diff --git a/ManagerService/Data/SubSection/SectionWeb.cs b/ManagerService/Data/SubSection/SectionWeb.cs index 68e60ec..f9eb4da 100644 --- a/ManagerService/Data/SubSection/SectionWeb.cs +++ b/ManagerService/Data/SubSection/SectionWeb.cs @@ -19,8 +19,8 @@ namespace ManagerService.Data.SubSection { id = Id, label = Label, - title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), - description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(), + title = Title.ToList(), + description = Description.ToList(), order = Order, type = Type, imageId = ImageId, diff --git a/ManagerService/Data/SubSection/Translation.cs b/ManagerService/Data/SubSection/Translation.cs index 9e98def..7a90f64 100644 --- a/ManagerService/Data/SubSection/Translation.cs +++ b/ManagerService/Data/SubSection/Translation.cs @@ -1,5 +1,4 @@ using ManagerService.DTOs; -using System; using System.ComponentModel.DataAnnotations; namespace ManagerService.Data.SubSection diff --git a/ManagerService/Helpers/LanguageInit.cs b/ManagerService/Helpers/LanguageInit.cs index 60959e3..ed0c308 100644 --- a/ManagerService/Helpers/LanguageInit.cs +++ b/ManagerService/Helpers/LanguageInit.cs @@ -1,18 +1,18 @@ using System.Collections.Generic; -using ManagerService.Data.SubSection; +using ManagerService.DTOs; namespace Manager.Helpers { public class LanguageInit { - public static List Init(string label, List languages, bool toNull = false) + public static List Init(string label, List languages, bool toNull = false) { - List translations = new List(); + List translations = new List(); foreach (var language in languages) { var value = toNull ? null : $"{language} - {label}"; - translations.Add(new Translation() { Language = language.ToUpper(), Value = value }); + translations.Add(new TranslationDTO() { language = language.ToUpper(), value = value }); } return translations; } diff --git a/ManagerService/Migrations/20250324140608_UpdateMix2.Designer.cs b/ManagerService/Migrations/20250324140608_UpdateMix2.Designer.cs new file mode 100644 index 0000000..7f7adee --- /dev/null +++ b/ManagerService/Migrations/20250324140608_UpdateMix2.Designer.cs @@ -0,0 +1,828 @@ +// +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("20250324140608_UpdateMix2")] + partial class UpdateMix2 + { + /// + 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("GeoPointId") + .HasColumnType("integer"); + + 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.HasIndex("GeoPointId"); + + 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>("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.Resource", b => + { + b.HasOne("ManagerService.Data.SubSection.GeoPoint", null) + .WithMany("Contents") + .HasForeignKey("GeoPointId"); + }); + + 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.GeoPoint", b => + { + b.Navigation("Contents"); + }); + + 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/20250324140608_UpdateMix2.cs b/ManagerService/Migrations/20250324140608_UpdateMix2.cs new file mode 100644 index 0000000..7a73003 --- /dev/null +++ b/ManagerService/Migrations/20250324140608_UpdateMix2.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using ManagerService.Data; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdateMix2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Contents", + table: "GeoPoint"); + + migrationBuilder.AddColumn( + name: "GeoPointId", + table: "Resources", + type: "integer", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Resources_GeoPointId", + table: "Resources", + column: "GeoPointId"); + + migrationBuilder.AddForeignKey( + name: "FK_Resources_GeoPoint_GeoPointId", + table: "Resources", + column: "GeoPointId", + principalTable: "GeoPoint", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Resources_GeoPoint_GeoPointId", + table: "Resources"); + + migrationBuilder.DropIndex( + name: "IX_Resources_GeoPointId", + table: "Resources"); + + migrationBuilder.DropColumn( + name: "GeoPointId", + table: "Resources"); + + migrationBuilder.AddColumn>( + name: "Contents", + table: "GeoPoint", + type: "jsonb", + nullable: false); + } + } +} diff --git a/ManagerService/Migrations/20250324144502_UpdateMix3.Designer.cs b/ManagerService/Migrations/20250324144502_UpdateMix3.Designer.cs new file mode 100644 index 0000000..a535068 --- /dev/null +++ b/ManagerService/Migrations/20250324144502_UpdateMix3.Designer.cs @@ -0,0 +1,757 @@ +// +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("20250324144502_UpdateMix3")] + partial class UpdateMix3 + { + /// + 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.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("GeoPoints"); + }); + + 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>("ArticleContents") + .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.Property>("SliderContents") + .IsRequired() + .HasColumnType("jsonb"); + + 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.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.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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ManagerService/Migrations/20250324144502_UpdateMix3.cs b/ManagerService/Migrations/20250324144502_UpdateMix3.cs new file mode 100644 index 0000000..eaefdc6 --- /dev/null +++ b/ManagerService/Migrations/20250324144502_UpdateMix3.cs @@ -0,0 +1,190 @@ +using System.Collections.Generic; +using ManagerService.Data.SubSection; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdateMix3 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_GeoPoint_Sections_SectionMapId", + table: "GeoPoint"); + + migrationBuilder.DropForeignKey( + name: "FK_Resources_GeoPoint_GeoPointId", + table: "Resources"); + + migrationBuilder.DropTable( + name: "Content"); + + migrationBuilder.DropIndex( + name: "IX_Resources_GeoPointId", + table: "Resources"); + + migrationBuilder.DropPrimaryKey( + name: "PK_GeoPoint", + table: "GeoPoint"); + + migrationBuilder.DropColumn( + name: "GeoPointId", + table: "Resources"); + + migrationBuilder.RenameTable( + name: "GeoPoint", + newName: "GeoPoints"); + + migrationBuilder.RenameIndex( + name: "IX_GeoPoint_SectionMapId", + table: "GeoPoints", + newName: "IX_GeoPoints_SectionMapId"); + + migrationBuilder.AddColumn>( + name: "ArticleContents", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn>( + name: "SliderContents", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn>( + name: "Contents", + table: "GeoPoints", + type: "jsonb", + nullable: false); + + migrationBuilder.AddPrimaryKey( + name: "PK_GeoPoints", + table: "GeoPoints", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_GeoPoints_Sections_SectionMapId", + table: "GeoPoints", + column: "SectionMapId", + principalTable: "Sections", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_GeoPoints_Sections_SectionMapId", + table: "GeoPoints"); + + migrationBuilder.DropPrimaryKey( + name: "PK_GeoPoints", + table: "GeoPoints"); + + migrationBuilder.DropColumn( + name: "ArticleContents", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "SliderContents", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "Contents", + table: "GeoPoints"); + + migrationBuilder.RenameTable( + name: "GeoPoints", + newName: "GeoPoint"); + + migrationBuilder.RenameIndex( + name: "IX_GeoPoints_SectionMapId", + table: "GeoPoint", + newName: "IX_GeoPoint_SectionMapId"); + + migrationBuilder.AddColumn( + name: "GeoPointId", + table: "Resources", + type: "integer", + nullable: true); + + migrationBuilder.AddPrimaryKey( + name: "PK_GeoPoint", + table: "GeoPoint", + column: "Id"); + + migrationBuilder.CreateTable( + name: "Content", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ResourceId = table.Column(type: "text", nullable: true), + Description = table.Column>(type: "jsonb", nullable: false), + Order = table.Column(type: "integer", nullable: false), + SectionArticleId = table.Column(type: "text", nullable: true), + SectionSliderId = table.Column(type: "text", nullable: true), + Title = table.Column>(type: "jsonb", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Content", x => x.Id); + table.ForeignKey( + name: "FK_Content_Resources_ResourceId", + column: x => x.ResourceId, + principalTable: "Resources", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Content_Sections_SectionArticleId", + column: x => x.SectionArticleId, + principalTable: "Sections", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Content_Sections_SectionSliderId", + column: x => x.SectionSliderId, + principalTable: "Sections", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Resources_GeoPointId", + table: "Resources", + column: "GeoPointId"); + + migrationBuilder.CreateIndex( + name: "IX_Content_ResourceId", + table: "Content", + column: "ResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_Content_SectionArticleId", + table: "Content", + column: "SectionArticleId"); + + migrationBuilder.CreateIndex( + name: "IX_Content_SectionSliderId", + table: "Content", + column: "SectionSliderId"); + + migrationBuilder.AddForeignKey( + name: "FK_GeoPoint_Sections_SectionMapId", + table: "GeoPoint", + column: "SectionMapId", + principalTable: "Sections", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Resources_GeoPoint_GeoPointId", + table: "Resources", + column: "GeoPointId", + principalTable: "GeoPoint", + principalColumn: "Id"); + } + } +} diff --git a/ManagerService/Migrations/20250324150634_UpdateMix4.Designer.cs b/ManagerService/Migrations/20250324150634_UpdateMix4.Designer.cs new file mode 100644 index 0000000..152910d --- /dev/null +++ b/ManagerService/Migrations/20250324150634_UpdateMix4.Designer.cs @@ -0,0 +1,713 @@ +// +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("20250324150634_UpdateMix4")] + partial class UpdateMix4 + { + /// + 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.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("GeoPoints"); + }); + + 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>("ArticleContents") + .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>("MapCategories") + .IsRequired() + .HasColumnType("jsonb"); + + 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.Property>("SliderContents") + .IsRequired() + .HasColumnType("jsonb"); + + 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.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.SectionMap", b => + { + 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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ManagerService/Migrations/20250324150634_UpdateMix4.cs b/ManagerService/Migrations/20250324150634_UpdateMix4.cs new file mode 100644 index 0000000..c4b05d6 --- /dev/null +++ b/ManagerService/Migrations/20250324150634_UpdateMix4.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using ManagerService.Data.SubSection; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdateMix4 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Categorie"); + + migrationBuilder.AddColumn>( + name: "MapCategories", + table: "Sections", + type: "jsonb", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MapCategories", + table: "Sections"); + + migrationBuilder.CreateTable( + name: "Categorie", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ResourceId = table.Column(type: "text", nullable: true), + Icon = table.Column(type: "text", nullable: true), + Label = table.Column>(type: "jsonb", nullable: false), + Order = table.Column(type: "integer", nullable: true), + SectionMapId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Categorie", x => x.Id); + table.ForeignKey( + name: "FK_Categorie_Resources_ResourceId", + column: x => x.ResourceId, + principalTable: "Resources", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Categorie_Sections_SectionMapId", + column: x => x.SectionMapId, + principalTable: "Sections", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Categorie_ResourceId", + table: "Categorie", + column: "ResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_Categorie_SectionMapId", + table: "Categorie", + column: "SectionMapId"); + } + } +} diff --git a/ManagerService/Migrations/20250324151019_UpdateMix5.Designer.cs b/ManagerService/Migrations/20250324151019_UpdateMix5.Designer.cs new file mode 100644 index 0000000..0c79646 --- /dev/null +++ b/ManagerService/Migrations/20250324151019_UpdateMix5.Designer.cs @@ -0,0 +1,680 @@ +// +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("20250324151019_UpdateMix5")] + partial class UpdateMix5 + { + /// + 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.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("GeoPoints"); + }); + + 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>("ArticleContents") + .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>("MapCategories") + .IsRequired() + .HasColumnType("jsonb"); + + 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.Property>("PDFOrderedTranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + + 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.Property>("SliderContents") + .IsRequired() + .HasColumnType("jsonb"); + + 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.GeoPoint", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMap", null) + .WithMany("MapPoints") + .HasForeignKey("SectionMapId"); + }); + + 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.SectionMap", b => + { + b.Navigation("MapPoints"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b => + { + b.Navigation("MenuSections"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.Navigation("QuizQuestions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ManagerService/Migrations/20250324151019_UpdateMix5.cs b/ManagerService/Migrations/20250324151019_UpdateMix5.cs new file mode 100644 index 0000000..2781d1a --- /dev/null +++ b/ManagerService/Migrations/20250324151019_UpdateMix5.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using ManagerService.Data.SubSection; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdateMix5 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "OrderedTranslationAndResource"); + + migrationBuilder.AddColumn>( + name: "PDFOrderedTranslationAndResources", + table: "Sections", + type: "jsonb", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PDFOrderedTranslationAndResources", + table: "Sections"); + + migrationBuilder.CreateTable( + name: "OrderedTranslationAndResource", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Order = table.Column(type: "integer", nullable: false), + SectionPdfId = table.Column(type: "text", nullable: true), + TranslationAndResources = table.Column>(type: "jsonb", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderedTranslationAndResource", x => x.Id); + table.ForeignKey( + name: "FK_OrderedTranslationAndResource_Sections_SectionPdfId", + column: x => x.SectionPdfId, + principalTable: "Sections", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_OrderedTranslationAndResource_SectionPdfId", + table: "OrderedTranslationAndResource", + column: "SectionPdfId"); + } + } +} diff --git a/ManagerService/Migrations/20250324152734_UpdateMix6.Designer.cs b/ManagerService/Migrations/20250324152734_UpdateMix6.Designer.cs new file mode 100644 index 0000000..17a1454 --- /dev/null +++ b/ManagerService/Migrations/20250324152734_UpdateMix6.Designer.cs @@ -0,0 +1,680 @@ +// +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("20250324152734_UpdateMix6")] + partial class UpdateMix6 + { + /// + 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.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("GeoPoints"); + }); + + 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("QuizQuestions"); + }); + + 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>("ArticleContents") + .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>("MapCategories") + .IsRequired() + .HasColumnType("jsonb"); + + 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.Property>("PDFOrderedTranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + + 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.Property>("SliderContents") + .IsRequired() + .HasColumnType("jsonb"); + + 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.GeoPoint", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMap", null) + .WithMany("MapPoints") + .HasForeignKey("SectionMapId"); + }); + + 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.SectionMap", b => + { + b.Navigation("MapPoints"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b => + { + b.Navigation("MenuSections"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.Navigation("QuizQuestions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ManagerService/Migrations/20250324152734_UpdateMix6.cs b/ManagerService/Migrations/20250324152734_UpdateMix6.cs new file mode 100644 index 0000000..fc1eba5 --- /dev/null +++ b/ManagerService/Migrations/20250324152734_UpdateMix6.cs @@ -0,0 +1,108 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdateMix6 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_QuizQuestion_Resources_ResourceId", + table: "QuizQuestion"); + + migrationBuilder.DropForeignKey( + name: "FK_QuizQuestion_Sections_SectionQuizId", + table: "QuizQuestion"); + + migrationBuilder.DropPrimaryKey( + name: "PK_QuizQuestion", + table: "QuizQuestion"); + + migrationBuilder.RenameTable( + name: "QuizQuestion", + newName: "QuizQuestions"); + + migrationBuilder.RenameIndex( + name: "IX_QuizQuestion_SectionQuizId", + table: "QuizQuestions", + newName: "IX_QuizQuestions_SectionQuizId"); + + migrationBuilder.RenameIndex( + name: "IX_QuizQuestion_ResourceId", + table: "QuizQuestions", + newName: "IX_QuizQuestions_ResourceId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_QuizQuestions", + table: "QuizQuestions", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_QuizQuestions_Resources_ResourceId", + table: "QuizQuestions", + column: "ResourceId", + principalTable: "Resources", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_QuizQuestions_Sections_SectionQuizId", + table: "QuizQuestions", + column: "SectionQuizId", + principalTable: "Sections", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_QuizQuestions_Resources_ResourceId", + table: "QuizQuestions"); + + migrationBuilder.DropForeignKey( + name: "FK_QuizQuestions_Sections_SectionQuizId", + table: "QuizQuestions"); + + migrationBuilder.DropPrimaryKey( + name: "PK_QuizQuestions", + table: "QuizQuestions"); + + migrationBuilder.RenameTable( + name: "QuizQuestions", + newName: "QuizQuestion"); + + migrationBuilder.RenameIndex( + name: "IX_QuizQuestions_SectionQuizId", + table: "QuizQuestion", + newName: "IX_QuizQuestion_SectionQuizId"); + + migrationBuilder.RenameIndex( + name: "IX_QuizQuestions_ResourceId", + table: "QuizQuestion", + newName: "IX_QuizQuestion_ResourceId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_QuizQuestion", + table: "QuizQuestion", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_QuizQuestion_Resources_ResourceId", + table: "QuizQuestion", + column: "ResourceId", + principalTable: "Resources", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_QuizQuestion_Sections_SectionQuizId", + table: "QuizQuestion", + column: "SectionQuizId", + principalTable: "Sections", + principalColumn: "Id"); + } + } +} diff --git a/ManagerService/Migrations/20250324154921_UpdateMix7.Designer.cs b/ManagerService/Migrations/20250324154921_UpdateMix7.Designer.cs new file mode 100644 index 0000000..71073d3 --- /dev/null +++ b/ManagerService/Migrations/20250324154921_UpdateMix7.Designer.cs @@ -0,0 +1,680 @@ +// +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("20250324154921_UpdateMix7")] + partial class UpdateMix7 + { + /// + 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.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("GeoPoints"); + }); + + 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("QuizQuestions"); + }); + + 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>("ArticleContents") + .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>("MapCategories") + .IsRequired() + .HasColumnType("jsonb"); + + 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.Property>("PDFOrderedTranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + + 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.Property>("SliderContents") + .IsRequired() + .HasColumnType("jsonb"); + + 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.GeoPoint", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMap", null) + .WithMany("MapPoints") + .HasForeignKey("SectionMapId"); + }); + + 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.SectionMap", b => + { + b.Navigation("MapPoints"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b => + { + b.Navigation("MenuSections"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.Navigation("QuizQuestions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ManagerService/Migrations/20250324154921_UpdateMix7.cs b/ManagerService/Migrations/20250324154921_UpdateMix7.cs new file mode 100644 index 0000000..690688a --- /dev/null +++ b/ManagerService/Migrations/20250324154921_UpdateMix7.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdateMix7 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs index b7ebaef..be1504f 100644 --- a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs +++ b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs @@ -87,7 +87,7 @@ namespace ManagerService.Migrations b.Property("SecondaryColor") .HasColumnType("text"); - b.Property>("Title") + b.Property>("Title") .IsRequired() .HasColumnType("jsonb"); @@ -213,7 +213,7 @@ namespace ManagerService.Migrations b.Property("DateCreation") .HasColumnType("timestamp with time zone"); - b.Property>("Description") + b.Property>("Description") .HasColumnType("jsonb"); b.Property("Discriminator") @@ -259,7 +259,7 @@ namespace ManagerService.Migrations b.Property("SectionMenuId") .HasColumnType("text"); - b.Property>("Title") + b.Property>("Title") .IsRequired() .HasColumnType("jsonb"); @@ -277,78 +277,6 @@ namespace ManagerService.Migrations 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") @@ -360,11 +288,11 @@ namespace ManagerService.Migrations b.Property("CategorieId") .HasColumnType("integer"); - b.Property>("Contents") + b.Property>("Contents") .IsRequired() .HasColumnType("jsonb"); - b.Property>("Description") + b.Property>("Description") .IsRequired() .HasColumnType("jsonb"); @@ -403,7 +331,7 @@ namespace ManagerService.Migrations .IsRequired() .HasColumnType("jsonb"); - b.Property>("Title") + b.Property>("Title") .IsRequired() .HasColumnType("jsonb"); @@ -411,32 +339,7 @@ namespace ManagerService.Migrations 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"); + b.ToTable("GeoPoints"); }); modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => @@ -470,7 +373,7 @@ namespace ManagerService.Migrations b.HasIndex("SectionQuizId"); - b.ToTable("QuizQuestion"); + b.ToTable("QuizQuestions"); }); modelBuilder.Entity("ManagerService.Data.User", b => @@ -516,7 +419,7 @@ namespace ManagerService.Migrations b.Property("AgendaMapProvider") .HasColumnType("integer"); - b.Property>("AgendaResourceIds") + b.Property>("AgendaResourceIds") .IsRequired() .HasColumnType("jsonb"); @@ -527,11 +430,15 @@ namespace ManagerService.Migrations { b.HasBaseType("ManagerService.Data.Section"); - b.Property>("ArticleAudioIds") + b.Property>("ArticleAudioIds") .IsRequired() .HasColumnType("jsonb"); - b.Property>("ArticleContent") + b.Property>("ArticleContent") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("ArticleContents") .IsRequired() .HasColumnType("jsonb"); @@ -548,6 +455,10 @@ namespace ManagerService.Migrations { b.HasBaseType("ManagerService.Data.Section"); + b.Property>("MapCategories") + .IsRequired() + .HasColumnType("jsonb"); + b.Property("MapCenterLatitude") .HasColumnType("text"); @@ -585,6 +496,10 @@ namespace ManagerService.Migrations { b.HasBaseType("ManagerService.Data.Section"); + b.Property>("PDFOrderedTranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + b.HasDiscriminator().HasValue("PDF"); }); @@ -618,19 +533,19 @@ namespace ManagerService.Migrations { b.HasBaseType("ManagerService.Data.Section"); - b.Property>("QuizBadLevel") + b.Property>("QuizBadLevel") .IsRequired() .HasColumnType("jsonb"); - b.Property>("QuizGoodLevel") + b.Property>("QuizGoodLevel") .IsRequired() .HasColumnType("jsonb"); - b.Property>("QuizGreatLevel") + b.Property>("QuizGreatLevel") .IsRequired() .HasColumnType("jsonb"); - b.Property>("QuizMediumLevel") + b.Property>("QuizMediumLevel") .IsRequired() .HasColumnType("jsonb"); @@ -641,6 +556,10 @@ namespace ManagerService.Migrations { b.HasBaseType("ManagerService.Data.Section"); + b.Property>("SliderContents") + .IsRequired() + .HasColumnType("jsonb"); + b.HasDiscriminator().HasValue("Slider"); }); @@ -700,36 +619,6 @@ namespace ManagerService.Migrations .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) @@ -737,13 +626,6 @@ namespace ManagerService.Migrations .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") @@ -775,15 +657,8 @@ namespace ManagerService.Migrations 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"); }); @@ -792,20 +667,10 @@ namespace ManagerService.Migrations 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/Services/SectionFactory.cs b/ManagerService/Services/SectionFactory.cs index 5bf877a..e133468 100644 --- a/ManagerService/Services/SectionFactory.cs +++ b/ManagerService/Services/SectionFactory.cs @@ -71,8 +71,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -84,7 +84,7 @@ namespace ManagerService.Services Longitude = dto.longitude, MeterZoneGPS = dto.meterZoneGPS, Type = dto.type, - AgendaResourceIds = agendaDTO.resourceIds.Select(r => new Translation().FromDTO(r)).ToList(), + AgendaResourceIds = agendaDTO.resourceIds, AgendaMapProvider = agendaDTO.agendaMapProvider }, SectionType.Article => new SectionArticle @@ -93,8 +93,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -106,11 +106,11 @@ namespace ManagerService.Services Longitude = dto.longitude, MeterZoneGPS = dto.meterZoneGPS, Type = dto.type, - ArticleContent = articleDTO.content.Select(r => new Translation().FromDTO(r)).ToList(), + ArticleContent = articleDTO.content, ArticleIsContentTop = articleDTO.isContentTop, - ArticleAudioIds = articleDTO.audioIds.Select(a => new Translation().FromDTO(a)).ToList(), + ArticleAudioIds = articleDTO.audioIds, ArticleIsReadAudioAuto = articleDTO.isReadAudioAuto, - ArticleContents = articleDTO.contents.Select(c => new Content().FromDTO(c)).ToList() + ArticleContents = articleDTO.contents }, SectionType.Map => new SectionMap { @@ -118,8 +118,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -147,8 +147,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -168,8 +168,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -181,7 +181,7 @@ namespace ManagerService.Services Longitude = dto.longitude, MeterZoneGPS = dto.meterZoneGPS, Type = dto.type, - PDFOrderedTranslationAndResources = pdfDTO.pdfs.Select(p => new OrderedTranslationAndResource().FromDTO(p)).ToList() + PDFOrderedTranslationAndResources = pdfDTO.pdfs }, SectionType.Puzzle => new SectionPuzzle { @@ -189,8 +189,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -214,8 +214,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -227,10 +227,10 @@ namespace ManagerService.Services Longitude = dto.longitude, MeterZoneGPS = dto.meterZoneGPS, Type = dto.type, - 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(), + QuizBadLevel = quizDTO.bad_level, + QuizMediumLevel = quizDTO.medium_level, + QuizGoodLevel = quizDTO.good_level, + QuizGreatLevel = quizDTO.great_level, //Questions = ((QuizDTO)dto).questions, // TODO specific }, SectionType.Slider => new SectionSlider @@ -239,8 +239,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -252,7 +252,7 @@ namespace ManagerService.Services Longitude = dto.longitude, MeterZoneGPS = dto.meterZoneGPS, Type = dto.type, - SliderContents = sliderDTO.contents.Select(c => new Content().FromDTO(c)).ToList(), // TODO TEST + SliderContents = sliderDTO.contents, // TODO TEST }, SectionType.Video => new SectionVideo { @@ -260,8 +260,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -282,8 +282,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -305,8 +305,8 @@ namespace ManagerService.Services 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(), + Title = dto.title, + Description = dto.description, Order = dto.order.Value, ImageId = dto.imageId, ImageSource = dto.imageSource, @@ -326,6 +326,7 @@ namespace ManagerService.Services public static SectionDTO ToDTO(Section section) { + // TODO retrieve specific elements ? return section switch { SectionAgenda agenda => new AgendaDTO @@ -334,8 +335,8 @@ namespace ManagerService.Services 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(), + title = agenda.Title, + description = agenda.Description, order = agenda.Order, imageId = agenda.ImageId, imageSource = agenda.ImageSource, @@ -347,17 +348,17 @@ namespace ManagerService.Services longitude = agenda.Longitude, meterZoneGPS = agenda.MeterZoneGPS, type = agenda.Type, - resourceIds = agenda.AgendaResourceIds.Select(r => r.ToDTO()).ToList(), + resourceIds = agenda.AgendaResourceIds, agendaMapProvider = agenda.AgendaMapProvider }, SectionArticle article => new ArticleDTO { id = article.Id, configurationId = article.ConfigurationId, - instanceId = agenda.InstanceId, + instanceId = article.InstanceId, label = article.Label, - title = article.Title.Select(t => t.ToDTO()).ToList(), - description = article.Description.Select(d => d.ToDTO()).ToList(), + title = article.Title, + description = article.Description, order = article.Order, imageId = article.ImageId, imageSource = article.ImageSource, @@ -369,19 +370,20 @@ namespace ManagerService.Services longitude = article.Longitude, meterZoneGPS = article.MeterZoneGPS, type = article.Type, - content = article.ArticleContent.Select(r => r.ToDTO()).ToList(), + content = article.ArticleContent, isContentTop = article.ArticleIsContentTop, - audioIds = article.ArticleAudioIds.Select(a => a.ToDTO()).ToList(), + audioIds = article.ArticleAudioIds, isReadAudioAuto = article.ArticleIsReadAudioAuto, - contents = article.ArticleContents.Select(c => c.ToDTO()).ToList() + contents = article.ArticleContents }, SectionMap map => new MapDTO { id = map.Id, configurationId = map.ConfigurationId, + instanceId = map.InstanceId, label = map.Label, - title = map.Title.Select(t => t.ToDTO()).ToList(), - description = map.Description.Select(d => d.ToDTO()).ToList(), + title = map.Title, + description = map.Description, order = map.Order, imageId = map.ImageId, imageSource = map.ImageSource, @@ -401,15 +403,16 @@ namespace ManagerService.Services centerLatitude = map.MapCenterLatitude, centerLongitude = map.MapCenterLongitude, categories = null, // map.MapCategories, // TODO specific - points = null // map.MapPoints // TODO specific + //points = null // map.MapPoints // TODO specific }, SectionMenu menu => new MenuDTO { id = menu.Id, configurationId = menu.ConfigurationId, + instanceId = menu.InstanceId, label = menu.Label, - title = menu.Title.Select(t => t.ToDTO()).ToList(), - description = menu.Description.Select(d => d.ToDTO()).ToList(), + title = menu.Title, + description = menu.Description, order = menu.Order, imageId = menu.ImageId, imageSource = menu.ImageSource, @@ -427,9 +430,10 @@ namespace ManagerService.Services { id = pdf.Id, configurationId = pdf.ConfigurationId, + instanceId = pdf.InstanceId, label = pdf.Label, - title = pdf.Title.Select(t => t.ToDTO()).ToList(), - description = pdf.Description.Select(d => d.ToDTO()).ToList(), + title = pdf.Title, + description = pdf.Description, order = pdf.Order, imageId = pdf.ImageId, imageSource = pdf.ImageSource, @@ -441,15 +445,16 @@ namespace ManagerService.Services longitude = pdf.Longitude, meterZoneGPS = pdf.MeterZoneGPS, type = pdf.Type, - pdfs = pdf.PDFOrderedTranslationAndResources.Select(p => p.ToDTO()).ToList() + pdfs = pdf.PDFOrderedTranslationAndResources }, SectionPuzzle puzzle => new PuzzleDTO { id = puzzle.Id, configurationId = puzzle.ConfigurationId, + instanceId = puzzle.InstanceId, label = puzzle.Label, - title = puzzle.Title.Select(t => t.ToDTO()).ToList(), - description = puzzle.Description.Select(d => d.ToDTO()).ToList(), + title = puzzle.Title, + description = puzzle.Description, order = puzzle.Order, imageId = puzzle.ImageId, imageSource = puzzle.ImageSource, @@ -471,9 +476,10 @@ namespace ManagerService.Services { id = quiz.Id, configurationId = quiz.ConfigurationId, + instanceId = quiz.InstanceId, label = quiz.Label, - title = quiz.Title.Select(t => t.ToDTO()).ToList(), - description = quiz.Description.Select(d => d.ToDTO()).ToList(), + title = quiz.Title, + description = quiz.Description, order = quiz.Order, imageId = quiz.ImageId, imageSource = quiz.ImageSource, @@ -485,19 +491,20 @@ namespace ManagerService.Services 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(), + bad_level = quiz.QuizBadLevel, + medium_level = quiz.QuizMediumLevel, + good_level = quiz.QuizGoodLevel, + great_level = quiz.QuizGreatLevel, questions = null // quiz.Questions, // TODO specific }, SectionSlider slider => new SliderDTO { id = slider.Id, configurationId = slider.ConfigurationId, + instanceId = slider.InstanceId, label = slider.Label, - title = slider.Title.Select(t => t.ToDTO()).ToList(), - description = slider.Description.Select(d => d.ToDTO()).ToList(), + title = slider.Title, + description = slider.Description, order = slider.Order, imageId = slider.ImageId, imageSource = slider.ImageSource, @@ -509,15 +516,16 @@ namespace ManagerService.Services longitude = slider.Longitude, meterZoneGPS = slider.MeterZoneGPS, type = slider.Type, - contents = slider.SliderContents.Select(c => c.ToDTO()).ToList() + contents = slider.SliderContents }, SectionVideo video => new VideoDTO { id = video.Id, configurationId = video.ConfigurationId, + instanceId = video.InstanceId, label = video.Label, - title = video.Title.Select(t => t.ToDTO()).ToList(), - description = video.Description.Select(d => d.ToDTO()).ToList(), + title = video.Title, + description = video.Description, order = video.Order, imageId = video.ImageId, imageSource = video.ImageSource, @@ -535,9 +543,10 @@ namespace ManagerService.Services { id = weather.Id, configurationId = weather.ConfigurationId, + instanceId = weather.InstanceId, label = weather.Label, - title = weather.Title.Select(t => t.ToDTO()).ToList(), - description = weather.Description.Select(d => d.ToDTO()).ToList(), + title = weather.Title, + description = weather.Description, order = weather.Order, imageId = weather.ImageId, imageSource = weather.ImageSource, @@ -557,9 +566,10 @@ namespace ManagerService.Services { id = web.Id, configurationId = web.ConfigurationId, + instanceId = web.InstanceId, label = web.Label, - title = web.Title.Select(t => t.ToDTO()).ToList(), - description = web.Description.Select(d => d.ToDTO()).ToList(), + title = web.Title, + description = web.Description, order = web.Order, imageId = web.ImageId, imageSource = web.ImageSource,