From 11cfeab210cc02c7a26bf7afc3855606b0539829 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 19 Mar 2025 08:57:29 +0100 Subject: [PATCH] Updated DB (wip) --- .../Controllers/ConfigurationController.cs | 30 +- .../Controllers/DeviceController.cs | 16 +- .../Controllers/InstanceController.cs | 40 +- .../Controllers/ResourceController.cs | 33 +- .../Controllers/SectionController.cs | 56 +- ManagerService/Controllers/UserController.cs | 18 +- ManagerService/DTOs/OldSectionDTO.cs | 29 + .../DTOs/OldTranslationAndResourceDTO.cs | 14 + .../DTOs/OrderedTranslationAndResourceDTO.cs | 11 + ManagerService/DTOs/SectionDTO.cs | 1 - ManagerService/DTOs/SectionType.cs | 17 + ManagerService/DTOs/SubSection/AgendaDTO.cs | 2 +- ManagerService/DTOs/SubSection/ArticleDTO.cs | 2 +- ManagerService/DTOs/SubSection/MapDTO.cs | 11 +- ManagerService/DTOs/SubSection/MenuDTO.cs | 2 +- .../DTOs/SubSection/OldAgendaDTO.cs | 11 + .../DTOs/SubSection/OldArticleDTO.cs | 14 + ManagerService/DTOs/SubSection/OldMapDTO.cs | 58 ++ ManagerService/DTOs/SubSection/OldMenuDTO.cs | 11 + ManagerService/DTOs/SubSection/OldPdfDTO.cs | 16 + .../DTOs/SubSection/OldPuzzleDTO.cs | 14 + ManagerService/DTOs/SubSection/OldQuizzDTO.cs | 37 + .../DTOs/SubSection/OldSliderDTO.cs | 9 + ManagerService/DTOs/SubSection/OldVideoDTO.cs | 8 + .../DTOs/SubSection/OldWeatherDTO.cs | 11 + ManagerService/DTOs/SubSection/OldWebDTO.cs | 8 + ManagerService/DTOs/SubSection/PdfDTO.cs | 10 +- ManagerService/DTOs/SubSection/PuzzleDTO.cs | 2 +- ManagerService/DTOs/SubSection/QuizzDTO.cs | 2 +- ManagerService/DTOs/SubSection/SliderDTO.cs | 7 +- ManagerService/DTOs/SubSection/VideoDTO.cs | 6 +- ManagerService/DTOs/SubSection/WeatherDTO.cs | 5 +- ManagerService/DTOs/SubSection/WebDTO.cs | 6 +- .../DTOs/TranslationAndResourceDTO.cs | 5 +- ManagerService/Data/Configuration.cs | 3 +- ManagerService/Data/MyInfoMateDbContext.cs | 18 +- ManagerService/Data/OldConfiguration.cs | 147 ++++ ManagerService/Data/OldDevice.cs | 107 +++ ManagerService/Data/OldInstance.cs | 39 + ManagerService/Data/OldResource.cs | 48 + ManagerService/Data/OldSection.cs | 110 +++ ManagerService/Data/OldUser.cs | 56 ++ ManagerService/Data/Section.cs | 51 +- ManagerService/Data/SubSection/Categorie.cs | 56 ++ ManagerService/Data/SubSection/Content.cs | 56 ++ .../OrderedTranslationAndResource.cs | 44 + .../Data/SubSection/QuizQuestion.cs | 52 ++ .../Data/SubSection/SectionAgenda.cs | 50 ++ .../Data/SubSection/SectionArticle.cs | 62 ++ ManagerService/Data/SubSection/SectionMap.cs | 112 +++ ManagerService/Data/SubSection/SectionMenu.cs | 46 + ManagerService/Data/SubSection/SectionPdf.cs | 43 + .../Data/SubSection/SectionPuzzle.cs | 65 ++ ManagerService/Data/SubSection/SectionQuiz.cs | 64 ++ .../Data/SubSection/SectionSlider.cs | 46 + .../Data/SubSection/SectionVideo.cs | 41 + .../Data/SubSection/SectionWeather.cs | 51 ++ ManagerService/Data/SubSection/SectionWeb.cs | 42 + .../Data/{ => SubSection}/Translation.cs | 10 +- .../Data/SubSection/TranslationAndResource.cs | 47 + ManagerService/Helpers/LanguageInit.cs | 2 +- .../20250305163047_InitialCreate.Designer.cs | 1 + .../20250305163047_InitialCreate.cs | 2 +- .../20250319073520_UpdateDB.Designer.cs | 825 ++++++++++++++++++ .../Migrations/20250319073520_UpdateDB.cs | 596 +++++++++++++ .../MyInfoMateDbContextModelSnapshot.cs | 513 ++++++++++- .../Services/ConfigurationDatabaseService.cs | 16 +- .../Services/DeviceDatabaseService.cs | 30 +- .../Services/IHexIdGeneratorService.cs | 33 + .../Services/InstanceDatabaseService.cs | 24 +- .../Services/ResourceDatabaseService.cs | 20 +- .../Services/SectionDatabaseService.cs | 25 +- .../Services/UserDatabaseService.cs | 24 +- ManagerService/Startup.cs | 8 +- 74 files changed, 3858 insertions(+), 249 deletions(-) create mode 100644 ManagerService/DTOs/OldSectionDTO.cs create mode 100644 ManagerService/DTOs/OldTranslationAndResourceDTO.cs create mode 100644 ManagerService/DTOs/OrderedTranslationAndResourceDTO.cs create mode 100644 ManagerService/DTOs/SectionType.cs create mode 100644 ManagerService/DTOs/SubSection/OldAgendaDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldArticleDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldMapDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldMenuDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldPdfDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldPuzzleDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldQuizzDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldSliderDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldVideoDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldWeatherDTO.cs create mode 100644 ManagerService/DTOs/SubSection/OldWebDTO.cs create mode 100644 ManagerService/Data/OldConfiguration.cs create mode 100644 ManagerService/Data/OldDevice.cs create mode 100644 ManagerService/Data/OldInstance.cs create mode 100644 ManagerService/Data/OldResource.cs create mode 100644 ManagerService/Data/OldSection.cs create mode 100644 ManagerService/Data/OldUser.cs create mode 100644 ManagerService/Data/SubSection/Categorie.cs create mode 100644 ManagerService/Data/SubSection/Content.cs create mode 100644 ManagerService/Data/SubSection/OrderedTranslationAndResource.cs create mode 100644 ManagerService/Data/SubSection/QuizQuestion.cs create mode 100644 ManagerService/Data/SubSection/SectionAgenda.cs create mode 100644 ManagerService/Data/SubSection/SectionArticle.cs create mode 100644 ManagerService/Data/SubSection/SectionMap.cs create mode 100644 ManagerService/Data/SubSection/SectionMenu.cs create mode 100644 ManagerService/Data/SubSection/SectionPdf.cs create mode 100644 ManagerService/Data/SubSection/SectionPuzzle.cs create mode 100644 ManagerService/Data/SubSection/SectionQuiz.cs create mode 100644 ManagerService/Data/SubSection/SectionSlider.cs create mode 100644 ManagerService/Data/SubSection/SectionVideo.cs create mode 100644 ManagerService/Data/SubSection/SectionWeather.cs create mode 100644 ManagerService/Data/SubSection/SectionWeb.cs rename ManagerService/Data/{ => SubSection}/Translation.cs (82%) create mode 100644 ManagerService/Data/SubSection/TranslationAndResource.cs create mode 100644 ManagerService/Migrations/20250319073520_UpdateDB.Designer.cs create mode 100644 ManagerService/Migrations/20250319073520_UpdateDB.cs create mode 100644 ManagerService/Services/IHexIdGeneratorService.cs diff --git a/ManagerService/Controllers/ConfigurationController.cs b/ManagerService/Controllers/ConfigurationController.cs index 305830d..4bc30ad 100644 --- a/ManagerService/Controllers/ConfigurationController.cs +++ b/ManagerService/Controllers/ConfigurationController.cs @@ -9,7 +9,9 @@ using Manager.Helpers; using Manager.Interfaces.Models; using Manager.Services; using ManagerService.Data; +using ManagerService.Data.SubSection; using ManagerService.DTOs; +using ManagerService.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; @@ -34,6 +36,7 @@ namespace ManagerService.Controllers private DeviceDatabaseService _deviceService;*/ private readonly ILogger _logger; private readonly IConfiguration _configuration; + IHexIdGeneratorService idService = new HexIdGeneratorService(); public ConfigurationController(IConfiguration configuration, ILogger logger, MyInfoMateDbContext myInfoMateDbContext) { @@ -129,11 +132,14 @@ namespace ManagerService.Controllers try { - var weatherSections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && s.Type == SectionType.Weather && !s.IsSubSection).ToList(); // TODO TEST + //var weatherSections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && s.Type == SectionType.Weather && !s.IsSubSection).ToList(); // TODO TEST + var weatherSections = _myInfoMateDbContext.Sections.OfType() + .Where(s => s.ConfigurationId == id && !s.IsSubSection) + .ToList(); foreach (var weatherSection in weatherSections) { - WeatherDTO weatherDTO = JsonConvert.DeserializeObject(weatherSection.Data); + WeatherDTO weatherDTO = weatherSection.ToDTO();//JsonConvert.DeserializeObject(weatherSection.Data); if (weatherDTO.city != null && weatherDTO.city.Length >= 2 && (weatherDTO.updatedDate == null || weatherDTO.updatedDate.Value.AddHours(3) < DateTimeOffset.Now)) // Update all 4 hours { @@ -168,7 +174,7 @@ namespace ManagerService.Controllers weatherDTO.updatedDate = DateTimeOffset.Now; weatherDTO.result = callResponseBody; - weatherSection.Data = JsonConvert.SerializeObject(weatherDTO); // TODO update + //weatherSection.Data = JsonConvert.SerializeObject(weatherDTO); // TODO update _myInfoMateDbContext.SaveChanges(); //_sectionService.Update(weatherSection.Id, weatherSection); @@ -245,14 +251,18 @@ namespace ManagerService.Controllers //configuration.Languages = new List { "FR", "NL", "EN", "DE" }; // by default all languages configuration.Title = LanguageInit.Init("Title", configuration.Languages); - configuration.DateCreation = DateTime.Now; + configuration.DateCreation = DateTime.Now.ToUniversalTime(); configuration.IsMobile = newConfiguration.isMobile; configuration.IsTablet = newConfiguration.isTablet; configuration.IsOffline = newConfiguration.isOffline; + configuration.Id = idService.GenerateHexId(); + _myInfoMateDbContext.Configurations.Add(configuration); //Configuration configurationCreated = _configurationService.Create(configuration); + _myInfoMateDbContext.SaveChanges(); + return new OkObjectResult(configuration.ToDTO(new List())); // Empty list } catch (ArgumentNullException ex) @@ -437,7 +447,7 @@ namespace ManagerService.Controllers addResourceToList(resourceDTOs, section.imageId); } - switch (section.type) { + /*switch (section.type) { case SectionType.Map: MapDTO mapDTO = JsonConvert.DeserializeObject(section.data); if (mapDTO.iconResourceId != null) @@ -594,7 +604,7 @@ namespace ManagerService.Controllers case SectionType.Weather: default: break; - } + }*/ } ExportConfigurationDTO toDownload = configuration.ToExportDTO(sectionDTOs, resourceDTOs); string jsonString = JsonConvert.SerializeObject(toDownload); @@ -699,7 +709,7 @@ namespace ManagerService.Controllers newSection.ConfigurationId = section.configurationId; newSection.IsSubSection = section.isSubSection; newSection.ParentId = section.parentId; - newSection.Data = section.data; + //newSection.Data = section.data; newSection.DateCreation = section.dateCreation; newSection.IsBeacon = section.isBeacon; newSection.BeaconId = section.beaconId; @@ -715,7 +725,7 @@ namespace ManagerService.Controllers _myInfoMateDbContext.Sections.Add(newSection); //_sectionService.Create(newSection); - switch (section.type) + /*switch (section.type) { case SectionType.Map: MapDTO mapDTO = JsonConvert.DeserializeObject(section.data); @@ -759,7 +769,7 @@ namespace ManagerService.Controllers } break; case SectionType.Quizz: - QuizzDTO quizzDTO = JsonConvert.DeserializeObject(section.data); + QuizDTO quizzDTO = JsonConvert.DeserializeObject(section.data); foreach (var question in quizzDTO.questions) { if (question.label != null) @@ -841,7 +851,7 @@ namespace ManagerService.Controllers case SectionType.Weather: default: break; - } + }*/ } return new ObjectResult("The configuration has been successfully imported") { StatusCode = 202 }; diff --git a/ManagerService/Controllers/DeviceController.cs b/ManagerService/Controllers/DeviceController.cs index 1755a62..e20c0f1 100644 --- a/ManagerService/Controllers/DeviceController.cs +++ b/ManagerService/Controllers/DeviceController.cs @@ -40,7 +40,7 @@ namespace ManagerService.Controllers { try { - List devices = _deviceService.GetAll(instanceId); + List devices = _deviceService.GetAll(instanceId); return new OkObjectResult(devices.Select(d => d.ToDTO())); } @@ -64,7 +64,7 @@ namespace ManagerService.Controllers { try { - Device device = _deviceService.GetById(id); + OldDevice device = _deviceService.GetById(id); if (device == null) throw new KeyNotFoundException("This device was not found"); @@ -104,7 +104,7 @@ namespace ManagerService.Controllers if (configuration == null) throw new KeyNotFoundException("Configuration does not exist"); - Device device = new Device(); + OldDevice device = new OldDevice(); if (_deviceService.IsExistIdentifier(newDevice.identifier)) { // Update info @@ -129,7 +129,7 @@ namespace ManagerService.Controllers device.BatteryLevel = newDevice.batteryLevel; device.LastBatteryLevel = newDevice.lastBatteryLevel; - Device deviceCreated = _deviceService.IsExistIdentifier(newDevice.identifier) ? _deviceService.Update(device.Id, device) : _deviceService.Create(device); + OldDevice deviceCreated = _deviceService.IsExistIdentifier(newDevice.identifier) ? _deviceService.Update(device.Id, device) : _deviceService.Create(device); return new OkObjectResult(deviceCreated.ToDTO()); } @@ -168,7 +168,7 @@ namespace ManagerService.Controllers if (updatedDevice == null) throw new ArgumentNullException("Device param is null"); - Device device = _deviceService.GetById(updatedDevice.id); + OldDevice device = _deviceService.GetById(updatedDevice.id); if (device == null) throw new KeyNotFoundException("Device does not exist"); @@ -185,7 +185,7 @@ namespace ManagerService.Controllers device.BatteryLevel = updatedDevice.batteryLevel; device.LastBatteryLevel = updatedDevice.lastBatteryLevel; - Device deviceModified = _deviceService.Update(updatedDevice.id, device); + OldDevice deviceModified = _deviceService.Update(updatedDevice.id, device); return new OkObjectResult(deviceModified.ToDTO()); } @@ -219,7 +219,7 @@ namespace ManagerService.Controllers if (deviceIn == null) throw new ArgumentNullException("Device param is null"); - Device device = _deviceService.GetById(deviceIn.id); + OldDevice device = _deviceService.GetById(deviceIn.id); if (device == null) throw new KeyNotFoundException("Device does not exist"); @@ -235,7 +235,7 @@ namespace ManagerService.Controllers device.Configuration = configuration.Label; device.ConfigurationId = deviceIn.configurationId; - Device deviceModified = _deviceService.Update(device.Id, device); + OldDevice deviceModified = _deviceService.Update(device.Id, device); MqttClientService.PublishMessage($"player/{device.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true })); diff --git a/ManagerService/Controllers/InstanceController.cs b/ManagerService/Controllers/InstanceController.cs index 4a3859c..fc3cdaf 100644 --- a/ManagerService/Controllers/InstanceController.cs +++ b/ManagerService/Controllers/InstanceController.cs @@ -17,17 +17,20 @@ namespace ManagerService.Controllers [OpenApiTag("Instance", Description = "Instance management")] public class InstanceController : ControllerBase { + private readonly MyInfoMateDbContext _myInfoMateDbContext; + private InstanceDatabaseService _instanceService; private UserDatabaseService _userService; private readonly ILogger _logger; private readonly ProfileLogic _profileLogic; - public InstanceController(ILogger logger, InstanceDatabaseService instanceService, UserDatabaseService userService, ProfileLogic profileLogic) + public InstanceController(ILogger logger, InstanceDatabaseService instanceService, UserDatabaseService userService, ProfileLogic profileLogic, MyInfoMateDbContext myInfoMateDbContext) { _logger = logger; _instanceService = instanceService; _userService = userService; _profileLogic = profileLogic; + _myInfoMateDbContext = myInfoMateDbContext; } /// @@ -40,7 +43,9 @@ namespace ManagerService.Controllers { try { - List instances = _instanceService.GetAll(); + //List instances = _instanceService.GetAll(); + List instances = _myInfoMateDbContext.Instances.ToList(); + return new OkObjectResult(instances); } @@ -63,7 +68,9 @@ namespace ManagerService.Controllers { try { - Instance instance = _instanceService.GetById(id); + Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == id); + + //OldInstance instance = _instanceService.GetById(id); if (instance == null) throw new KeyNotFoundException("This instance was not found"); @@ -99,14 +106,18 @@ namespace ManagerService.Controllers newInstance.DateCreation = DateTime.Now; - List instances = _instanceService.GetAll(); + /*List instances = _instanceService.GetAll(); + Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == id);*/ - if (instances.Select(i => i.Name).Contains(newInstance.Name)) + + if (_myInfoMateDbContext.Instances.Any(i => i.Name == newInstance.Name)) throw new InvalidOperationException("This name is already used"); - Instance instanceCreated = _instanceService.Create(newInstance); + //OldInstance instanceCreated = _instanceService.Create(newInstance); + _myInfoMateDbContext.Instances.Add(newInstance); + _myInfoMateDbContext.SaveChanges(); - return new OkObjectResult(instanceCreated.ToDTO()); + return new OkObjectResult(newInstance.ToDTO()); } catch (ArgumentNullException ex) { @@ -139,14 +150,17 @@ namespace ManagerService.Controllers if (updatedInstance == null) throw new ArgumentNullException("instance param is null"); - Instance instance = _instanceService.GetById(updatedInstance.Id); + Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == updatedInstance.Id); + //OldInstance instance = _instanceService.GetById(updatedInstance.Id); if (instance == null) throw new KeyNotFoundException("instance does not exist"); - Instance instanceModified = _instanceService.Update(updatedInstance.Id, instance); + instance = updatedInstance; + //OldInstance instanceModified = _instanceService.Update(updatedInstance.Id, instance); + _myInfoMateDbContext.SaveChanges(); - return new OkObjectResult(instanceModified.ToDTO()); + return new OkObjectResult(instance.ToDTO()); } catch (ArgumentNullException ex) { @@ -175,7 +189,7 @@ namespace ManagerService.Controllers { try { - Instance instance = _instanceService.GetByPinCode(pinCode); + OldInstance instance = _instanceService.GetByPinCode(pinCode); if (instance == null) throw new KeyNotFoundException("Instance was not found"); @@ -209,10 +223,10 @@ namespace ManagerService.Controllers if (id == null) throw new ArgumentNullException("instance param is null"); - Instance instance = _instanceService.GetById(id); + OldInstance instance = _instanceService.GetById(id); // Delete all user in instance - List users = _userService.GetByInstanceId(instance.Id); + List users = _userService.GetByInstanceId(instance.Id); foreach(var user in users) { diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs index 0d2ed46..8f0effc 100644 --- a/ManagerService/Controllers/ResourceController.cs +++ b/ManagerService/Controllers/ResourceController.cs @@ -50,7 +50,7 @@ namespace ManagerService.Controllers { if (instanceId == null) throw new ArgumentNullException("InstanceId needed"); - List resources = new List(); + List resources = new List(); if (types.Count > 0) { resources = _resourceService.GetAllByType(instanceId, types); @@ -89,7 +89,7 @@ namespace ManagerService.Controllers { try { - Resource resource = _resourceService.GetById(id); + OldResource resource = _resourceService.GetById(id); if (resource == null) throw new KeyNotFoundException("This resource was not found"); @@ -149,7 +149,7 @@ namespace ManagerService.Controllers { try { - Resource resource = _resourceService.GetById(id); + OldResource resource = _resourceService.GetById(id); if (resource == null) throw new KeyNotFoundException("This resource was not found"); @@ -219,7 +219,7 @@ namespace ManagerService.Controllers throw new ArgumentNullException("One of resource params is null"); var resourceType = (ResourceType)Enum.Parse(typeof(ResourceType), type); - List resources = new List(); + List resources = new List(); foreach (var file in Request.Form.Files) { @@ -250,12 +250,12 @@ namespace ManagerService.Controllers throw new FileLoadException(message: "Fichier inexistant ou trop volumineux (max 4Mb)"); } // Todo add some verification ? - Resource resource = new Resource(); + OldResource resource = new OldResource(); resource.Label = label; resource.Type = resourceType; resource.DateCreation = DateTime.Now; resource.InstanceId = instanceId; - Resource resourceCreated = _resourceService.Create(resource); + OldResource resourceCreated = _resourceService.Create(resource); resources.Add(resourceCreated); } } @@ -296,7 +296,7 @@ namespace ManagerService.Controllers throw new ArgumentNullException("Resource param is null"); // Todo add some verification ? - Resource resource = new Resource(); + OldResource resource = new OldResource(); resource.InstanceId = newResource.instanceId; resource.Label = newResource.label; resource.Type = newResource.type; @@ -305,7 +305,7 @@ namespace ManagerService.Controllers //resource.Data = newResource.data; resource.InstanceId = newResource.instanceId; - Resource resourceCreated = _resourceService.Create(resource); + OldResource resourceCreated = _resourceService.Create(resource); return new OkObjectResult(resourceCreated.ToDTO()); // WITHOUT DATA } @@ -340,7 +340,7 @@ namespace ManagerService.Controllers if (updatedResource == null) throw new ArgumentNullException("Resource param is null"); - Resource resource = _resourceService.GetById(updatedResource.id); + OldResource resource = _resourceService.GetById(updatedResource.id); if (resource == null) throw new KeyNotFoundException("Resource does not exist"); @@ -352,7 +352,7 @@ namespace ManagerService.Controllers resource.Url = updatedResource.url; //resource.Data = updatedResource.data; // NOT ALLOWED - Resource resourceModified = _resourceService.Update(updatedResource.id, resource); + OldResource resourceModified = _resourceService.Update(updatedResource.id, resource); return new OkObjectResult(resourceModified.ToDTO()); } @@ -428,8 +428,9 @@ namespace ManagerService.Controllers foreach (var categorie in mapDTO.categories) { - categorie.iconUrl = categorie.iconResourceId == id ? null : categorie.iconUrl; - categorie.iconResourceId = categorie.iconResourceId == id ? null : categorie.iconResourceId; + // TODO + /*categorie.iconUrl = categorie.iconResourceId == id ? null : categorie.iconUrl; + categorie.iconResourceId = categorie.iconResourceId == id ? null : categorie.iconResourceId;*/ } section.Data = JsonConvert.SerializeObject(mapDTO); break; @@ -444,14 +445,16 @@ namespace ManagerService.Controllers sliderDTO.contents = contentsToKeep; section.Data = JsonConvert.SerializeObject(sliderDTO); break; - case SectionType.Quizz: - QuizzDTO quizzDTO = JsonConvert.DeserializeObject(section.Data); + // TODO + /*case SectionType.Quizz: + QuizDTO quizzDTO = JsonConvert.DeserializeObject(section.Data); foreach (var question in quizzDTO.questions) { if (question.label != null) { foreach (var questionLabel in question.label) { + questionLabel.resourceUrl = questionLabel.resourceId == id ? null : questionLabel.resourceUrl; questionLabel.resourceId = questionLabel.resourceId == id ? null : questionLabel.resourceId; } @@ -517,7 +520,7 @@ namespace ManagerService.Controllers } } section.Data = JsonConvert.SerializeObject(quizzDTO); - break; + break;*/ case SectionType.Article: ArticleDTO articleDTO = JsonConvert.DeserializeObject(section.Data); List contentsArticleToKeep = new List(); diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index 9257beb..1089d03 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -2,6 +2,7 @@ using Manager.Helpers; using Manager.Services; using ManagerService.Data; +using ManagerService.Data.SubSection; using ManagerService.DTOs; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -45,7 +46,7 @@ namespace ManagerService.Controllers { try { - List
sections = _sectionService.GetAll(instanceId); + List sections = _sectionService.GetAll(instanceId); /* CLEAN ARTICLE AUDIO - Init new field AudioIds */ @@ -93,7 +94,7 @@ namespace ManagerService.Controllers if (_configurationService.IsExist(id)) { - List
sections = _sectionService.GetAllFromConfiguration(id); + List sections = _sectionService.GetAllFromConfiguration(id); return new OkObjectResult(sections.Select(r => r.ToDTO())); } @@ -154,7 +155,7 @@ namespace ManagerService.Controllers if (id == null) throw new ArgumentNullException("Param is null"); - List
sections = _sectionService.GetAllSubSection(id); + List sections = _sectionService.GetAllSubSection(id); return new OkObjectResult(sections.Select(r => r.ToDTO())); } @@ -182,7 +183,7 @@ namespace ManagerService.Controllers { try { - Section section = _sectionService.GetById(id); + OldSection section = _sectionService.GetById(id); if (section == null) throw new KeyNotFoundException("This section was not found"); @@ -244,7 +245,7 @@ namespace ManagerService.Controllers { try { - List
sections = _sectionService.GetAll(instanceId); + List sections = _sectionService.GetAll(instanceId); sections = sections.Where(s => s.IsBeacon && s.BeaconId != null).ToList(); @@ -364,23 +365,23 @@ namespace ManagerService.Controllers mapDTO.points = new List(); mapDTO.categories = new List(); - section.Data = JsonConvert.SerializeObject(mapDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(mapDTO); // Include all info from specific section as JSON break; case SectionType.Slider: sliderDTO = new SliderDTO(); sliderDTO.contents = new List(); - section.Data = JsonConvert.SerializeObject(sliderDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(sliderDTO); // Include all info from specific section as JSON break; case SectionType.Video: VideoDTO videoDTO = new VideoDTO(); videoDTO.source = ""; - section.Data = JsonConvert.SerializeObject(videoDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(videoDTO); // Include all info from specific section as JSON break; case SectionType.Web: WebDTO webDTO = new WebDTO(); webDTO.source = ""; - section.Data = JsonConvert.SerializeObject(webDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(webDTO); // Include all info from specific section as JSON break; case SectionType.Menu: MenuDTO menuDTO = new MenuDTO(); @@ -409,12 +410,12 @@ namespace ManagerService.Controllers /*menuDTO.Sections.Add(section0DTO); menuDTO.Sections.Add(section1DTO);*/ - section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON break; case SectionType.Quizz: - QuizzDTO quizzDTO = new QuizzDTO(); + QuizDTO quizzDTO = new QuizDTO(); quizzDTO.questions = new List(); - section.Data = JsonConvert.SerializeObject(quizzDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(quizzDTO); // Include all info from specific section as JSON break; case SectionType.Article: ArticleDTO articleDTO = new ArticleDTO(); @@ -422,27 +423,28 @@ namespace ManagerService.Controllers articleDTO.content = contentArticle.Select(c => c.ToDTO()).ToList(); // TODO check articleDTO.audioIds = LanguageInit.Init("Audio", languages, true).Select(c => c.ToDTO()).ToList(); // TODO check - section.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON break; case SectionType.PDF: PdfDTO pdfDTO = new PdfDTO(); - section.Data = JsonConvert.SerializeObject(pdfDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(pdfDTO); // Include all info from specific section as JSON break; case SectionType.Puzzle: PuzzleDTO puzzleDTO = new PuzzleDTO(); - section.Data = JsonConvert.SerializeObject(puzzleDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(puzzleDTO); // Include all info from specific section as JSON break; case SectionType.Agenda: AgendaDTO agendaDTO = new AgendaDTO(); - section.Data = JsonConvert.SerializeObject(agendaDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(agendaDTO); // Include all info from specific section as JSON break; case SectionType.Weather: WeatherDTO weatherDTO = new WeatherDTO(); - section.Data = JsonConvert.SerializeObject(weatherDTO); // Include all info from specific section as JSON + //section.Data = JsonConvert.SerializeObject(weatherDTO); // Include all info from specific section as JSON break; } - Section sectionCreated = _sectionService.Create(section); + // TODO + OldSection sectionCreated = new OldSection();//_sectionService.Create(section); return new OkObjectResult(sectionCreated.ToDTO()); } @@ -528,13 +530,13 @@ namespace ManagerService.Controllers if (updatedSection == null) throw new ArgumentNullException("Section param is null"); - Section section = _sectionService.GetById(updatedSection.id); + OldSection section = _sectionService.GetById(updatedSection.id); if (section == null) throw new KeyNotFoundException("Section does not exist"); // Todo add some verification ? - section.InstanceId = updatedSection.instanceId; + /*section.InstanceId = updatedSection.instanceId; section.Label = updatedSection.label; section.Title = updatedSection.title.Select(t => new Translation().FromDTO(t)).ToList(); // TODO CHECK section.Description = updatedSection.description.Select(t => new Translation().FromDTO(t)).ToList();// TODO CHECK @@ -551,7 +553,9 @@ namespace ManagerService.Controllers section.Longitude = updatedSection.longitude; section.MeterZoneGPS = updatedSection.meterZoneGPS; - Section sectionModified = _sectionService.Update(updatedSection.id, section); + Section sectionModified = _sectionService.Update(updatedSection.id, section);*/ + // todo + Section sectionModified = new Section(); MqttClientService.PublishMessage($"config/{sectionModified.ConfigurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true })); @@ -595,7 +599,7 @@ namespace ManagerService.Controllers foreach (var updatedSection in updatedSectionsOrder) { - Section section = _sectionService.GetById(updatedSection.id); + OldSection section = _sectionService.GetById(updatedSection.id); section.Order = updatedSection.order.GetValueOrDefault(); _sectionService.Update(section.Id, section); @@ -723,11 +727,11 @@ namespace ManagerService.Controllers /// /// Useless, just to generate dto code /// - [ProducesResponseType(typeof(QuizzDTO), 200)] - [HttpGet("QuizzDTO")] - public ObjectResult GetQuizzDTO() + [ProducesResponseType(typeof(QuizDTO), 200)] + [HttpGet("QuizDTO")] + public ObjectResult GetQuizDTO() { - return new ObjectResult("QuizzDTO") { StatusCode = 200 }; + return new ObjectResult("QuizDTO") { StatusCode = 200 }; } /// diff --git a/ManagerService/Controllers/UserController.cs b/ManagerService/Controllers/UserController.cs index d4d9294..57d7ca1 100644 --- a/ManagerService/Controllers/UserController.cs +++ b/ManagerService/Controllers/UserController.cs @@ -41,7 +41,7 @@ namespace ManagerService.Controllers { try { - List users = _userService.GetAll(); + List users = _userService.GetAll(); return new OkObjectResult(users); } @@ -64,7 +64,7 @@ namespace ManagerService.Controllers { try { - User user = _userService.GetById(id); + OldUser user = _userService.GetById(id); if (user == null) throw new KeyNotFoundException("This user was not found"); @@ -91,7 +91,7 @@ namespace ManagerService.Controllers [ProducesResponseType(typeof(string), 409)] [ProducesResponseType(typeof(string), 500)] [HttpPost] - public ObjectResult CreateUser([FromBody] User newUser) + public ObjectResult CreateUser([FromBody] OldUser newUser) { try { @@ -104,14 +104,14 @@ namespace ManagerService.Controllers newUser.Token = _tokenService.GenerateToken(newUser.Email).ToString(); newUser.DateCreation = DateTime.Now; - List users = _userService.GetAll(); + List users = _userService.GetAll(); if (users.Select(u => u.Email).Contains(newUser.Email)) throw new InvalidOperationException("This Email is already used"); newUser.Password = _profileLogic.HashPassword(newUser.Password); - User userCreated = _userService.Create(newUser); + OldUser userCreated = _userService.Create(newUser); return new OkObjectResult(userCreated.ToDTO()); } @@ -139,19 +139,19 @@ namespace ManagerService.Controllers [ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 500)] [HttpPut] - public ObjectResult UpdateUser([FromBody] User updatedUser) + public ObjectResult UpdateUser([FromBody] OldUser updatedUser) { try { if (updatedUser == null) throw new ArgumentNullException("User param is null"); - User user = _userService.GetById(updatedUser.Id); + OldUser user = _userService.GetById(updatedUser.Id); if (user == null) throw new KeyNotFoundException("User does not exist"); - User userModified = _userService.Update(updatedUser.Id, updatedUser); + OldUser userModified = _userService.Update(updatedUser.Id, updatedUser); return new OkObjectResult(userModified.ToDTO()); } @@ -186,7 +186,7 @@ namespace ManagerService.Controllers if (id == null) throw new ArgumentNullException("User param is null"); - User user = _userService.GetById(id); + OldUser user = _userService.GetById(id); if (user == null) throw new KeyNotFoundException("User does not exist"); diff --git a/ManagerService/DTOs/OldSectionDTO.cs b/ManagerService/DTOs/OldSectionDTO.cs new file mode 100644 index 0000000..b132391 --- /dev/null +++ b/ManagerService/DTOs/OldSectionDTO.cs @@ -0,0 +1,29 @@ +using ManagerService.Data; +using System; +using System.Collections.Generic; + +namespace ManagerService.DTOs +{ + public class OldSectionDTO + { + public string id { get; set; } + public string label { get; set; } // use in manager + public List title { get; set; } + public List description { get; set; } + public string imageId { get; set; } // == ResourceId + public string imageSource { get; set; } // == Image url + public string configurationId { get; set; } + public bool isSubSection { get; set; } // true if part of menu type + public string parentId { get; set; } // only if it's an subsection + public SectionType type { get; set; } // !! If IsSubSection == true => Type can't not be menu ! + public string data { get; set; } // == Include section type info + public DateTime dateCreation { get; set; } // == Include section type info + public int? order { get; set; } // Order to show + public string instanceId { get; set; } + public string latitude { get; set; } // MyVisit - Use to launch automatic content when current location is near + public string longitude { get; set; } // MyVisit - Use to launch automatic content when current location is near + public int? meterZoneGPS { get; set; } // MyVisit - Nbr of meters of the zone to launch content + public bool isBeacon { get; set; } // MyVisit - True if section use beacon, false otherwise + public int? beaconId { get; set; } // MyVisit - Beacon' identifier + } +} diff --git a/ManagerService/DTOs/OldTranslationAndResourceDTO.cs b/ManagerService/DTOs/OldTranslationAndResourceDTO.cs new file mode 100644 index 0000000..c85d8ec --- /dev/null +++ b/ManagerService/DTOs/OldTranslationAndResourceDTO.cs @@ -0,0 +1,14 @@ + +using ManagerService.Data; + +namespace ManagerService.DTOs +{ + public class OldTranslationAndResourceDTO + { + public string language { get; set; } + public string value { get; set; } + public string resourceId { get; set; } // question image, audio or video + public ResourceType? resourceType { get; set; } + public string resourceUrl { get; set; } // url to firebase storage or on internet + } +} diff --git a/ManagerService/DTOs/OrderedTranslationAndResourceDTO.cs b/ManagerService/DTOs/OrderedTranslationAndResourceDTO.cs new file mode 100644 index 0000000..9f7dd23 --- /dev/null +++ b/ManagerService/DTOs/OrderedTranslationAndResourceDTO.cs @@ -0,0 +1,11 @@ + +using System.Collections.Generic; + +namespace ManagerService.DTOs +{ + public class OrderedTranslationAndResourceDTO + { + public List translationAndResourceDTOs { get; set; } + public int order { get; set; } + } +} diff --git a/ManagerService/DTOs/SectionDTO.cs b/ManagerService/DTOs/SectionDTO.cs index c30a840..038f3e4 100644 --- a/ManagerService/DTOs/SectionDTO.cs +++ b/ManagerService/DTOs/SectionDTO.cs @@ -16,7 +16,6 @@ namespace ManagerService.DTOs public bool isSubSection { get; set; } // true if part of menu type public string parentId { get; set; } // only if it's an subsection public SectionType type { get; set; } // !! If IsSubSection == true => Type can't not be menu ! - public string data { get; set; } // == Include section type info public DateTime dateCreation { get; set; } // == Include section type info public int? order { get; set; } // Order to show public string instanceId { get; set; } diff --git a/ManagerService/DTOs/SectionType.cs b/ManagerService/DTOs/SectionType.cs new file mode 100644 index 0000000..e1b0b27 --- /dev/null +++ b/ManagerService/DTOs/SectionType.cs @@ -0,0 +1,17 @@ +namespace ManagerService.DTOs +{ + public enum SectionType + { + Map, + Slider, + Video, + Web, + Menu, + Quizz, + Article, + PDF, + Puzzle, + Agenda, + Weather + } +} diff --git a/ManagerService/DTOs/SubSection/AgendaDTO.cs b/ManagerService/DTOs/SubSection/AgendaDTO.cs index 7c4f4b1..201702b 100644 --- a/ManagerService/DTOs/SubSection/AgendaDTO.cs +++ b/ManagerService/DTOs/SubSection/AgendaDTO.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Manager.DTOs { - public class AgendaDTO + public class AgendaDTO : SectionDTO { public List resourceIds { get; set; } // All json files for all languages public MapProvider? mapProvider { get; set; } // Default = Google diff --git a/ManagerService/DTOs/SubSection/ArticleDTO.cs b/ManagerService/DTOs/SubSection/ArticleDTO.cs index 3cab760..025e494 100644 --- a/ManagerService/DTOs/SubSection/ArticleDTO.cs +++ b/ManagerService/DTOs/SubSection/ArticleDTO.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Manager.DTOs { - public class ArticleDTO + public class ArticleDTO : SectionDTO { public List content { get; set; } public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise diff --git a/ManagerService/DTOs/SubSection/MapDTO.cs b/ManagerService/DTOs/SubSection/MapDTO.cs index 9e28361..d123642 100644 --- a/ManagerService/DTOs/SubSection/MapDTO.cs +++ b/ManagerService/DTOs/SubSection/MapDTO.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace Manager.DTOs { - public class MapDTO + public class MapDTO : SectionDTO { public int zoom { get; set; } // Default = 18 public MapTypeApp? mapType { get; set; } // Default = Hybrid for Google @@ -15,8 +15,8 @@ namespace Manager.DTOs public string iconResourceId { get; set; } public string iconSource { get; set; } // url to firebase storage or on internet public List categories { get; set; } - public string latitude { get; set; } // Center on - public string longitude { get; set; } // Center on + public string centerLatitude { get; set; } // Center on + public string centerLongitude { get; set; } // Center on } public class GeoPointDTO @@ -40,11 +40,10 @@ namespace Manager.DTOs public class CategorieDTO { - public int? id { get; set; } + public int id { get; set; } public List label { get; set; } public string icon { get; set; } // icon material - public string iconResourceId { get; set; } // icon point geo - public string iconUrl { get; set; } // url to firebase storage or on internet + public ResourceDTO resourceDTO { get; set; } // Icon public int? order { get; set; } // Order to show } diff --git a/ManagerService/DTOs/SubSection/MenuDTO.cs b/ManagerService/DTOs/SubSection/MenuDTO.cs index 3fd9bce..e5e1ef3 100644 --- a/ManagerService/DTOs/SubSection/MenuDTO.cs +++ b/ManagerService/DTOs/SubSection/MenuDTO.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Manager.DTOs { - public class MenuDTO + public class MenuDTO : SectionDTO { //public string Title { get; set; } // Dictionary with all languages public List sections { get; set; } diff --git a/ManagerService/DTOs/SubSection/OldAgendaDTO.cs b/ManagerService/DTOs/SubSection/OldAgendaDTO.cs new file mode 100644 index 0000000..896c9a5 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldAgendaDTO.cs @@ -0,0 +1,11 @@ +using ManagerService.DTOs; +using System.Collections.Generic; + +namespace Manager.DTOs +{ + public class OldAgendaDTO + { + public List resourceIds { get; set; } // All json files for all languages + public MapProvider? mapProvider { get; set; } // Default = Google + } +} diff --git a/ManagerService/DTOs/SubSection/OldArticleDTO.cs b/ManagerService/DTOs/SubSection/OldArticleDTO.cs new file mode 100644 index 0000000..dcc9e15 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldArticleDTO.cs @@ -0,0 +1,14 @@ +using ManagerService.DTOs; +using System.Collections.Generic; + +namespace Manager.DTOs +{ + public class OldArticleDTO + { + public List content { get; set; } + public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise + public List audioIds { get; set; } + public bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise + public List contents { get; set; } + } +} diff --git a/ManagerService/DTOs/SubSection/OldMapDTO.cs b/ManagerService/DTOs/SubSection/OldMapDTO.cs new file mode 100644 index 0000000..d034c99 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldMapDTO.cs @@ -0,0 +1,58 @@ +using Manager.Interfaces.Models; +using ManagerService.Data; +using ManagerService.DTOs; +using System.Collections.Generic; + +namespace Manager.DTOs +{ + public class OldMapDTO + { + public int zoom { get; set; } // Default = 18 + public MapTypeApp? mapType { get; set; } // Default = Hybrid for Google + public MapTypeMapBox? mapTypeMapbox { get; set; } // Default = standard for MapBox + public MapProvider? mapProvider { get; set; } // Default = Google + public List points { get; set; } + public string iconResourceId { get; set; } + public string iconSource { get; set; } // url to firebase storage or on internet + public List categories { get; set; } + public string latitude { get; set; } // Center on + public string longitude { get; set; } // Center on + } + + public class OldGeoPointDTO + { + public int? id { get; set; } + public List title { get; set; } + public List description { get; set; } + public List contents { get; set; } + public OldCategorieDTO categorie { get; set; } // TO DELETE IN FUTURE + public int? categorieId { get; set; } + public string latitude { get; set; } + public string longitude { get; set; } + public string imageResourceId { get; set; } + public string imageUrl { get; set; } + public List schedules { get; set; } + public List prices { get; set; } + public List phone { get; set; } + public List email { get; set; } + public List site { get; set; } + } + + public class OldCategorieDTO + { + public int? id { get; set; } + public List label { get; set; } + public string icon { get; set; } // icon material + public string iconResourceId { get; set; } // icon point geo + public string iconUrl { get; set; } // url to firebase storage or on internet + public int? order { get; set; } // Order to show + } + + public class OldContentGeoPoint + { + 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; } + } +} diff --git a/ManagerService/DTOs/SubSection/OldMenuDTO.cs b/ManagerService/DTOs/SubSection/OldMenuDTO.cs new file mode 100644 index 0000000..8a6e881 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldMenuDTO.cs @@ -0,0 +1,11 @@ +using ManagerService.DTOs; +using System.Collections.Generic; + +namespace Manager.DTOs +{ + public class OldMenuDTO + { + //public string Title { get; set; } // Dictionary with all languages + public List sections { get; set; } + } +} diff --git a/ManagerService/DTOs/SubSection/OldPdfDTO.cs b/ManagerService/DTOs/SubSection/OldPdfDTO.cs new file mode 100644 index 0000000..1ae01a8 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldPdfDTO.cs @@ -0,0 +1,16 @@ +using ManagerService.DTOs; +using System.Collections.Generic; + +namespace Manager.DTOs +{ + public class OldPdfDTO + { + public List pdfs { get; set; } + } + + public class OldPDFFileDTO + { + public List pdfFilesAndTitles { get; set; } + public int? order { get; set; } // Order to show + } +} diff --git a/ManagerService/DTOs/SubSection/OldPuzzleDTO.cs b/ManagerService/DTOs/SubSection/OldPuzzleDTO.cs new file mode 100644 index 0000000..4e3d7d2 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldPuzzleDTO.cs @@ -0,0 +1,14 @@ +using ManagerService.DTOs; +using System.Collections.Generic; + +namespace Manager.DTOs +{ + public class OldPuzzleDTO + { + public List messageDebut { get; set; } + public List messageFin { get; set; } + public ContentDTO image { get; set; } // But only image is possible + public int rows { get; set; } = 3; + public int cols { get; set; } = 3; + } +} diff --git a/ManagerService/DTOs/SubSection/OldQuizzDTO.cs b/ManagerService/DTOs/SubSection/OldQuizzDTO.cs new file mode 100644 index 0000000..893ac97 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldQuizzDTO.cs @@ -0,0 +1,37 @@ +using ManagerService.DTOs; +using System.Collections.Generic; +using System.Security.AccessControl; + +namespace Manager.DTOs +{ + public class OldQuizzDTO + { + public List questions { get; set; } + public OldLevelDTO bad_level { get; set; } + public OldLevelDTO medium_level { get; set; } + public OldLevelDTO good_level { get; set; } + public OldLevelDTO great_level { get; set; } + } + + public class OldQuestionDTO + { + public List label { get; set; } + public List responses { get; set; } + public string imageBackgroundResourceId { get; set; } // question image background + public ResourceType? imageBackgroundResourceType { get; set; } + public string imageBackgroundResourceUrl { get; set; } // url to firebase storage or on internet + public int order { get; set; } // Order to show + } + + public class OldResponseDTO + { + public List label { get; set; } + public bool isGood { get; set; } + public int order { get; set; } // Order to show + } + + public class OldLevelDTO + { + public List label { get; set; } + } +} diff --git a/ManagerService/DTOs/SubSection/OldSliderDTO.cs b/ManagerService/DTOs/SubSection/OldSliderDTO.cs new file mode 100644 index 0000000..598ae9f --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldSliderDTO.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Manager.DTOs +{ + public class OldSliderDTO + { + public List contents { get; set; } + } +} diff --git a/ManagerService/DTOs/SubSection/OldVideoDTO.cs b/ManagerService/DTOs/SubSection/OldVideoDTO.cs new file mode 100644 index 0000000..b24ffb5 --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldVideoDTO.cs @@ -0,0 +1,8 @@ +namespace Manager.DTOs +{ + public class OldVideoDTO + { + //public string Title { get; set; } // Dictionary with all languages + public string source { get; set; } // url to resource id (local) or on internet + } +} diff --git a/ManagerService/DTOs/SubSection/OldWeatherDTO.cs b/ManagerService/DTOs/SubSection/OldWeatherDTO.cs new file mode 100644 index 0000000..1ff5e1a --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldWeatherDTO.cs @@ -0,0 +1,11 @@ +using System; + +namespace Manager.DTOs +{ + public class OldWeatherDTO + { + public string city { get; set; } // Weather City + public DateTimeOffset? updatedDate { get; set; } // Weather date update (to only refresh) + public string result { get; set; } // Weather result + } +} diff --git a/ManagerService/DTOs/SubSection/OldWebDTO.cs b/ManagerService/DTOs/SubSection/OldWebDTO.cs new file mode 100644 index 0000000..edb6a3b --- /dev/null +++ b/ManagerService/DTOs/SubSection/OldWebDTO.cs @@ -0,0 +1,8 @@ +namespace Manager.DTOs +{ + public class OldWebDTO + { + //public string Title { get; set; } // Dictionary with all languages + public string source { get; set; } // url to resource id (local) or on internet + } +} diff --git a/ManagerService/DTOs/SubSection/PdfDTO.cs b/ManagerService/DTOs/SubSection/PdfDTO.cs index 7682e1a..943662e 100644 --- a/ManagerService/DTOs/SubSection/PdfDTO.cs +++ b/ManagerService/DTOs/SubSection/PdfDTO.cs @@ -3,14 +3,8 @@ using System.Collections.Generic; namespace Manager.DTOs { - public class PdfDTO + public class PdfDTO : SectionDTO { - public List pdfs { get; set; } - } - - public class PDFFileDTO - { - public List pdfFilesAndTitles { get; set; } - public int? order { get; set; } // Order to show + public List pdfs { get; set; } } } diff --git a/ManagerService/DTOs/SubSection/PuzzleDTO.cs b/ManagerService/DTOs/SubSection/PuzzleDTO.cs index 02f1b3e..dd28d95 100644 --- a/ManagerService/DTOs/SubSection/PuzzleDTO.cs +++ b/ManagerService/DTOs/SubSection/PuzzleDTO.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Manager.DTOs { - public class PuzzleDTO + public class PuzzleDTO : SectionDTO { public List messageDebut { get; set; } public List messageFin { get; set; } diff --git a/ManagerService/DTOs/SubSection/QuizzDTO.cs b/ManagerService/DTOs/SubSection/QuizzDTO.cs index 6ec4098..017fa06 100644 --- a/ManagerService/DTOs/SubSection/QuizzDTO.cs +++ b/ManagerService/DTOs/SubSection/QuizzDTO.cs @@ -4,7 +4,7 @@ using System.Security.AccessControl; namespace Manager.DTOs { - public class QuizzDTO + public class QuizDTO : SectionDTO { public List questions { get; set; } public LevelDTO bad_level { get; set; } diff --git a/ManagerService/DTOs/SubSection/SliderDTO.cs b/ManagerService/DTOs/SubSection/SliderDTO.cs index e89e73b..609d02c 100644 --- a/ManagerService/DTOs/SubSection/SliderDTO.cs +++ b/ManagerService/DTOs/SubSection/SliderDTO.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace Manager.DTOs { - public class SliderDTO + public class SliderDTO : SectionDTO { public List contents { get; set; } } @@ -13,9 +13,8 @@ namespace Manager.DTOs { public List title { get; set; } public List description { get; set; } - public string resourceId { get; set; } - public string resourceUrl { get; set; } // url to firebase storage or on internet public int order { get; set; } // Order to show - public ResourceType resourceType { get; set; } + public string resourceId { get; set; } + public ResourceDTO resource { get; set; } } } diff --git a/ManagerService/DTOs/SubSection/VideoDTO.cs b/ManagerService/DTOs/SubSection/VideoDTO.cs index 62967fd..556330f 100644 --- a/ManagerService/DTOs/SubSection/VideoDTO.cs +++ b/ManagerService/DTOs/SubSection/VideoDTO.cs @@ -1,6 +1,8 @@ -namespace Manager.DTOs +using ManagerService.DTOs; + +namespace Manager.DTOs { - public class VideoDTO + public class VideoDTO : SectionDTO { //public string Title { get; set; } // Dictionary with all languages public string source { get; set; } // url to resource id (local) or on internet diff --git a/ManagerService/DTOs/SubSection/WeatherDTO.cs b/ManagerService/DTOs/SubSection/WeatherDTO.cs index f3ca561..c916773 100644 --- a/ManagerService/DTOs/SubSection/WeatherDTO.cs +++ b/ManagerService/DTOs/SubSection/WeatherDTO.cs @@ -1,8 +1,9 @@ -using System; +using ManagerService.DTOs; +using System; namespace Manager.DTOs { - public class WeatherDTO + public class WeatherDTO : SectionDTO { public string city { get; set; } // Weather City public DateTimeOffset? updatedDate { get; set; } // Weather date update (to only refresh) diff --git a/ManagerService/DTOs/SubSection/WebDTO.cs b/ManagerService/DTOs/SubSection/WebDTO.cs index 4b042ab..de5293f 100644 --- a/ManagerService/DTOs/SubSection/WebDTO.cs +++ b/ManagerService/DTOs/SubSection/WebDTO.cs @@ -1,6 +1,8 @@ -namespace Manager.DTOs +using ManagerService.DTOs; + +namespace Manager.DTOs { - public class WebDTO + public class WebDTO : SectionDTO { //public string Title { get; set; } // Dictionary with all languages public string source { get; set; } // url to resource id (local) or on internet diff --git a/ManagerService/DTOs/TranslationAndResourceDTO.cs b/ManagerService/DTOs/TranslationAndResourceDTO.cs index a50b7bc..ac50c7a 100644 --- a/ManagerService/DTOs/TranslationAndResourceDTO.cs +++ b/ManagerService/DTOs/TranslationAndResourceDTO.cs @@ -7,8 +7,7 @@ namespace ManagerService.DTOs { public string language { get; set; } public string value { get; set; } - public string resourceId { get; set; } // question image, audio or video - public ResourceType? resourceType { get; set; } - public string resourceUrl { get; set; } // url to firebase storage or on internet + public string resourceId { get; set; } + public ResourceDTO resource { get; set; } } } diff --git a/ManagerService/Data/Configuration.cs b/ManagerService/Data/Configuration.cs index 87abbfb..e43f230 100644 --- a/ManagerService/Data/Configuration.cs +++ b/ManagerService/Data/Configuration.cs @@ -1,4 +1,5 @@ -using ManagerService.DTOs; +using ManagerService.Data.SubSection; +using ManagerService.DTOs; using MongoDB.Bson.Serialization.Attributes; using System; using System.Collections.Generic; diff --git a/ManagerService/Data/MyInfoMateDbContext.cs b/ManagerService/Data/MyInfoMateDbContext.cs index b056541..f20cd93 100644 --- a/ManagerService/Data/MyInfoMateDbContext.cs +++ b/ManagerService/Data/MyInfoMateDbContext.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore; +using ManagerService.Data.SubSection; +using Microsoft.EntityFrameworkCore; namespace ManagerService.Data { @@ -20,6 +21,21 @@ namespace ManagerService.Data .Property(s => s.Title) .HasColumnType("jsonb"); + modelBuilder.Entity
() + .HasDiscriminator("Discriminator") + .HasValue
("Base") + .HasValue("Agenda") + .HasValue("Article") + .HasValue("Map") + .HasValue("Menu") + .HasValue("PDF") + .HasValue("Puzzle") + .HasValue("Quiz") + .HasValue("Slider") + .HasValue("Video") + .HasValue("Weather") + .HasValue("Web"); + modelBuilder.Entity
() .Property(s => s.Title) .HasColumnType("jsonb"); diff --git a/ManagerService/Data/OldConfiguration.cs b/ManagerService/Data/OldConfiguration.cs new file mode 100644 index 0000000..9408407 --- /dev/null +++ b/ManagerService/Data/OldConfiguration.cs @@ -0,0 +1,147 @@ +using ManagerService.DTOs; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace ManagerService.Data +{ + /// + /// Configuration Information + /// + public class OldConfiguration + { + [BsonId] + [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Label")] + [BsonRequired] + public string Label { get; set; } + + [BsonElement("Title")] + [BsonRequired] + public List Title { get; set; } + + [BsonElement("ImageId")] + public string ImageId { get; set; } + + [BsonElement("ImageSource")] + public string ImageSource { get; set; } + + [BsonElement("PrimaryColor")] + public string PrimaryColor { get; set; } + + [BsonElement("SecondaryColor")] + public string SecondaryColor { get; set; } + + [BsonElement("Languages")] + public List Languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application ! + + [BsonElement("DateCreation")] + public DateTime DateCreation { get; set; } + + [BsonElement("IsMobile")] + public bool IsMobile { get; set; } + + [BsonElement("IsTablet")] + public bool IsTablet { get; set; } + + [BsonElement("IsOffline")] + public bool IsOffline { get; set; } + + [BsonElement("InstanceId")] + [BsonRequired] + public string InstanceId { get; set; } + + [BsonElement("LoaderImageId")] + public string LoaderImageId { get; set; } + + [BsonElement("LoaderImageUrl")] + public string LoaderImageUrl { get; set; } + + [BsonElement("WeatherCity")] + public string WeatherCity { get; set; } + + [BsonElement("WeatherUpdatedDate")] + public DateTimeOffset? WeatherUpdatedDate { get; set; } + + [BsonElement("WeatherResult")] + public string WeatherResult { get; set; } + + [BsonElement("IsDate")] + public bool IsDate { get; set; } + + [BsonElement("IsHour")] + public bool IsHour { get; set; } + + [BsonElement("IsSectionImageBackground")] + public bool IsSectionImageBackground { get; set; } + + [BsonElement("RoundedValue")] + public int? RoundedValue { get; set; } + + [BsonElement("ScreenPercentageSectionsMainPage")] + public int? ScreenPercentageSectionsMainPage { get; set; } + + public ConfigurationDTO ToDTO(List sectionIds) + { + return new ConfigurationDTO() + { + id = Id, + label = Label, + title = Title, + imageId = ImageId, + imageSource = ImageSource, + loaderImageId = LoaderImageId, + loaderImageUrl = LoaderImageUrl, + weatherCity = WeatherCity, + weatherUpdatedDate = WeatherUpdatedDate, + weatherResult = WeatherResult, + dateCreation = DateCreation, + primaryColor = PrimaryColor, + languages = Languages, + secondaryColor = SecondaryColor, + isMobile = IsMobile, + isTablet = IsTablet, + isOffline = IsOffline, + instanceId = InstanceId, + isDate = IsDate, + isHour = IsHour, + isSectionImageBackground = IsSectionImageBackground, + roundedValue = RoundedValue, + screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage, + sectionIds = sectionIds + }; + } + + public ExportConfigurationDTO ToExportDTO(List sections, List resources) { + return new ExportConfigurationDTO() + { + id = Id, + label = Label, + title= Title, + imageId = ImageId, + imageSource = ImageSource, + loaderImageId = LoaderImageId, + loaderImageUrl = LoaderImageUrl, + weatherCity = WeatherCity, + dateCreation = DateCreation, + primaryColor = PrimaryColor, + languages = Languages, + secondaryColor = SecondaryColor, + isMobile = IsMobile, + isTablet = IsTablet, + isOffline = IsOffline, + sections = sections, + resources = resources, + instanceId = InstanceId, + isDate = IsDate, + isSectionImageBackground = IsSectionImageBackground, + roundedValue = RoundedValue, + screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage, + sectionIds = sections.Select(s => s.id).ToList() + }; + } + } +} diff --git a/ManagerService/Data/OldDevice.cs b/ManagerService/Data/OldDevice.cs new file mode 100644 index 0000000..faf7cf3 --- /dev/null +++ b/ManagerService/Data/OldDevice.cs @@ -0,0 +1,107 @@ +using ManagerService.DTOs; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.ComponentModel.DataAnnotations; + +namespace ManagerService.Data +{ + /// + /// Device Information (Tablet) + /// + public class OldDevice + { + [BsonId] + [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Identifier")] + public string Identifier { get; set; } + + [BsonElement("Name")] + public string Name { get; set; } + + [BsonElement("IpAddressWLAN")] + [BsonRequired] + public string IpAddressWLAN { get; set; } + + [BsonElement("IpAddressETH")] + [BsonRequired] + [Required] + public string IpAddressETH { get; set; } + + [BsonElement("Configuration")] + public string Configuration { get; set; } + + [BsonElement("ConfigurationId")] + [BsonRequired] + public string ConfigurationId { get; set; } + + [BsonElement("Connected")] + [BsonRequired] + public bool Connected { get; set; } + + [BsonElement("DateCreation")] + public DateTime DateCreation { get; set; } + + [BsonElement("DateUpdate")] + public DateTime DateUpdate { get; set; } + + // BatteryLevel in case of powered devices + [BsonElement("BatteryLevel")] + public string BatteryLevel { get; set; } + + [BsonElement("LastBatteryLevel")] + public DateTime LastBatteryLevel { get; set; } + + // ConnectionLevel wifi strength level + [BsonElement("ConnectionLevel")] + public string ConnectionLevel { get; set; } + + [BsonElement("LastConnectionLevel")] + public DateTime LastConnectionLevel { get; set; } + + [BsonElement("InstanceId")] + [BsonRequired] + public string InstanceId { get; set; } + + public DeviceDTO ToDTO() + { + return new DeviceDTO() + { + id = Id, + identifier = Identifier, + name = Name, + ipAddressWLAN = IpAddressWLAN, + ipAddressETH = IpAddressETH, + connected = Connected, + configuration = Configuration, + configurationId = ConfigurationId, + dateUpdate = DateUpdate, + dateCreation = DateCreation, + instanceId = InstanceId + }; + } + + public DeviceDetailDTO ToDetailDTO() + { + return new DeviceDetailDTO() + { + id = Id, + identifier = Identifier, + name = Name, + ipAddressWLAN = IpAddressWLAN, + ipAddressETH = IpAddressETH, + connected = Connected, + configuration = Configuration, + configurationId = ConfigurationId, + connectionLevel = ConnectionLevel, + lastConnectionLevel = LastConnectionLevel, + batteryLevel = BatteryLevel, + lastBatteryLevel = LastBatteryLevel, + dateUpdate = DateUpdate, + dateCreation = DateCreation, + instanceId = InstanceId + }; + } + } +} \ No newline at end of file diff --git a/ManagerService/Data/OldInstance.cs b/ManagerService/Data/OldInstance.cs new file mode 100644 index 0000000..bbeaf84 --- /dev/null +++ b/ManagerService/Data/OldInstance.cs @@ -0,0 +1,39 @@ +using ManagerService.DTOs; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.ComponentModel.DataAnnotations; + +namespace ManagerService.Data +{ + /// + /// Instance Information + /// + public class OldInstance + { + [BsonId] + [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Name")] + [BsonRequired] + public string Name { get; set; } // UNIQUE !.. + + [BsonElement("DateCreation")] + public DateTime DateCreation { get; set; } + + [BsonElement("PinCode")] + public int? PinCode { get; set; } + + public InstanceDTO ToDTO() + { + return new InstanceDTO() + { + id = Id, + name = Name, + dateCreation = DateCreation, + pinCode = PinCode + }; + } + + } +} diff --git a/ManagerService/Data/OldResource.cs b/ManagerService/Data/OldResource.cs new file mode 100644 index 0000000..0768c9a --- /dev/null +++ b/ManagerService/Data/OldResource.cs @@ -0,0 +1,48 @@ +using ManagerService.DTOs; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.ComponentModel.DataAnnotations; + +namespace ManagerService.Data +{ + /// + /// Resource Information + /// + public class OldResource + { + [BsonId] + [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Type")] + [BsonRequired] + public ResourceType Type { get; set; } + + [BsonElement("Label")] + [BsonRequired] + public string Label { get; set; } + + [BsonElement("DateCreation")] + public DateTime DateCreation { get; set; } + + [BsonElement("InstanceId")] + [BsonRequired] + public string InstanceId { get; set; } + + [BsonElement("URL")] + public string Url { get; set; } // Firebase url + + public ResourceDTO ToDTO() + { + return new ResourceDTO() + { + id = Id, + label = Label, + type = Type, + url = Url, + dateCreation = DateCreation, + instanceId = InstanceId + }; + } + } +} diff --git a/ManagerService/Data/OldSection.cs b/ManagerService/Data/OldSection.cs new file mode 100644 index 0000000..ce6457d --- /dev/null +++ b/ManagerService/Data/OldSection.cs @@ -0,0 +1,110 @@ +using ManagerService.DTOs; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data +{ + /// + /// Section Information + /// + public class OldSection + { + [BsonId] + [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Label")] + [BsonRequired] + public string Label { get; set; } // Use in manager + + [BsonElement("Title")] + [BsonRequired] + public List Title { get; set; } + + [BsonElement("Description")] + public List Description { get; set; } + + [BsonElement("Order")] + public int Order { get; set; } + + [BsonElement("ConfigurationId")] + [BsonRequired] + public string ConfigurationId { get; set; } // Parent id + + [BsonElement("ImageId")] + [BsonRequired] + public string ImageId { get; set; } + + [BsonElement("ImageSource")] + [BsonRequired] + public string ImageSource { get; set; } + + [BsonElement("Type")] + [BsonRequired] + public SectionType Type { get; set; } + + [BsonElement("IsSubSection")] + [BsonRequired] + public bool IsSubSection { get; set; } + + [BsonElement("ParentId")] + public string ParentId { get; set; } // only if it's an subsection + + [BsonElement("DateCreation")] + public DateTime DateCreation { get; set; } + + [BsonElement("Data")] + [BsonRequired] + public string Data { get; set; } // Json encapsulated section info + + [BsonElement("InstanceId")] + [BsonRequired] + public string InstanceId { get; set; } + + [BsonElement("IsBeacon")] + public bool IsBeacon { get; set; } + + [BsonElement("BeaconId")] + public int? BeaconId { get; set; } + + [BsonElement("Latitude")] + public string Latitude { get; set; } + + [BsonElement("Longitude")] + public string Longitude { get; set; } + + [BsonElement("MeterZoneGPS")] + public int? MeterZoneGPS { get; set; } + + public SectionDTO ToDTO() + { + return new SectionDTO() + { + id = Id, + label = Label, + title = Title.OrderBy(t => t.language).ToList(), + description = Description.OrderBy(d => d.language).ToList(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + //data = Data, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + }; + } + } +} diff --git a/ManagerService/Data/OldUser.cs b/ManagerService/Data/OldUser.cs new file mode 100644 index 0000000..7185ab4 --- /dev/null +++ b/ManagerService/Data/OldUser.cs @@ -0,0 +1,56 @@ +using ManagerService.DTOs; +using MongoDB.Bson.Serialization.Attributes; +using System; +using System.ComponentModel.DataAnnotations; + +namespace ManagerService.Data +{ + /// + /// User Information + /// + public class OldUser + { + [BsonId] + [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] + public string Id { get; set; } + + [BsonElement("Email")] + [BsonRequired] + public string Email { get; set; } // UNIQUE !.. + + [BsonElement("Password")] + [BsonRequired] + public string Password { get; set; } + + [BsonElement("FirstName")] + [BsonRequired] + public string FirstName { get; set; } + + [BsonElement("LastName")] + [BsonRequired] + public string LastName { get; set; } + + [BsonElement("Token")] + [BsonRequired] + public string Token { get; set; } + + [BsonElement("DateCreation")] + public DateTime DateCreation { get; set; } + + [BsonElement("InstanceId")] + [BsonRequired] + public string InstanceId { get; set; } + + public UserDetailDTO ToDTO() + { + return new UserDetailDTO() + { + id = Id, + email = Email, + firstName = FirstName, + lastName = LastName, + }; + } + + } +} diff --git a/ManagerService/Data/Section.cs b/ManagerService/Data/Section.cs index c0ce943..00d9311 100644 --- a/ManagerService/Data/Section.cs +++ b/ManagerService/Data/Section.cs @@ -1,4 +1,5 @@ -using ManagerService.DTOs; +using ManagerService.Data.SubSection; +using ManagerService.DTOs; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -15,82 +16,50 @@ namespace ManagerService.Data { [Key] [Required] - /*[BsonId] - [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]*/ public string Id { get; set; } - //[BsonElement("Label")] - //[BsonRequired] [Required] public string Label { get; set; } // Use in manager - //[BsonElement("Title")] - //[BsonRequired] [Required] [Column(TypeName = "jsonb")] public List Title { get; set; } - //[BsonElement("Description")] [Column(TypeName = "jsonb")] public List Description { get; set; } - //[BsonElement("Order")] public int Order { get; set; } - //[BsonElement("ConfigurationId")] - //[BsonRequired] [Required] public string ConfigurationId { get; set; } // Parent id - //[BsonElement("ImageId")] - //[BsonRequired] [Required] public string ImageId { get; set; } - //[BsonElement("ImageSource")] - //[BsonRequired] [Required] public string ImageSource { get; set; } - //[BsonElement("Type")] - //[BsonRequired] [Required] public SectionType Type { get; set; } - //[BsonElement("IsSubSection")] - //[BsonRequired] [Required] public bool IsSubSection { get; set; } - //[BsonElement("ParentId")] public string ParentId { get; set; } // only if it's an subsection - //[BsonElement("DateCreation")] public DateTime DateCreation { get; set; } - //[BsonElement("Data")] - //[BsonRequired] - [Required] - public string Data { get; set; } // Json encapsulated section info - - //[BsonElement("InstanceId")] - //[BsonRequired] [Required] public string InstanceId { get; set; } - //[BsonElement("IsBeacon")] public bool IsBeacon { get; set; } - //[BsonElement("BeaconId")] public int? BeaconId { get; set; } - //[BsonElement("Latitude")] public string Latitude { get; set; } - //[BsonElement("Longitude")] public string Longitude { get; set; } - //[BsonElement("MeterZoneGPS")] public int? MeterZoneGPS { get; set; } public SectionDTO ToDTO() @@ -108,7 +77,6 @@ namespace ManagerService.Data configurationId = ConfigurationId, isSubSection = IsSubSection, parentId = ParentId, - data = Data, dateCreation = DateCreation, instanceId = InstanceId, isBeacon = IsBeacon, @@ -119,19 +87,4 @@ namespace ManagerService.Data }; } } - - public enum SectionType - { - Map, - Slider, - Video, - Web, - Menu, - Quizz, - Article, - PDF, - Puzzle, - Agenda, - Weather - } } diff --git a/ManagerService/Data/SubSection/Categorie.cs b/ManagerService/Data/SubSection/Categorie.cs new file mode 100644 index 0000000..0ef3134 --- /dev/null +++ b/ManagerService/Data/SubSection/Categorie.cs @@ -0,0 +1,56 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + +namespace ManagerService.Data.SubSection +{ + /// + /// Categorie + /// + public class Categorie + { + [Key] + [Required] + public int Id { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Label { get; set; } + + public string Icon { get; set; } // icon material + + public string ResourceId { get; set; } + + public Resource Resource { get; set; } // icon + + public int? Order { get; set; } // Order to show + + + public CategorieDTO ToDTO() + { + return new CategorieDTO() + { + id = Id, + label = Label.OrderBy(l => l.Language).Select(l => l.ToDTO()).ToList(), + icon = Icon, + order = Order, + resourceDTO = Resource.ToDTO() + }; + } + + public Categorie FromDTO(CategorieDTO categorieDTO) + { + return new Categorie() + { + Id = categorieDTO.id, + // TODO + /*Label = categorieDTO.label, + */ + }; + } + } +} diff --git a/ManagerService/Data/SubSection/Content.cs b/ManagerService/Data/SubSection/Content.cs new file mode 100644 index 0000000..ee9dea5 --- /dev/null +++ b/ManagerService/Data/SubSection/Content.cs @@ -0,0 +1,56 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + +namespace ManagerService.Data.SubSection +{ + /// + /// Content + /// + public class Content + { + [Key] + [Required] + public int Id { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Title { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Description { get; set; } + + public string ResourceId { get; set; } + public Resource Resource { get; set; } + + public int Order { get; set; } // Order to show + + public ContentDTO ToDTO() + { + 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(), + order = Order, + resourceId = ResourceId, + resource = Resource.ToDTO() + }; + } + + public Content FromDTO(ContentDTO contentDTO) + { + return new Content() + { + Title = contentDTO.title.Select(t => new Translation().FromDTO(t)).ToList(), + Description = contentDTO.description.Select(t => new Translation().FromDTO(t)).ToList(), + Order = contentDTO.order, + ResourceId = contentDTO.resourceId + }; + } + } +} diff --git a/ManagerService/Data/SubSection/OrderedTranslationAndResource.cs b/ManagerService/Data/SubSection/OrderedTranslationAndResource.cs new file mode 100644 index 0000000..920f1ee --- /dev/null +++ b/ManagerService/Data/SubSection/OrderedTranslationAndResource.cs @@ -0,0 +1,44 @@ +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + +namespace ManagerService.Data.SubSection +{ + /// + /// Ordered translationAndResource + /// + public class OrderedTranslationAndResource + { + [Key] + [Required] + public int Id { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List TranslationAndResources { get; set; } + + public int Order { get; set; } // Order to show + + + public OrderedTranslationAndResourceDTO ToDTO() + { + return new OrderedTranslationAndResourceDTO() + { + translationAndResourceDTOs = TranslationAndResources.Select(tar => tar.ToDTO()).ToList(), + order = Order + }; + } + + public OrderedTranslationAndResource FromDTO(OrderedTranslationAndResourceDTO orderedTranslationAndResourceDTO) + { + return new OrderedTranslationAndResource() + { + TranslationAndResources = orderedTranslationAndResourceDTO.translationAndResourceDTOs.Select(tar => new TranslationAndResource().FromDTO(tar)).ToList(), + Order = orderedTranslationAndResourceDTO.order + }; + } + } +} diff --git a/ManagerService/Data/SubSection/QuizQuestion.cs b/ManagerService/Data/SubSection/QuizQuestion.cs new file mode 100644 index 0000000..e27b361 --- /dev/null +++ b/ManagerService/Data/SubSection/QuizQuestion.cs @@ -0,0 +1,52 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ManagerService.Data.SubSection +{ + /// + /// Quiz question + /// + public class QuizQuestion + { + [Key] + [Required] + public int Id { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Label { get; set; } + + public string ResourceId { get; set; } // Background image id + + public Resource Resource { get; set; } // Background image + + public int Order { get; set; } // Order to show + + [Required] + [Column(TypeName = "jsonb")] + public List Responses { get; set; } // TODO check + + // TODO + /*public TranslationDTO ToDTO() + { + return new TranslationDTO() + { + language = Language, + value = Value + }; + } + + public Translation FromDTO(TranslationDTO translationDTO) + { + return new Translation() + { + Language = translationDTO.language, + Value = translationDTO.value + }; + }*/ + } +} diff --git a/ManagerService/Data/SubSection/SectionAgenda.cs b/ManagerService/Data/SubSection/SectionAgenda.cs new file mode 100644 index 0000000..268af6d --- /dev/null +++ b/ManagerService/Data/SubSection/SectionAgenda.cs @@ -0,0 +1,50 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section agenda + /// + public class SectionAgenda : Section + { + [Required] + [Column(TypeName = "jsonb")] + public List resourceIds { get; set; } // All json files for all languages + + public MapProvider? mapProvider { get; set; } // Default = Google + + public AgendaDTO ToDTO() + { + return new AgendaDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + resourceIds = resourceIds.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), + mapProvider = mapProvider + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionArticle.cs b/ManagerService/Data/SubSection/SectionArticle.cs new file mode 100644 index 0000000..b581226 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionArticle.cs @@ -0,0 +1,62 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section article + /// + public class SectionArticle: Section + { + [Required] + [Column(TypeName = "jsonb")] + public List content { get; set; } + + public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise + + [Required] + [Column(TypeName = "jsonb")] + public List audioIds { get; set; } + + public bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise + + [Required] + public List contents { get; set; } + + public ArticleDTO ToDTO() + { + return new ArticleDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + content = content.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(), + isContentTop = isContentTop, + audioIds = audioIds.Select(a=> a.ToDTO()).ToList(), + isReadAudioAuto = isReadAudioAuto, + contents = contents.Select(c => c.ToDTO()).ToList(), + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionMap.cs b/ManagerService/Data/SubSection/SectionMap.cs new file mode 100644 index 0000000..f256b10 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionMap.cs @@ -0,0 +1,112 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section map + /// + public class SectionMap : Section + { + public int Zoom { get; set; } // Default = 18 + public MapTypeApp? MapType { get; set; } // Default = Hybrid for Google + public MapTypeMapBox? MapTypeMapbox { get; set; } // Default = standard for MapBox + public MapProvider? MapProvider { get; set; } // Default = Google + public List Points { get; set; } + public string ResourceId { get; set; } + public Resource Resource { get; set; } // Icon + public List Categories { get; set; } + public string CenterLatitude { get; set; } // Center on + public string CenterLongitude { get; set; } // Center on + + + public MapDTO ToDTO() + { + return new MapDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + zoom = Zoom, + mapType = MapType, + mapTypeMapbox = MapTypeMapbox, + mapProvider = MapProvider, + //points = Points.Select(p => p.ToDTO()).ToList(), // TODO + iconResourceId = ResourceId, + categories = Categories.Select(c => c.ToDTO()).ToList(), + centerLatitude = CenterLatitude, + centerLongitude = CenterLongitude + }; + } + } + + public class GeoPoint + { + [Required] + public int? Id { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Title { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Description { get; set; } + + //TODO + [Required] + [Column(TypeName = "jsonb")] + public List Contents { get; set; } // Contentsgeopoint + + public int? CategorieId { get; set; } + + public string Latitude { get; set; } + + public string Longitude { get; set; } + + public string ImageResourceId { get; set; } + + public string ImageUrl { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Schedules { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Prices { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Phone { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Email { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Site { get; set; } + } +} diff --git a/ManagerService/Data/SubSection/SectionMenu.cs b/ManagerService/Data/SubSection/SectionMenu.cs new file mode 100644 index 0000000..ef06735 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionMenu.cs @@ -0,0 +1,46 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section menu + /// + public class SectionMenu : Section + { + [Required] + public List
Sections { get; set; } // All json files for all languages + + public MenuDTO ToDTO() + { + return new MenuDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + sections = Sections.Select(s => s.ToDTO()).ToList() + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionPdf.cs b/ManagerService/Data/SubSection/SectionPdf.cs new file mode 100644 index 0000000..9c8ce8b --- /dev/null +++ b/ManagerService/Data/SubSection/SectionPdf.cs @@ -0,0 +1,43 @@ +using Manager.DTOs; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section Pdf + /// + public class SectionPdf : Section + { + [Required] + public List orderedTranslationAndResources { get; set; } // All json files for all languages + + public PdfDTO ToDTO() + { + return new PdfDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + pdfs = orderedTranslationAndResources.Select(otar => otar.ToDTO()).ToList() + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionPuzzle.cs b/ManagerService/Data/SubSection/SectionPuzzle.cs new file mode 100644 index 0000000..122bd80 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionPuzzle.cs @@ -0,0 +1,65 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section puzzle + /// + public class SectionPuzzle : Section + { + [Required] + [Column(TypeName = "jsonb")] + public List MessageDebut { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List MessageFin { get; set; } + + public string ContentId { get; set; } // But only image is possible + public Content Content { get; set; } // But only image is possible + + [Required] + public int Rows { get; set; } = 3; + + [Required] + public int Cols { get; set; } = 3; + + + public PuzzleDTO ToDTO() + { + return new PuzzleDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + messageDebut = MessageDebut.Select(md => md.ToDTO()).ToList(), + messageFin = MessageFin.Select(mf => mf.ToDTO()).ToList(), + image = Content.ToDTO(), + rows = Rows, + cols = Cols + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionQuiz.cs b/ManagerService/Data/SubSection/SectionQuiz.cs new file mode 100644 index 0000000..57fec6d --- /dev/null +++ b/ManagerService/Data/SubSection/SectionQuiz.cs @@ -0,0 +1,64 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section quiz + /// + public class SectionQuiz : Section + { + [Required] + public List Questions { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List BadLevel { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List MediumLevel { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List GoodLevel { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List GreatLevel { get; set; } + + + public QuizDTO ToDTO() + { + return new QuizDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + //questions = Questions.Select(q => q.tod) + // TODO + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionSlider.cs b/ManagerService/Data/SubSection/SectionSlider.cs new file mode 100644 index 0000000..05516f3 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionSlider.cs @@ -0,0 +1,46 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section slider + /// + public class SectionSlider : Section + { + [Required] + public List Contents { get; set; } // TODO check + + public SliderDTO ToDTO() + { + return new SliderDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + contents = Contents.Select(c => c.ToDTO()).ToList(), + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionVideo.cs b/ManagerService/Data/SubSection/SectionVideo.cs new file mode 100644 index 0000000..cea93b2 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionVideo.cs @@ -0,0 +1,41 @@ +using Manager.DTOs; +using System.ComponentModel.DataAnnotations; +using System.Linq; + +namespace ManagerService.Data.SubSection +{ + /// + /// Section video + /// + public class SectionVideo : Section + { + [Required] + public string Source { get; set; } // url to resource id (local) or on internet + + public VideoDTO ToDTO() + { + return new VideoDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + source = Source + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionWeather.cs b/ManagerService/Data/SubSection/SectionWeather.cs new file mode 100644 index 0000000..36f0839 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionWeather.cs @@ -0,0 +1,51 @@ +using Manager.DTOs; +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section weather + /// + public class SectionWeather : Section + { + public string City { get; set; } // Weather City + + public DateTimeOffset? UpdatedDate { get; set; } // Weather date update (to only refresh) + + public string Result { get; set; } // Weather result + + public WeatherDTO ToDTO() + { + return new WeatherDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + city = City, + updatedDate = UpdatedDate, + result = Result, + }; + } + } +} diff --git a/ManagerService/Data/SubSection/SectionWeb.cs b/ManagerService/Data/SubSection/SectionWeb.cs new file mode 100644 index 0000000..73c64b1 --- /dev/null +++ b/ManagerService/Data/SubSection/SectionWeb.cs @@ -0,0 +1,42 @@ +using Manager.DTOs; +using System.ComponentModel.DataAnnotations; +using System.Linq; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section web + /// + public class SectionWeb : Section + { + [Required] + public string Source { get; set; } // url to resource id (local) or on internet + + public WebDTO ToDTO() + { + return new WebDTO() + { + 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(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + source = Source + }; + } + } +} diff --git a/ManagerService/Data/Translation.cs b/ManagerService/Data/SubSection/Translation.cs similarity index 82% rename from ManagerService/Data/Translation.cs rename to ManagerService/Data/SubSection/Translation.cs index 3d3abc9..9e98def 100644 --- a/ManagerService/Data/Translation.cs +++ b/ManagerService/Data/SubSection/Translation.cs @@ -2,7 +2,7 @@ using System; using System.ComponentModel.DataAnnotations; -namespace ManagerService.Data +namespace ManagerService.Data.SubSection { /// /// Translation @@ -11,7 +11,7 @@ namespace ManagerService.Data { [Key] [Required] - public int Id { get; set; } + public int Id { get; set; } [Required] public string Language { get; set; } @@ -36,11 +36,5 @@ namespace ManagerService.Data Value = translationDTO.value }; } - - public enum TranslationType - { - Title, - Description - } } } diff --git a/ManagerService/Data/SubSection/TranslationAndResource.cs b/ManagerService/Data/SubSection/TranslationAndResource.cs new file mode 100644 index 0000000..4f14072 --- /dev/null +++ b/ManagerService/Data/SubSection/TranslationAndResource.cs @@ -0,0 +1,47 @@ +using ManagerService.DTOs; +using System; +using System.ComponentModel.DataAnnotations; + +namespace ManagerService.Data.SubSection +{ + /// + /// Translation + /// + public class TranslationAndResource + { + [Key] + [Required] + public int Id { get; set; } + + [Required] + public string Language { get; set; } + + public string Value { get; set; } + + public string ResourceId { get; set; } + + public Resource Resource { get; set; } + + + public TranslationAndResourceDTO ToDTO() + { + return new TranslationAndResourceDTO() + { + language = Language, + value = Value, + resourceId = ResourceId, + resource = Resource.ToDTO() + }; + } + + public TranslationAndResource FromDTO(TranslationAndResourceDTO translationAndResourceDTO) + { + return new TranslationAndResource() + { + Language = translationAndResourceDTO.language, + Value = translationAndResourceDTO.value, + ResourceId = translationAndResourceDTO.resourceId + }; + } + } +} diff --git a/ManagerService/Helpers/LanguageInit.cs b/ManagerService/Helpers/LanguageInit.cs index 37733fc..60959e3 100644 --- a/ManagerService/Helpers/LanguageInit.cs +++ b/ManagerService/Helpers/LanguageInit.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using ManagerService.Data; +using ManagerService.Data.SubSection; namespace Manager.Helpers { diff --git a/ManagerService/Migrations/20250305163047_InitialCreate.Designer.cs b/ManagerService/Migrations/20250305163047_InitialCreate.Designer.cs index 89106bb..6a8c1dc 100644 --- a/ManagerService/Migrations/20250305163047_InitialCreate.Designer.cs +++ b/ManagerService/Migrations/20250305163047_InitialCreate.Designer.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using ManagerService.Data; +using ManagerService.Data.SubSection; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; diff --git a/ManagerService/Migrations/20250305163047_InitialCreate.cs b/ManagerService/Migrations/20250305163047_InitialCreate.cs index 8fbff0d..6175b92 100644 --- a/ManagerService/Migrations/20250305163047_InitialCreate.cs +++ b/ManagerService/Migrations/20250305163047_InitialCreate.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using ManagerService.Data; +using ManagerService.Data.SubSection; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable diff --git a/ManagerService/Migrations/20250319073520_UpdateDB.Designer.cs b/ManagerService/Migrations/20250319073520_UpdateDB.Designer.cs new file mode 100644 index 0000000..f0bd109 --- /dev/null +++ b/ManagerService/Migrations/20250319073520_UpdateDB.Designer.cs @@ -0,0 +1,825 @@ +// +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("20250319073520_UpdateDB")] + partial class UpdateDB + { + /// + 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.Property("WeatherCity") + .HasColumnType("text"); + + b.Property("WeatherResult") + .HasColumnType("text"); + + b.Property("WeatherUpdatedDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Configurations"); + }); + + modelBuilder.Entity("ManagerService.Data.Device", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BatteryLevel") + .HasColumnType("text"); + + b.Property("Configuration") + .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.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("integer"); + + b.HasKey("Id"); + + b.ToTable("Instances"); + }); + + modelBuilder.Entity("ManagerService.Data.Resource", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("Url") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Resources"); + }); + + modelBuilder.Entity("ManagerService.Data.Section", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BeaconId") + .HasColumnType("integer"); + + b.Property("ConfigurationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property>("Description") + .HasColumnType("jsonb"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)"); + + b.Property("ImageId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImageSource") + .IsRequired() + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsBeacon") + .HasColumnType("boolean"); + + b.Property("IsSubSection") + .HasColumnType("boolean"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text"); + + b.Property("Latitude") + .HasColumnType("text"); + + b.Property("Longitude") + .HasColumnType("text"); + + b.Property("MeterZoneGPS") + .HasColumnType("integer"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ParentId") + .HasColumnType("text"); + + b.Property("SectionMenuId") + .HasColumnType("text"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SectionMenuId"); + + b.ToTable("Sections"); + + b.HasDiscriminator().HasValue("Base"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Icon") + .HasColumnType("text"); + + b.Property>("Label") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionMapId"); + + b.ToTable("Categorie"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Description") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("SectionArticleId") + .HasColumnType("text"); + + b.Property("SectionSliderId") + .HasColumnType("text"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionArticleId"); + + b.HasIndex("SectionSliderId"); + + b.ToTable("Content"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategorieId") + .HasColumnType("integer"); + + b.Property>("Contents") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Description") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Email") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ImageResourceId") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Latitude") + .HasColumnType("text"); + + b.Property("Longitude") + .HasColumnType("text"); + + b.Property>("Phone") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Prices") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Schedules") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.Property>("Site") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionMapId"); + + b.ToTable("GeoPoint"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("SectionPdfId") + .HasColumnType("text"); + + b.Property>("TranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionPdfId"); + + b.ToTable("OrderedTranslationAndResource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Label") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property>("Responses") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionQuizId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionQuizId"); + + b.ToTable("QuizQuestion"); + }); + + modelBuilder.Entity("ManagerService.Data.User", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Token") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionAgenda", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("mapProvider") + .HasColumnType("integer"); + + b.Property>("resourceIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasDiscriminator().HasValue("Agenda"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("audioIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("content") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("isContentTop") + .HasColumnType("boolean"); + + b.Property("isReadAudioAuto") + .HasColumnType("boolean"); + + b.HasDiscriminator().HasValue("Article"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("CenterLatitude") + .HasColumnType("text"); + + b.Property("CenterLongitude") + .HasColumnType("text"); + + b.Property("MapProvider") + .HasColumnType("integer"); + + b.Property("MapType") + .HasColumnType("integer"); + + b.Property("MapTypeMapbox") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("Zoom") + .HasColumnType("integer"); + + b.HasIndex("ResourceId"); + + 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("Cols") + .HasColumnType("integer"); + + b.Property("ContentId") + .HasColumnType("text"); + + b.Property("ContentId1") + .HasColumnType("integer"); + + b.Property>("MessageDebut") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("MessageFin") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Rows") + .HasColumnType("integer"); + + b.HasIndex("ContentId1"); + + b.HasDiscriminator().HasValue("Puzzle"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("BadLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("GoodLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("GreatLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("MediumLevel") + .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("Source") + .IsRequired() + .HasColumnType("text"); + + b.HasDiscriminator().HasValue("Video"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeather", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Result") + .HasColumnType("text"); + + b.Property("UpdatedDate") + .HasColumnType("timestamp with time zone"); + + b.HasDiscriminator().HasValue("Weather"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeb", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("Source") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Sections", t => + { + t.Property("Source") + .HasColumnName("SectionWeb_Source"); + }); + + b.HasDiscriminator().HasValue("Web"); + }); + + modelBuilder.Entity("ManagerService.Data.Section", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMenu", null) + .WithMany("Sections") + .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("Categories") + .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("contents") + .HasForeignKey("SectionArticleId"); + + b.HasOne("ManagerService.Data.SubSection.SectionSlider", null) + .WithMany("Contents") + .HasForeignKey("SectionSliderId"); + + b.Navigation("Resource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMap", null) + .WithMany("Points") + .HasForeignKey("SectionMapId"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionPdf", null) + .WithMany("orderedTranslationAndResources") + .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("Questions") + .HasForeignKey("SectionQuizId"); + + b.Navigation("Resource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.HasOne("ManagerService.Data.Resource", "Resource") + .WithMany() + .HasForeignKey("ResourceId"); + + b.Navigation("Resource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b => + { + b.HasOne("ManagerService.Data.SubSection.Content", "Content") + .WithMany() + .HasForeignKey("ContentId1"); + + b.Navigation("Content"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b => + { + b.Navigation("contents"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.Navigation("Categories"); + + b.Navigation("Points"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b => + { + b.Navigation("Sections"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b => + { + b.Navigation("orderedTranslationAndResources"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.Navigation("Questions"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b => + { + b.Navigation("Contents"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ManagerService/Migrations/20250319073520_UpdateDB.cs b/ManagerService/Migrations/20250319073520_UpdateDB.cs new file mode 100644 index 0000000..c96a34e --- /dev/null +++ b/ManagerService/Migrations/20250319073520_UpdateDB.cs @@ -0,0 +1,596 @@ +using System; +using System.Collections.Generic; +using Manager.DTOs; +using ManagerService.DTOs; +using ManagerService.Data; +using ManagerService.Data.SubSection; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdateDB : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Data", + table: "Sections"); + + migrationBuilder.AddColumn>( + name: "BadLevel", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn( + name: "CenterLatitude", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "CenterLongitude", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "City", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Cols", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "ContentId", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "ContentId1", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "Discriminator", + table: "Sections", + type: "character varying(8)", + maxLength: 8, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn>( + name: "GoodLevel", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn>( + name: "GreatLevel", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapProvider", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapType", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "MapTypeMapbox", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn>( + name: "MediumLevel", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn>( + name: "MessageDebut", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn>( + name: "MessageFin", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn( + name: "ResourceId", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Result", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Rows", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "SectionMenuId", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "SectionWeb_Source", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "Source", + table: "Sections", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "UpdatedDate", + table: "Sections", + type: "timestamp with time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "Zoom", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn>( + name: "audioIds", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn>( + name: "content", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn( + name: "isContentTop", + table: "Sections", + type: "boolean", + nullable: true); + + migrationBuilder.AddColumn( + name: "isReadAudioAuto", + table: "Sections", + type: "boolean", + nullable: true); + + migrationBuilder.AddColumn( + name: "mapProvider", + table: "Sections", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn>( + name: "resourceIds", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.CreateTable( + name: "Categorie", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Label = table.Column>(type: "jsonb", nullable: false), + Icon = table.Column(type: "text", nullable: true), + ResourceId = table.Column(type: "text", nullable: true), + 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.CreateTable( + name: "Content", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column>(type: "jsonb", nullable: false), + Description = table.Column>(type: "jsonb", nullable: false), + ResourceId = table.Column(type: "text", nullable: true), + Order = table.Column(type: "integer", nullable: false), + SectionArticleId = table.Column(type: "text", nullable: true), + SectionSliderId = table.Column(type: "text", nullable: true) + }, + 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.CreateTable( + name: "GeoPoint", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column>(type: "jsonb", nullable: false), + Description = table.Column>(type: "jsonb", nullable: false), + Contents = table.Column>(type: "jsonb", nullable: false), + CategorieId = table.Column(type: "integer", nullable: true), + Latitude = table.Column(type: "text", nullable: true), + Longitude = table.Column(type: "text", nullable: true), + ImageResourceId = table.Column(type: "text", nullable: true), + ImageUrl = table.Column(type: "text", nullable: true), + Schedules = table.Column>(type: "jsonb", nullable: false), + Prices = table.Column>(type: "jsonb", nullable: false), + Phone = table.Column>(type: "jsonb", nullable: false), + Email = table.Column>(type: "jsonb", nullable: false), + Site = table.Column>(type: "jsonb", nullable: false), + SectionMapId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GeoPoint", x => x.Id); + table.ForeignKey( + name: "FK_GeoPoint_Sections_SectionMapId", + column: x => x.SectionMapId, + principalTable: "Sections", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "OrderedTranslationAndResource", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TranslationAndResources = table.Column>(type: "jsonb", nullable: false), + Order = table.Column(type: "integer", nullable: false), + SectionPdfId = table.Column(type: "text", nullable: true) + }, + 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.CreateTable( + name: "QuizQuestion", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Label = table.Column>(type: "jsonb", nullable: false), + ResourceId = table.Column(type: "text", nullable: true), + Order = table.Column(type: "integer", nullable: false), + Responses = table.Column>(type: "jsonb", nullable: false), + SectionQuizId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_QuizQuestion", x => x.Id); + table.ForeignKey( + name: "FK_QuizQuestion_Resources_ResourceId", + column: x => x.ResourceId, + principalTable: "Resources", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_QuizQuestion_Sections_SectionQuizId", + column: x => x.SectionQuizId, + principalTable: "Sections", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Sections_ContentId1", + table: "Sections", + column: "ContentId1"); + + migrationBuilder.CreateIndex( + name: "IX_Sections_ResourceId", + table: "Sections", + column: "ResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_Sections_SectionMenuId", + table: "Sections", + column: "SectionMenuId"); + + migrationBuilder.CreateIndex( + name: "IX_Categorie_ResourceId", + table: "Categorie", + column: "ResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_Categorie_SectionMapId", + table: "Categorie", + column: "SectionMapId"); + + 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.CreateIndex( + name: "IX_GeoPoint_SectionMapId", + table: "GeoPoint", + column: "SectionMapId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderedTranslationAndResource_SectionPdfId", + table: "OrderedTranslationAndResource", + column: "SectionPdfId"); + + migrationBuilder.CreateIndex( + name: "IX_QuizQuestion_ResourceId", + table: "QuizQuestion", + column: "ResourceId"); + + migrationBuilder.CreateIndex( + name: "IX_QuizQuestion_SectionQuizId", + table: "QuizQuestion", + column: "SectionQuizId"); + + migrationBuilder.AddForeignKey( + name: "FK_Sections_Content_ContentId1", + table: "Sections", + column: "ContentId1", + principalTable: "Content", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Sections_Resources_ResourceId", + table: "Sections", + column: "ResourceId", + principalTable: "Resources", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Sections_Sections_SectionMenuId", + table: "Sections", + column: "SectionMenuId", + principalTable: "Sections", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Sections_Content_ContentId1", + table: "Sections"); + + migrationBuilder.DropForeignKey( + name: "FK_Sections_Resources_ResourceId", + table: "Sections"); + + migrationBuilder.DropForeignKey( + name: "FK_Sections_Sections_SectionMenuId", + table: "Sections"); + + migrationBuilder.DropTable( + name: "Categorie"); + + migrationBuilder.DropTable( + name: "Content"); + + migrationBuilder.DropTable( + name: "GeoPoint"); + + migrationBuilder.DropTable( + name: "OrderedTranslationAndResource"); + + migrationBuilder.DropTable( + name: "QuizQuestion"); + + migrationBuilder.DropIndex( + name: "IX_Sections_ContentId1", + table: "Sections"); + + migrationBuilder.DropIndex( + name: "IX_Sections_ResourceId", + table: "Sections"); + + migrationBuilder.DropIndex( + name: "IX_Sections_SectionMenuId", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "BadLevel", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "CenterLatitude", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "CenterLongitude", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "City", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "Cols", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "ContentId", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "ContentId1", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "Discriminator", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "GoodLevel", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "GreatLevel", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "MapProvider", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "MapType", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "MapTypeMapbox", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "MediumLevel", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "MessageDebut", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "MessageFin", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "ResourceId", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "Result", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "Rows", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "SectionMenuId", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "SectionWeb_Source", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "Source", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "UpdatedDate", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "Zoom", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "audioIds", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "content", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "isContentTop", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "isReadAudioAuto", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "mapProvider", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "resourceIds", + table: "Sections"); + + migrationBuilder.AddColumn( + name: "Data", + table: "Sections", + type: "text", + nullable: false, + defaultValue: ""); + } + } +} diff --git a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs index 6346fb0..55d4d09 100644 --- a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs +++ b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs @@ -1,7 +1,10 @@ // 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.Storage.ValueConversion; @@ -217,16 +220,17 @@ namespace ManagerService.Migrations .IsRequired() .HasColumnType("text"); - b.Property("Data") - .IsRequired() - .HasColumnType("text"); - b.Property("DateCreation") .HasColumnType("timestamp with time zone"); b.Property>("Description") .HasColumnType("jsonb"); + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)"); + b.Property("ImageId") .IsRequired() .HasColumnType("text"); @@ -264,6 +268,9 @@ namespace ManagerService.Migrations b.Property("ParentId") .HasColumnType("text"); + b.Property("SectionMenuId") + .HasColumnType("text"); + b.Property>("Title") .IsRequired() .HasColumnType("jsonb"); @@ -273,7 +280,209 @@ namespace ManagerService.Migrations b.HasKey("Id"); + b.HasIndex("SectionMenuId"); + b.ToTable("Sections"); + + b.HasDiscriminator().HasValue("Base"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Icon") + .HasColumnType("text"); + + b.Property>("Label") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionMapId"); + + b.ToTable("Categorie"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Description") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("SectionArticleId") + .HasColumnType("text"); + + b.Property("SectionSliderId") + .HasColumnType("text"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionArticleId"); + + b.HasIndex("SectionSliderId"); + + b.ToTable("Content"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategorieId") + .HasColumnType("integer"); + + b.Property>("Contents") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Description") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Email") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ImageResourceId") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Latitude") + .HasColumnType("text"); + + b.Property("Longitude") + .HasColumnType("text"); + + b.Property>("Phone") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Prices") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Schedules") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.Property>("Site") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionMapId"); + + b.ToTable("GeoPoint"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("SectionPdfId") + .HasColumnType("text"); + + b.Property>("TranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionPdfId"); + + b.ToTable("OrderedTranslationAndResource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Label") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property>("Responses") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionQuizId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionQuizId"); + + b.ToTable("QuizQuestion"); }); modelBuilder.Entity("ManagerService.Data.User", b => @@ -311,6 +520,302 @@ namespace ManagerService.Migrations b.ToTable("Users"); }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionAgenda", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("mapProvider") + .HasColumnType("integer"); + + b.Property>("resourceIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasDiscriminator().HasValue("Agenda"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("audioIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("content") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("isContentTop") + .HasColumnType("boolean"); + + b.Property("isReadAudioAuto") + .HasColumnType("boolean"); + + b.HasDiscriminator().HasValue("Article"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("CenterLatitude") + .HasColumnType("text"); + + b.Property("CenterLongitude") + .HasColumnType("text"); + + b.Property("MapProvider") + .HasColumnType("integer"); + + b.Property("MapType") + .HasColumnType("integer"); + + b.Property("MapTypeMapbox") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("Zoom") + .HasColumnType("integer"); + + b.HasIndex("ResourceId"); + + 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("Cols") + .HasColumnType("integer"); + + b.Property("ContentId") + .HasColumnType("text"); + + b.Property("ContentId1") + .HasColumnType("integer"); + + b.Property>("MessageDebut") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("MessageFin") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Rows") + .HasColumnType("integer"); + + b.HasIndex("ContentId1"); + + b.HasDiscriminator().HasValue("Puzzle"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("BadLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("GoodLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("GreatLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("MediumLevel") + .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("Source") + .IsRequired() + .HasColumnType("text"); + + b.HasDiscriminator().HasValue("Video"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeather", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Result") + .HasColumnType("text"); + + b.Property("UpdatedDate") + .HasColumnType("timestamp with time zone"); + + b.HasDiscriminator().HasValue("Weather"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeb", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("Source") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Sections", t => + { + t.Property("Source") + .HasColumnName("SectionWeb_Source"); + }); + + b.HasDiscriminator().HasValue("Web"); + }); + + modelBuilder.Entity("ManagerService.Data.Section", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMenu", null) + .WithMany("Sections") + .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("Categories") + .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("contents") + .HasForeignKey("SectionArticleId"); + + b.HasOne("ManagerService.Data.SubSection.SectionSlider", null) + .WithMany("Contents") + .HasForeignKey("SectionSliderId"); + + b.Navigation("Resource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMap", null) + .WithMany("Points") + .HasForeignKey("SectionMapId"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionPdf", null) + .WithMany("orderedTranslationAndResources") + .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("Questions") + .HasForeignKey("SectionQuizId"); + + b.Navigation("Resource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.HasOne("ManagerService.Data.Resource", "Resource") + .WithMany() + .HasForeignKey("ResourceId"); + + b.Navigation("Resource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b => + { + b.HasOne("ManagerService.Data.SubSection.Content", "Content") + .WithMany() + .HasForeignKey("ContentId1"); + + b.Navigation("Content"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b => + { + b.Navigation("contents"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.Navigation("Categories"); + + b.Navigation("Points"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b => + { + b.Navigation("Sections"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b => + { + b.Navigation("orderedTranslationAndResources"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.Navigation("Questions"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b => + { + b.Navigation("Contents"); + }); #pragma warning restore 612, 618 } } diff --git a/ManagerService/Services/ConfigurationDatabaseService.cs b/ManagerService/Services/ConfigurationDatabaseService.cs index a09a455..36f6c3e 100644 --- a/ManagerService/Services/ConfigurationDatabaseService.cs +++ b/ManagerService/Services/ConfigurationDatabaseService.cs @@ -11,36 +11,36 @@ namespace Manager.Services { public class ConfigurationDatabaseService { - private readonly IMongoCollection _Configurations; + private readonly IMongoCollection _Configurations; public ConfigurationDatabaseService(IConfiguration config) { var client = new MongoClient(config.GetConnectionString("TabletDb")); var database = client.GetDatabase("TabletDb"); - _Configurations = database.GetCollection("Configurations"); + _Configurations = database.GetCollection("Configurations"); } - public List GetAll(string instanceId) + public List GetAll(string instanceId) { return _Configurations.Find(d => d.InstanceId == instanceId).ToList(); } - public Configuration GetById(string id) + public OldConfiguration GetById(string id) { - return _Configurations.Find(d => d.Id == id).FirstOrDefault(); + return _Configurations.Find(d => d.Id == id).FirstOrDefault(); } public bool IsExist(string id) { - return _Configurations.Find(d => d.Id == id).FirstOrDefault() != null ? true : false; + return _Configurations.Find(d => d.Id == id).FirstOrDefault() != null ? true : false; } - public Configuration Create(Configuration configuration) + public OldConfiguration Create(OldConfiguration configuration) { _Configurations.InsertOne(configuration); return configuration; } - public Configuration Update(string id, Configuration configurationIn) + public OldConfiguration Update(string id, OldConfiguration configurationIn) { _Configurations.ReplaceOne(d => d.Id == id, configurationIn); return configurationIn; diff --git a/ManagerService/Services/DeviceDatabaseService.cs b/ManagerService/Services/DeviceDatabaseService.cs index e859d7d..a09d38b 100644 --- a/ManagerService/Services/DeviceDatabaseService.cs +++ b/ManagerService/Services/DeviceDatabaseService.cs @@ -11,67 +11,67 @@ namespace Manager.Services { public class DeviceDatabaseService { - private readonly IMongoCollection _Devices; + private readonly IMongoCollection _Devices; public DeviceDatabaseService(IConfiguration config) { var client = new MongoClient(config.GetConnectionString("TabletDb")); var database = client.GetDatabase("TabletDb"); - _Devices = database.GetCollection("Devices"); + _Devices = database.GetCollection("Devices"); } - public List GetAll(string instanceId) + public List GetAll(string instanceId) { return _Devices.Find(d => d.InstanceId == instanceId).ToList(); } - public List GetAllConnected() + public List GetAllConnected() { return _Devices.Find(d => d.Connected).ToList(); } - public List GetAllWithConfig(string configId) + public List GetAllWithConfig(string configId) { return _Devices.Find(d => d.ConfigurationId == configId).ToList(); } - public Device GetById(string id) + public OldDevice GetById(string id) { - return _Devices.Find(d => d.Id == id).FirstOrDefault(); + return _Devices.Find(d => d.Id == id).FirstOrDefault(); } - public Device GetByIdentifier(string identifier) + public OldDevice GetByIdentifier(string identifier) { - return _Devices.Find(d => d.Identifier == identifier).FirstOrDefault(); + return _Devices.Find(d => d.Identifier == identifier).FirstOrDefault(); } public bool IsExistIdentifier(string identifier) { - return _Devices.Find(d => d.Identifier == identifier).FirstOrDefault() != null ? true : false; + return _Devices.Find(d => d.Identifier == identifier).FirstOrDefault() != null ? true : false; } public bool IsExistIpWLAN(string ip) { - return _Devices.Find(d => d.IpAddressWLAN == ip).FirstOrDefault() != null ? true : false; + return _Devices.Find(d => d.IpAddressWLAN == ip).FirstOrDefault() != null ? true : false; } public bool IsExistIpETH(string ip) { - return _Devices.Find(d => d.IpAddressETH == ip).FirstOrDefault() != null ? true : false; + return _Devices.Find(d => d.IpAddressETH == ip).FirstOrDefault() != null ? true : false; } public bool IsExist(string id) { - return _Devices.Find(d => d.Id == id).FirstOrDefault() != null ? true : false; + return _Devices.Find(d => d.Id == id).FirstOrDefault() != null ? true : false; } - public Device Create(Device device) + public OldDevice Create(OldDevice device) { _Devices.InsertOne(device); return device; } - public Device Update(string id, Device deviceIn) + public OldDevice Update(string id, OldDevice deviceIn) { _Devices.ReplaceOne(d => d.Id == id, deviceIn); return deviceIn; diff --git a/ManagerService/Services/IHexIdGeneratorService.cs b/ManagerService/Services/IHexIdGeneratorService.cs new file mode 100644 index 0000000..e8a37c3 --- /dev/null +++ b/ManagerService/Services/IHexIdGeneratorService.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Logging; +using System; +using System.Linq; + +namespace ManagerService.Services +{ + + public interface IHexIdGeneratorService + { + string GenerateHexId(); // Génère un ID hexadécimal unique + //string GenerateMongoObjectId(); // (Optionnel) Génère un vrai ObjectId MongoDB + } + + public class HexIdGeneratorService : IHexIdGeneratorService + { + private readonly Random _random = new Random(); + + // Génération d'un ID hexadécimal basé sur des bytes aléatoires + public string GenerateHexId() + { + byte[] buffer = new byte[12]; // 12 bytes → 24 caractères hex + _random.NextBytes(buffer); + return string.Concat(buffer.Select(b => b.ToString("x2"))); + } + + // Génération d'un ObjectId MongoDB (facultatif) + /*public string GenerateMongoObjectId() + { + return ObjectId.GenerateNewId().ToString(); + }*/ + } + +} diff --git a/ManagerService/Services/InstanceDatabaseService.cs b/ManagerService/Services/InstanceDatabaseService.cs index 043ccf8..fddbdea 100644 --- a/ManagerService/Services/InstanceDatabaseService.cs +++ b/ManagerService/Services/InstanceDatabaseService.cs @@ -11,46 +11,46 @@ namespace Manager.Services { public class InstanceDatabaseService { - private readonly IMongoCollection _Instances; + private readonly IMongoCollection _Instances; public InstanceDatabaseService(IConfiguration config) { var client = new MongoClient(config.GetConnectionString("TabletDb")); var database = client.GetDatabase("TabletDb"); - _Instances = database.GetCollection("Instances"); + _Instances = database.GetCollection("Instances"); } - public List GetAll() + public List GetAll() { return _Instances.Find(m => true).ToList(); } - public Instance GetByName(string name) + public OldInstance GetByName(string name) { - return _Instances.Find(i => i.Name == name).FirstOrDefault(); + return _Instances.Find(i => i.Name == name).FirstOrDefault(); } - public Instance GetById(string id) + public OldInstance GetById(string id) { - return _Instances.Find(i => i.Id == id).FirstOrDefault(); + return _Instances.Find(i => i.Id == id).FirstOrDefault(); } - public Instance GetByPinCode(int pinCode) + public OldInstance GetByPinCode(int pinCode) { - return _Instances.Find(c => c.PinCode == pinCode).FirstOrDefault(); + return _Instances.Find(c => c.PinCode == pinCode).FirstOrDefault(); } public bool IsExist(string id) { - return _Instances.Find(i => i.Id == id).FirstOrDefault() != null ? true : false; + return _Instances.Find(i => i.Id == id).FirstOrDefault() != null ? true : false; } - public Instance Create(Instance instance) + public OldInstance Create(OldInstance instance) { _Instances.InsertOne(instance); return instance; } - public Instance Update(string id, Instance instanceIn) + public OldInstance Update(string id, OldInstance instanceIn) { _Instances.ReplaceOne(instance => instance.Id == id, instanceIn); return instanceIn; diff --git a/ManagerService/Services/ResourceDatabaseService.cs b/ManagerService/Services/ResourceDatabaseService.cs index aafaf96..02aef4c 100644 --- a/ManagerService/Services/ResourceDatabaseService.cs +++ b/ManagerService/Services/ResourceDatabaseService.cs @@ -11,41 +11,41 @@ namespace Manager.Services { public class ResourceDatabaseService { - private readonly IMongoCollection _Resources; + private readonly IMongoCollection _Resources; public ResourceDatabaseService(IConfiguration config) { var client = new MongoClient(config.GetConnectionString("TabletDb")); var database = client.GetDatabase("TabletDb"); - _Resources = database.GetCollection("Resources"); + _Resources = database.GetCollection("Resources"); } - public List GetAll(string instanceId) + public List GetAll(string instanceId) { return _Resources.Find(r => r.InstanceId == instanceId).ToList(); } - public List GetAllByType(string instanceId, List types) + public List GetAllByType(string instanceId, List types) { - return _Resources.Find(r => r.InstanceId == instanceId && types.Contains(r.Type)).ToList(); + return _Resources.Find(r => r.InstanceId == instanceId && types.Contains(r.Type)).ToList(); } - public Resource GetById(string id) + public OldResource GetById(string id) { - return _Resources.Find(r => r.Id == id).FirstOrDefault(); + return _Resources.Find(r => r.Id == id).FirstOrDefault(); } public bool IsExist(string id) { - return _Resources.Find(r => r.Id == id).FirstOrDefault() != null ? true : false; + return _Resources.Find(r => r.Id == id).FirstOrDefault() != null ? true : false; } - public Resource Create(Resource resource) + public OldResource Create(OldResource resource) { _Resources.InsertOne(resource); return resource; } - public Resource Update(string id, Resource resourceIn) + public OldResource Update(string id, OldResource resourceIn) { _Resources.ReplaceOne(r => r.Id == id, resourceIn); return resourceIn; diff --git a/ManagerService/Services/SectionDatabaseService.cs b/ManagerService/Services/SectionDatabaseService.cs index da7cfdc..3614036 100644 --- a/ManagerService/Services/SectionDatabaseService.cs +++ b/ManagerService/Services/SectionDatabaseService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Manager.Interfaces.Models; using ManagerService.Data; +using ManagerService.DTOs; using Microsoft.Extensions.Configuration; using MongoDB.Driver; @@ -11,26 +12,26 @@ namespace Manager.Services { public class SectionDatabaseService { - private readonly IMongoCollection
_Sections; + private readonly IMongoCollection _Sections; public SectionDatabaseService(IConfiguration config) { var client = new MongoClient(config.GetConnectionString("TabletDb")); var database = client.GetDatabase("TabletDb"); - _Sections = database.GetCollection
("Sections"); + _Sections = database.GetCollection("Sections"); } - public List
GetAll(string instanceId) + public List GetAll(string instanceId) { return _Sections.Find(s => !s.IsSubSection && s.InstanceId == instanceId).ToList(); } - public List
GetAllFromConfiguration(string configurationId) + public List GetAllFromConfiguration(string configurationId) { return _Sections.Find(s => !s.IsSubSection && s.ConfigurationId == configurationId).ToList(); } - public List
GetAllFromConfigurationEvenSubsection(string configurationId) + public List GetAllFromConfigurationEvenSubsection(string configurationId) { return _Sections.Find(s => s.ConfigurationId == configurationId).ToList(); } @@ -40,33 +41,33 @@ namespace Manager.Services return _Sections.Find(s => !s.IsSubSection && s.ConfigurationId == configurationId).ToList().Select(s => s.Id).ToList(); } - public List
GetAllWeatherSectionsFromConfiguration(string configurationId) + public List GetAllWeatherSectionsFromConfiguration(string configurationId) { return _Sections.Find(s => s.ConfigurationId == configurationId && s.Type == SectionType.Weather).ToList(); } - public List
GetAllSubSection(string parentId) + public List GetAllSubSection(string parentId) { return _Sections.Find(s => s.IsSubSection && s.ParentId == parentId).ToList(); } - public Section GetById(string id) + public OldSection GetById(string id) { - return _Sections.Find
(s => s.Id == id).FirstOrDefault(); + return _Sections.Find(s => s.Id == id).FirstOrDefault(); } public bool IsExist(string id) { - return _Sections.Find
(s => s.Id == id).FirstOrDefault() != null ? true : false; + return _Sections.Find(s => s.Id == id).FirstOrDefault() != null ? true : false; } - public Section Create(Section section) + public OldSection Create(OldSection section) { _Sections.InsertOne(section); return section; } - public Section Update(string id, Section sectionIn) + public OldSection Update(string id, OldSection sectionIn) { _Sections.ReplaceOne(s => s.Id == id, sectionIn); return sectionIn; diff --git a/ManagerService/Services/UserDatabaseService.cs b/ManagerService/Services/UserDatabaseService.cs index 16c682a..96b7007 100644 --- a/ManagerService/Services/UserDatabaseService.cs +++ b/ManagerService/Services/UserDatabaseService.cs @@ -11,46 +11,46 @@ namespace Manager.Services { public class UserDatabaseService { - private readonly IMongoCollection _Users; + private readonly IMongoCollection _Users; public UserDatabaseService(IConfiguration config) { var client = new MongoClient(config.GetConnectionString("TabletDb")); var database = client.GetDatabase("TabletDb"); - _Users = database.GetCollection("Users"); + _Users = database.GetCollection("Users"); } - public List GetAll() + public List GetAll() { return _Users.Find(u => true).ToList(); } - public User GetByEmail(string email) + public OldUser GetByEmail(string email) { - return _Users.Find(u => u.Email == email).FirstOrDefault(); + return _Users.Find(u => u.Email == email).FirstOrDefault(); } - public User GetById(string id) + public OldUser GetById(string id) { - return _Users.Find(u => u.Id == id).FirstOrDefault(); + return _Users.Find(u => u.Id == id).FirstOrDefault(); } - public List GetByInstanceId(string id) + public List GetByInstanceId(string id) { - return _Users.Find(u => u.InstanceId == id).ToList(); + return _Users.Find(u => u.InstanceId == id).ToList(); } public bool IsExist(string id) { - return _Users.Find(u => u.Id == id).FirstOrDefault() != null ? true : false; + return _Users.Find(u => u.Id == id).FirstOrDefault() != null ? true : false; } - public User Create(User user) + public OldUser Create(OldUser user) { _Users.InsertOne(user); return user; } - public User Update(string id, User userIn) + public OldUser Update(string id, OldUser userIn) { _Users.ReplaceOne(user => user.Id == id, userIn); return userIn; diff --git a/ManagerService/Startup.cs b/ManagerService/Startup.cs index 8a21d0e..ca7ba4e 100644 --- a/ManagerService/Startup.cs +++ b/ManagerService/Startup.cs @@ -25,6 +25,7 @@ using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Tokens; using Mqtt.Client.AspNetCore.Settings; using MyCore.Service.Extensions; +using Npgsql; using NSwag; using NSwag.Generation.AspNetCore; using NSwag.Generation.Processors.Security; @@ -151,8 +152,13 @@ namespace ManagerService var connectionString = Configuration.GetConnectionString("PostgresConnection"); + var dataSourceBuilder = new NpgsqlDataSourceBuilder(connectionString); + dataSourceBuilder.EnableDynamicJson(); + var dataSource = dataSourceBuilder.Build(); + services.AddDbContext(options => - options.UseNpgsql(connectionString)); + options.UseNpgsql(dataSource) + ); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.