diff --git a/ManagerService/Controllers/ConfigurationController.cs b/ManagerService/Controllers/ConfigurationController.cs index 3d6731a..1b23e51 100644 --- a/ManagerService/Controllers/ConfigurationController.cs +++ b/ManagerService/Controllers/ConfigurationController.cs @@ -68,7 +68,7 @@ namespace ManagerService.Controllers configurationDTOs.Add(configurationDTO); } - return new OkObjectResult(configurationDTOs.OrderBy(c => c.dateCreation)); + return new OkObjectResult(configurationDTOs.OrderBy(c => c.DateCreation)); } catch (Exception ex) { @@ -224,30 +224,19 @@ namespace ManagerService.Controllers // Todo add some verification ? Configuration configuration = new Configuration(); - configuration.InstanceId = newConfiguration.instanceId; - configuration.Label = newConfiguration.label; + configuration.InstanceId = newConfiguration.InstanceId; + configuration.Label = newConfiguration.Label; configuration.Title = new List(); - configuration.ImageId = newConfiguration.imageId; - configuration.ImageSource = newConfiguration.imageSource; - configuration.PrimaryColor = newConfiguration.primaryColor; - configuration.SecondaryColor = newConfiguration.secondaryColor; - configuration.LoaderImageId = newConfiguration.loaderImageId; - configuration.LoaderImageUrl = newConfiguration.loaderImageUrl; - configuration.IsDate = newConfiguration.isDate; - configuration.IsHour = newConfiguration.isHour; - configuration.IsSectionImageBackground = true; - configuration.RoundedValue = newConfiguration.roundedValue; - configuration.ScreenPercentageSectionsMainPage = newConfiguration.screenPercentageSectionsMainPage; - - configuration.Languages = _configuration.GetSection("SupportedLanguages").Get>(); - - //configuration.Languages = new List { "FR", "NL", "EN", "DE" }; // by default all languages + configuration.ImageId = newConfiguration.ImageId; + configuration.ImageSource = newConfiguration.ImageSource; + configuration.PrimaryColor = newConfiguration.PrimaryColor; + configuration.SecondaryColor = newConfiguration.SecondaryColor; + configuration.LoaderImageId = newConfiguration.LoaderImageId; + configuration.LoaderImageUrl = newConfiguration.LoaderImageUrl; + configuration.Languages = newConfiguration.Languages; configuration.Title = LanguageInit.Init("Title", configuration.Languages); - configuration.DateCreation = DateTime.Now.ToUniversalTime(); - configuration.IsMobile = newConfiguration.isMobile; - configuration.IsTablet = newConfiguration.isTablet; - configuration.IsOffline = newConfiguration.isOffline; + configuration.IsOffline = newConfiguration.IsOffline; configuration.Id = idService.GenerateHexId(); @@ -289,30 +278,23 @@ namespace ManagerService.Controllers if (updatedConfiguration == null) throw new ArgumentNullException("configuration param is null"); - Configuration configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == updatedConfiguration.id); + Configuration configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == updatedConfiguration.Id); if (configuration == null) throw new KeyNotFoundException("Configuration does not exist"); // Todo add some verification ? - configuration.InstanceId = updatedConfiguration.instanceId; - configuration.Label = updatedConfiguration.label; - configuration.Title = updatedConfiguration.title; - configuration.ImageId = updatedConfiguration.imageId; - configuration.ImageSource = updatedConfiguration.imageSource; - configuration.PrimaryColor = updatedConfiguration.primaryColor; - configuration.SecondaryColor = updatedConfiguration.secondaryColor; - configuration.Languages = updatedConfiguration.languages; - configuration.IsMobile = updatedConfiguration.isMobile; - configuration.IsTablet = updatedConfiguration.isTablet; - configuration.IsOffline = updatedConfiguration.isOffline; - configuration.LoaderImageId = updatedConfiguration.loaderImageId; - configuration.LoaderImageUrl = updatedConfiguration.loaderImageUrl; - configuration.IsDate = updatedConfiguration.isDate; - configuration.IsHour = updatedConfiguration.isHour; - configuration.IsSectionImageBackground = updatedConfiguration.isSectionImageBackground; - configuration.RoundedValue = updatedConfiguration.roundedValue; - configuration.ScreenPercentageSectionsMainPage = updatedConfiguration.screenPercentageSectionsMainPage; + configuration.InstanceId = updatedConfiguration.InstanceId; + configuration.Label = updatedConfiguration.Label; + configuration.Title = updatedConfiguration.Title; + configuration.ImageId = updatedConfiguration.ImageId; + configuration.ImageSource = updatedConfiguration.ImageSource; + configuration.PrimaryColor = updatedConfiguration.PrimaryColor; + configuration.SecondaryColor = updatedConfiguration.SecondaryColor; + configuration.Languages = updatedConfiguration.Languages; + configuration.IsOffline = updatedConfiguration.IsOffline; + configuration.LoaderImageId = updatedConfiguration.LoaderImageId; + configuration.LoaderImageUrl = updatedConfiguration.LoaderImageUrl; //Configuration configurationModified = _configurationService.Update(updatedConfiguration.id, configuration); _myInfoMateDbContext.SaveChanges(); @@ -638,44 +620,36 @@ namespace ManagerService.Controllers if (exportConfiguration == null) throw new ArgumentNullException("File to import is null"); - Configuration configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == exportConfiguration.id); + Configuration configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == exportConfiguration.Id); if (configuration != null) throw new InvalidOperationException("Configuration already exist in the system"); configuration = new Configuration(); - configuration.Id = exportConfiguration.id; - configuration.InstanceId = exportConfiguration.instanceId; - configuration.Label = exportConfiguration.label; - configuration.Title = exportConfiguration.title; - configuration.ImageId = exportConfiguration.imageId; - configuration.ImageSource = exportConfiguration.imageSource; + configuration.Id = exportConfiguration.Id; + configuration.InstanceId = exportConfiguration.InstanceId; + configuration.Label = exportConfiguration.Label; + configuration.Title = exportConfiguration.Title; + configuration.ImageId = exportConfiguration.ImageId; + configuration.ImageSource = exportConfiguration.ImageSource; if (configuration.ImageId != null) { createResource(exportConfiguration.resources.Where(r => r.id == configuration.ImageId).FirstOrDefault()); } - configuration.DateCreation = exportConfiguration.dateCreation; - configuration.PrimaryColor = exportConfiguration.primaryColor; - configuration.SecondaryColor = exportConfiguration.secondaryColor; - configuration.Languages = exportConfiguration.languages; - configuration.IsMobile = exportConfiguration.isMobile; - configuration.IsTablet = exportConfiguration.isTablet; - configuration.IsOffline = exportConfiguration.isOffline; - configuration.LoaderImageId = exportConfiguration.loaderImageId; - configuration.LoaderImageUrl = exportConfiguration.loaderImageUrl; + configuration.DateCreation = exportConfiguration.DateCreation; + configuration.PrimaryColor = exportConfiguration.PrimaryColor; + configuration.SecondaryColor = exportConfiguration.SecondaryColor; + configuration.Languages = exportConfiguration.Languages; + configuration.IsOffline = exportConfiguration.IsOffline; + configuration.LoaderImageId = exportConfiguration.LoaderImageId; + configuration.LoaderImageUrl = exportConfiguration.LoaderImageUrl; if (configuration.LoaderImageId != null) { createResource(exportConfiguration.resources.Where(r => r.id == configuration.LoaderImageId).FirstOrDefault()); } - configuration.IsDate = exportConfiguration.isDate; - configuration.IsHour = exportConfiguration.isHour; - configuration.IsSectionImageBackground = exportConfiguration.isSectionImageBackground; - configuration.RoundedValue = exportConfiguration.roundedValue; - configuration.ScreenPercentageSectionsMainPage = exportConfiguration.screenPercentageSectionsMainPage; - _myInfoMateDbContext.Configurations.Add(configuration); //_configurationService.Create(configuration); diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index 6a3733b..17ecc8f 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -1,5 +1,6 @@ using Manager.DTOs; using Manager.Helpers; +using Manager.Interfaces.Models; using Manager.Services; using ManagerService.Data; using ManagerService.Data.SubSection; @@ -16,7 +17,10 @@ using NSwag.Annotations; using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; +using System.Security.Cryptography; using System.Text.Json; +using System.Threading.Tasks; namespace ManagerService.Controllers { @@ -135,7 +139,7 @@ namespace ManagerService.Controllers [ProducesResponseType(typeof(string), 500)] [ProducesResponseType(typeof(string), 400)] [HttpGet("configuration/{id}/detail")] - public ObjectResult GetFromConfigurationDetail(string id) + public async Task GetFromConfigurationDetail(string id) { try { @@ -170,15 +174,16 @@ namespace ManagerService.Controllers description = geoPoint.Description, contents = geoPoint.Contents, categorieId = geoPoint.CategorieId, - latitude = geoPoint.Latitude, - longitude = geoPoint.Longitude, imageResourceId = geoPoint.ImageResourceId, imageUrl = geoPoint.ImageUrl, schedules = geoPoint.Schedules, prices = geoPoint.Prices, phone = geoPoint.Phone, email = geoPoint.Email, - site = geoPoint.Site + site = geoPoint.Site, + geometryType = geoPoint.GeometryType, + polyColor = geoPoint.PolyColor, + coordinates = geoPoint.Coordinates, }); } (dto as MapDTO).points = geoPointDTOs; @@ -225,15 +230,16 @@ namespace ManagerService.Controllers description = geoPointSub.Description, contents = geoPointSub.Contents, categorieId = geoPointSub.CategorieId, - latitude = geoPointSub.Latitude, - longitude = geoPointSub.Longitude, imageResourceId = geoPointSub.ImageResourceId, imageUrl = geoPointSub.ImageUrl, schedules = geoPointSub.Schedules, prices = geoPointSub.Prices, phone = geoPointSub.Phone, email = geoPointSub.Email, - site = geoPointSub.Site + site = geoPointSub.Site, + geometryType = geoPointSub.GeometryType, + polyColor = geoPointSub.PolyColor, + coordinates = geoPointSub.Coordinates }); } (subDTO as MapDTO).points = geoPointDTOsSub; @@ -267,6 +273,71 @@ namespace ManagerService.Controllers sectionsToReturn.Add(dto); } + try + { + var weatherSections = _myInfoMateDbContext.Sections.OfType() + .Where(s => s.ConfigurationId == id && !s.IsSubSection) + .ToList(); + + foreach (var weatherSection in weatherSections) + { + if (weatherSection.WeatherCity != null && weatherSection.WeatherCity.Length >= 2 && + (weatherSection.WeatherUpdatedDate == null || weatherSection.WeatherUpdatedDate.Value.AddHours(3) < DateTimeOffset.Now)) // Update all 4 hours + { + // Call Openweather api with token from appSettings and update result with json + var apiKey = _configuration.GetSection("OpenWeatherApiKey").Get(); + + if (apiKey != null && apiKey.Length > 0) + { + string url = $"http://api.openweathermap.org/geo/1.0/direct?q={weatherSection.WeatherCity}&limit=1&appid={apiKey}"; + + using (HttpClient client = new HttpClient()) + { + try + { + HttpResponseMessage response = await client.GetAsync(url); + response.EnsureSuccessStatusCode(); + string responseBody = await response.Content.ReadAsStringAsync(); + + List cities = JsonConvert.DeserializeObject>(responseBody); + + if (cities.Count > 0) + { + double lat = cities[0].Lat; + double lon = cities[0].Lon; + + //string onecallUrl = $"https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&appid={apiKey}"; + string callUrl = $"https://api.openweathermap.org/data/2.5/forecast?lat={lat}&lon={lon}&units=metric&appid={apiKey}"; + + HttpResponseMessage callResponse = await client.GetAsync(callUrl); + callResponse.EnsureSuccessStatusCode(); + string callResponseBody = await callResponse.Content.ReadAsStringAsync(); + + + weatherSection.WeatherUpdatedDate = DateTimeOffset.Now.ToUniversalTime(); ; + weatherSection.WeatherResult = callResponseBody; + _myInfoMateDbContext.SaveChanges(); + } + else + { + Console.WriteLine("Aucune ville trouvée."); + } + } + catch (HttpRequestException e) + { + Console.WriteLine($"Une erreur s'est produite lors de la requête HTTP : {e.Message}"); + } + } + } + } + + } + } + catch (Exception e) + { + Console.WriteLine($"Une erreur s'est produite lors de la mise à jour des sections de type météo : {e.Message}"); + } + return new OkObjectResult(sectionsToReturn); } else @@ -529,15 +600,17 @@ namespace ManagerService.Controllers section.ParentId = newSection.parentId; section.Type = newSection.type; - // TODO !! - if (configuration.IsMobile) + // TODO test that in new format + section.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection) + 1; + + /*if (configuration.IsMobile) { section.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection && (s.Type == SectionType.Article || s.Type == SectionType.Quiz)) + 1; } else { section.Order = 0; // _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection) + 1; - } + }*/ section.IsBeacon = newSection.isBeacon; section.BeaconId = newSection.beaconId; @@ -816,30 +889,14 @@ namespace ManagerService.Controllers var configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == section.ConfigurationId); - if (configuration.IsMobile) + // TODO TEST that in new format + List
sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection).ToList(); + int i = 1; + List
orderedSection = sections.OrderBy(s => s.Order).ToList(); + foreach (var sectionDb in orderedSection) { - // TODO !! - // update order only with article and quiz (FOR NOW) - List
sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection && (s.Type == SectionType.Article || s.Type == SectionType.Quiz)).ToList(); - int i = 1; - List
orderedSection = sections.OrderBy(s => s.Order).ToList(); - foreach (var sectionDb in orderedSection) - { - sectionDb.Order = i; - i++; - } - } - else { - // TODO !! - // update order from rest // TODO TEST - List
sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection).ToList(); - int i = 1; - List
orderedSection = sections.OrderBy(s => s.Order).ToList(); - foreach (var sectionDb in orderedSection) - { - sectionDb.Order = i; - i++; - } + sectionDb.Order = i; + i++; } _myInfoMateDbContext.SaveChanges(); diff --git a/ManagerService/Controllers/SectionMapController.cs b/ManagerService/Controllers/SectionMapController.cs index c326b08..dd8648a 100644 --- a/ManagerService/Controllers/SectionMapController.cs +++ b/ManagerService/Controllers/SectionMapController.cs @@ -66,8 +66,9 @@ namespace ManagerService.Controllers description = point.Description, contents = point.Contents, categorieId = point.CategorieId, - latitude = point.Latitude, - longitude = point.Longitude, + geometryType = point.GeometryType, + coordinates = point.Coordinates, // TODO test that + polyColor = point.PolyColor, imageResourceId = point.ImageResourceId, imageUrl = point.ImageUrl, schedules = point.Schedules, @@ -120,8 +121,9 @@ namespace ManagerService.Controllers geoPoint.Description = geoPointDTO.description; geoPoint.Contents = geoPointDTO.contents; geoPoint.CategorieId = geoPointDTO.categorieId; - geoPoint.Latitude = geoPointDTO.latitude; - geoPoint.Longitude = geoPointDTO.longitude; + geoPoint.GeometryType = geoPointDTO.geometryType; + geoPoint.Coordinates = geoPointDTO.coordinates; // TODO TEST + geoPoint.PolyColor = geoPointDTO.polyColor; geoPoint.ImageResourceId = geoPointDTO.imageResourceId; geoPoint.ImageUrl = geoPointDTO.imageUrl; // TO BE TESTED ? Depends on front geoPoint.Schedules = geoPointDTO.schedules; @@ -145,8 +147,9 @@ namespace ManagerService.Controllers description = geoPoint.Description, contents = geoPoint.Contents, categorieId = geoPoint.CategorieId, - latitude = geoPoint.Latitude, - longitude = geoPoint.Longitude, + geometryType = geoPointDTO.geometryType, + coordinates = geoPointDTO.coordinates, // TODO TEST + polyColor = geoPointDTO.polyColor, imageResourceId = geoPoint.ImageResourceId, imageUrl = geoPoint.ImageUrl, schedules = geoPoint.Schedules, @@ -196,8 +199,9 @@ namespace ManagerService.Controllers existingGeoPoint.Description = geoPointDTO.description; existingGeoPoint.Contents = geoPointDTO.contents; existingGeoPoint.CategorieId = geoPointDTO.categorieId; - existingGeoPoint.Latitude = geoPointDTO.latitude; - existingGeoPoint.Longitude = geoPointDTO.longitude; + existingGeoPoint.GeometryType = geoPointDTO.geometryType; + existingGeoPoint.Coordinates = geoPointDTO.coordinates; // TODO TEST + existingGeoPoint.PolyColor = geoPointDTO.polyColor; existingGeoPoint.ImageResourceId = geoPointDTO.imageResourceId; existingGeoPoint.ImageUrl = geoPointDTO.imageUrl; existingGeoPoint.Schedules = geoPointDTO.schedules; diff --git a/ManagerService/DTOs/AppConfigurationLinkDTO.cs b/ManagerService/DTOs/AppConfigurationLinkDTO.cs new file mode 100644 index 0000000..639dab3 --- /dev/null +++ b/ManagerService/DTOs/AppConfigurationLinkDTO.cs @@ -0,0 +1,17 @@ +namespace ManagerService.DTOs +{ + public class AppConfigurationLinkDTO + { + public string Id { get; set; } + + public string ConfigurationId { get; set; } + + public string ApplicationInstanceId { get; set; } + + public int? Order { get; set; } + + public bool IsActive { get; set; } = true; + + public int? WeightMasonryGrid { get; set; } + } +} diff --git a/ManagerService/DTOs/ApplicationInstanceDTO.cs b/ManagerService/DTOs/ApplicationInstanceDTO.cs new file mode 100644 index 0000000..fc3c699 --- /dev/null +++ b/ManagerService/DTOs/ApplicationInstanceDTO.cs @@ -0,0 +1,40 @@ +using ManagerService.Data; +using System.Collections.Generic; + +namespace ManagerService.DTOs +{ + public class ApplicationInstanceDTO + { + public string Id { get; set; } + + public string InstanceId { get; set; } + + public AppType AppType { get; set; } + + public List Configurations { get; set; } + + public string MainImageId { get; set; } + + public string MainImageUrl { get; set; } + + public string LoaderImageId { get; set; } + + public string LoaderImageUrl { get; set; } + + public bool IsDate { get; set; } + + public bool IsHour { get; set; } + + public string PrimaryColor { get; set; } + + public string SecondaryColor { get; set; } + + public int? RoundedValue { get; set; } + + public int? ScreenPercentageSectionsMainPage { get; set; } + + public bool IsSectionImageBackground { get; set; } + + public List Languages { get; set; } + } +} diff --git a/ManagerService/DTOs/ConfigurationDTO.cs b/ManagerService/DTOs/ConfigurationDTO.cs index c6b2470..12045f3 100644 --- a/ManagerService/DTOs/ConfigurationDTO.cs +++ b/ManagerService/DTOs/ConfigurationDTO.cs @@ -5,29 +5,19 @@ namespace ManagerService.DTOs { public class ConfigurationDTO { - public string id { get; set; } - public string label { get; set; } - public List title { get; set; } - public string imageId { get; set; } // == ResourceId - public string imageSource { get; set; } // == Image url - public string primaryColor { get; set; } - public string secondaryColor { get; set; } - public List languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application ! - public DateTime dateCreation { get; set; } - public bool isMobile { get; set; } // MyVisit - True if for mobile (MyVisit) - public bool isTablet { get; set; } - public bool isOffline { get; set; } // MyVisit - True if MyVisit is full offline - /*public string latitude { get; set; } // MyVisit - latitude of visit ? (MyVisit) - public string longitude { get; set; } // MyVisit - True if for mobile (MyVisit)*/ - public string instanceId { get; set; } + public string Id { get; set; } + public string InstanceId { get; set; } + public string Label { get; set; } + public List Title { get; set; } + public string ImageId { get; set; } // == ResourceId + public string ImageSource { get; set; } // == Image url + public string PrimaryColor { get; set; } + public string SecondaryColor { get; set; } + public List Languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application ! + public DateTime DateCreation { get; set; } + public bool IsOffline { get; set; } public List sectionIds { get; set; } - public string loaderImageId { get; set; } // == ResourceId - public string loaderImageUrl { get; set; } // == Image url - public bool isDate { get; set; } - public bool isHour { get; set; } - - public bool isSectionImageBackground { get; set; } // Use to display background for section main image (or not) - public int? roundedValue { get; set; } // Use to set rounded decoration value - public int? screenPercentageSectionsMainPage { get; set; } // Use to set percentage of screen will be used to show sections (base on center) + public string LoaderImageId { get; set; } // == ResourceId + public string LoaderImageUrl { get; set; } // == Image url } } diff --git a/ManagerService/DTOs/InstanceDTO.cs b/ManagerService/DTOs/InstanceDTO.cs index 4d849f9..889b205 100644 --- a/ManagerService/DTOs/InstanceDTO.cs +++ b/ManagerService/DTOs/InstanceDTO.cs @@ -8,5 +8,10 @@ namespace ManagerService.DTOs public string name { get; set; } public DateTime? dateCreation { get; set; } public string pinCode { get; set; } + public bool isPushNotification { get; set; } + public bool isStatistic { get; set; } + public bool isMobile { get; set; } + public bool isTablet { get; set; } + public bool isVR { get; set; } } } diff --git a/ManagerService/DTOs/SectionDTO.cs b/ManagerService/DTOs/SectionDTO.cs index 1d17149..7475e04 100644 --- a/ManagerService/DTOs/SectionDTO.cs +++ b/ManagerService/DTOs/SectionDTO.cs @@ -9,6 +9,7 @@ namespace ManagerService.DTOs public string label { get; set; } // use in manager public List title { get; set; } public List description { get; set; } + public bool isActive { get; set; } public string imageId { get; set; } // == ResourceId public string imageSource { get; set; } // == Image url public string configurationId { get; set; } diff --git a/ManagerService/DTOs/SubSection/MapDTO.cs b/ManagerService/DTOs/SubSection/MapDTO.cs index fee530d..2ee8b0d 100644 --- a/ManagerService/DTOs/SubSection/MapDTO.cs +++ b/ManagerService/DTOs/SubSection/MapDTO.cs @@ -2,6 +2,8 @@ using ManagerService.Data.SubSection; using ManagerService.DTOs; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using static ManagerService.Data.SubSection.SectionEvent; namespace Manager.DTOs { @@ -26,8 +28,6 @@ namespace Manager.DTOs public List description { get; set; } public List contents { get; set; } 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; } @@ -35,6 +35,10 @@ namespace Manager.DTOs public List phone { get; set; } public List email { get; set; } public List site { get; set; } + public GeometryType geometryType { get; set; } + [Column(TypeName = "jsonb")] + public List coordinates { get; set; } = new(); // 1 point = marker, plusieurs = polyline/polygon + public string polyColor { get; set; } // color of the polyline or polygon } public class CategorieDTO diff --git a/ManagerService/Data/AppConfigurationLink.cs b/ManagerService/Data/AppConfigurationLink.cs new file mode 100644 index 0000000..717ecc0 --- /dev/null +++ b/ManagerService/Data/AppConfigurationLink.cs @@ -0,0 +1,65 @@ +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ManagerService.Data +{ + /// + /// Represents the association between an application instance (e.g., mobile or tablet app) + /// and a specific configuration. This link defines which configurations are used by which + /// application instances, optionally with an order or active status. + /// Useful for managing configuration assignment and display logic per app type. + /// + public class AppConfigurationLink + { + [Key] + public string Id { get; set; } + + [Required] + public string ConfigurationId { get; set; } + + [Required] + public string ApplicationInstanceId { get; set; } + + public int? Order { get; set; } + + public bool IsActive { get; set; } = true; + + public int? WeightMasonryGrid { get; set; } + + [ForeignKey(nameof(ConfigurationId))] + public Configuration Configuration { get; set; } + + [ForeignKey(nameof(ApplicationInstanceId))] + public ApplicationInstance ApplicationInstance { get; set; } + + public AppConfigurationLinkDTO ToDTO() + { + return new AppConfigurationLinkDTO() + { + Id = Id, + ConfigurationId = ConfigurationId, + ApplicationInstanceId = ApplicationInstanceId, + Order = Order, + IsActive = IsActive, + WeightMasonryGrid = WeightMasonryGrid + }; + } + + public AppConfigurationLink FromDTO(AppConfigurationLinkDTO appConfigurationLinkDTO) + { + return new AppConfigurationLink() + { + Id = appConfigurationLinkDTO.Id, + ConfigurationId = appConfigurationLinkDTO.ConfigurationId, + ApplicationInstanceId = appConfigurationLinkDTO.ApplicationInstanceId, + Order = appConfigurationLinkDTO.Order, + IsActive = appConfigurationLinkDTO.IsActive, + WeightMasonryGrid = appConfigurationLinkDTO?.WeightMasonryGrid, + }; + } + + } +} diff --git a/ManagerService/Data/ApplicationInstance.cs b/ManagerService/Data/ApplicationInstance.cs new file mode 100644 index 0000000..e70e78c --- /dev/null +++ b/ManagerService/Data/ApplicationInstance.cs @@ -0,0 +1,112 @@ +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace ManagerService.Data +{ + /// + /// Defines the link between an application instance and a configuration, + /// allowing apps to use one or multiple configurations. + /// + public class ApplicationInstance + { + [Key] + public string Id { get; set; } + + [Required] + public string InstanceId { get; set; } + + [Required] + public AppType AppType { get; set; } + + public List Configurations { get; set; } + + public string MainImageId { get; set; } + + public string MainImageUrl { get; set; } + + public string LoaderImageId { get; set; } + + public string LoaderImageUrl { get; set; } + + public bool IsDate { get; set; } + + public bool IsHour { get; set; } + + public string PrimaryColor { get; set; } + + public string SecondaryColor { get; set; } + + public int? RoundedValue { get; set; } + + public int? ScreenPercentageSectionsMainPage { get; set; } + + public bool IsSectionImageBackground { get; set; } // => Chose layout of main page + + public LayoutMainPageType LayoutMainPage { get; set; } = LayoutMainPageType.MasonryGrid; + + public List Languages { get; set; } // All app must support languages, if not, client's problem + + + public ApplicationInstanceDTO ToDTO() + { + return new ApplicationInstanceDTO() + { + Id = Id, + InstanceId = InstanceId, + AppType = AppType, + Configurations = Configurations, + MainImageId = MainImageId, + MainImageUrl = MainImageUrl, + LoaderImageId = LoaderImageId, + LoaderImageUrl = LoaderImageUrl, + IsDate = IsDate, + IsHour = IsHour, + PrimaryColor = PrimaryColor, + SecondaryColor = SecondaryColor, + RoundedValue = RoundedValue, + ScreenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage, + IsSectionImageBackground = IsSectionImageBackground, + Languages = Languages + }; + } + + public ApplicationInstance FromDTO(ApplicationInstanceDTO applicationInstanceDTO) + { + return new ApplicationInstance() + { + Id = applicationInstanceDTO.Id, + InstanceId = applicationInstanceDTO.InstanceId, + AppType = applicationInstanceDTO.AppType, + MainImageId = applicationInstanceDTO.MainImageId, + MainImageUrl = applicationInstanceDTO.MainImageUrl, + LoaderImageId = applicationInstanceDTO.LoaderImageId, + LoaderImageUrl = applicationInstanceDTO.LoaderImageUrl, + IsDate = applicationInstanceDTO.IsDate, + IsHour = applicationInstanceDTO.IsHour, + PrimaryColor = applicationInstanceDTO.PrimaryColor, + SecondaryColor = applicationInstanceDTO.SecondaryColor, + RoundedValue = applicationInstanceDTO.RoundedValue, + ScreenPercentageSectionsMainPage = applicationInstanceDTO.ScreenPercentageSectionsMainPage, + IsSectionImageBackground = applicationInstanceDTO.IsSectionImageBackground, + Languages = applicationInstanceDTO.Languages, + Configurations = applicationInstanceDTO.Configurations, + }; + } + + } + + public enum AppType + { + Mobile, + Tablet, + VR + } + + public enum LayoutMainPageType + { + SimpleGrid, + MasonryGrid + } +} diff --git a/ManagerService/Data/Configuration.cs b/ManagerService/Data/Configuration.cs index c99f570..e22c397 100644 --- a/ManagerService/Data/Configuration.cs +++ b/ManagerService/Data/Configuration.cs @@ -1,6 +1,4 @@ -using ManagerService.Data.SubSection; -using ManagerService.DTOs; -using MongoDB.Bson.Serialization.Attributes; +using ManagerService.DTOs; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -17,98 +15,53 @@ namespace ManagerService.Data { [Key] [Required] - /*[BsonId] - [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]*/ public string Id { get; set; } - /*[BsonElement("Label")] - [BsonRequired]*/ + [Required] + public string InstanceId { get; set; } + [Required] public string Label { get; set; } - /*[BsonElement("Title")] - [BsonRequired]*/ [Required] [Column(TypeName = "jsonb")] 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; } + public string PrimaryColor { get; set; } // Config can have their specific colors - /*[BsonElement("SecondaryColor")]*/ - public string SecondaryColor { get; set; } + public string SecondaryColor { get; set; } // Config can have their specific colors - /*[BsonElement("Languages")]*/ - public List Languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application ! + public List Languages { get; set; } // Config can support not all the languages (help to translate step by step) - /*[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]*/ - [Required] - public string InstanceId { get; set; } + public string LoaderImageId { get; set; } // Config can have their specific loader if needed - /*[BsonElement("LoaderImageId")]*/ - public string LoaderImageId { get; set; } - - /*[BsonElement("LoaderImageUrl")]*/ - public string LoaderImageUrl { 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 string LoaderImageUrl { get; set; } // Config can have their specific loader if needed public ConfigurationDTO ToDTO(List sectionIds) { return new ConfigurationDTO() { - id = Id, - label = Label, - title = Title, - imageId = ImageId, - imageSource = ImageSource, - loaderImageId = LoaderImageId, - loaderImageUrl = LoaderImageUrl, - 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, + Id = Id, + InstanceId = InstanceId, + Label = Label, + Title = Title, + ImageId = ImageId, + ImageSource = ImageSource, + LoaderImageId = LoaderImageId, + LoaderImageUrl = LoaderImageUrl, + DateCreation = DateCreation, + PrimaryColor = PrimaryColor, + Languages = Languages, + SecondaryColor = SecondaryColor, + IsOffline = IsOffline, sectionIds = sectionIds }; } @@ -116,27 +69,21 @@ namespace ManagerService.Data public ExportConfigurationDTO ToExportDTO(List sections, List resources) { return new ExportConfigurationDTO() { - id = Id, - label = Label, - title= Title, - imageId = ImageId, - imageSource = ImageSource, - loaderImageId = LoaderImageId, - loaderImageUrl = LoaderImageUrl, - dateCreation = DateCreation, - primaryColor = PrimaryColor, - languages = Languages, - secondaryColor = SecondaryColor, - isMobile = IsMobile, - isTablet = IsTablet, - isOffline = IsOffline, + Id = Id, + InstanceId = InstanceId, + Label = Label, + Title = Title, + ImageId = ImageId, + ImageSource = ImageSource, + LoaderImageId = LoaderImageId, + LoaderImageUrl = LoaderImageUrl, + DateCreation = DateCreation, + PrimaryColor = PrimaryColor, + Languages = Languages, + SecondaryColor = SecondaryColor, + 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/Instance.cs b/ManagerService/Data/Instance.cs index 948ee0a..f328774 100644 --- a/ManagerService/Data/Instance.cs +++ b/ManagerService/Data/Instance.cs @@ -11,21 +11,26 @@ namespace ManagerService.Data { [Key] [Required] - /*[BsonId] - [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]*/ public string Id { get; set; } - /*[BsonElement("Name")] - [BsonRequired]*/ [Required] public string Name { get; set; } // UNIQUE !.. - /*[BsonElement("DateCreation")]*/ public DateTime DateCreation { get; set; } - /*[BsonElement("PinCode")]*/ public string PinCode { get; set; } + public bool IsPushNotification { get; set; } + + public bool IsStatistic { get; set; } + + public bool IsMobile { get; set; } + + public bool IsTablet { get; set; } + + public bool IsVR { get; set; } + + public InstanceDTO ToDTO() { return new InstanceDTO() @@ -33,7 +38,12 @@ namespace ManagerService.Data id = Id, name = Name, dateCreation = DateCreation, - pinCode = PinCode + pinCode = PinCode, + isPushNotification = IsPushNotification, + isStatistic = IsStatistic, + isMobile = IsMobile, + isTablet = IsTablet, + isVR = IsVR, }; } @@ -44,7 +54,12 @@ namespace ManagerService.Data Id = instanceDTO.id, Name = instanceDTO.name, DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(), - PinCode = instanceDTO.pinCode + PinCode = instanceDTO.pinCode, + IsPushNotification = instanceDTO.isPushNotification, + IsStatistic = instanceDTO.isStatistic, + IsMobile = instanceDTO.isMobile, + IsTablet = instanceDTO.isTablet, + IsVR = instanceDTO.isVR }; } diff --git a/ManagerService/Data/MyInfoMateDbContext.cs b/ManagerService/Data/MyInfoMateDbContext.cs index 47a5f4c..34d6fb2 100644 --- a/ManagerService/Data/MyInfoMateDbContext.cs +++ b/ManagerService/Data/MyInfoMateDbContext.cs @@ -1,8 +1,10 @@ -using ManagerService.Data.SubSection; +using Manager.DTOs; +using ManagerService.Data.SubSection; using ManagerService.DTOs; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; using System.Text.Json; +using static ManagerService.Data.SubSection.SectionEvent; namespace ManagerService.Data { @@ -23,6 +25,9 @@ namespace ManagerService.Data // QUIZ public DbSet QuizQuestions { get; set; } + public DbSet GuidedPaths { get; set; } + public DbSet GuidedSteps { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) { var options = new JsonSerializerOptions @@ -67,6 +72,140 @@ namespace ManagerService.Data v => JsonSerializer.Serialize(v, options), v => JsonSerializer.Deserialize>(v, options)); + modelBuilder.Entity() + .Property(s => s.Title) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Description) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Coordinates) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Contents) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Schedules) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Prices) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Phone) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Email) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Site) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + // Configurations JSON pour GuidedPath + modelBuilder.Entity() + .Property(gp => gp.Title) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(gp => gp.Description) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + // Configurations JSON pour GuidedStep + modelBuilder.Entity() + .Property(gs => gs.Title) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(gs => gs.Description) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(gp => gp.ValidationQuestion) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(gp => gp.ExpectedAnswer) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(gp => gp.TimerExpiredMessage) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(gp => gp.MultipleChoiceOptions) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(gp => gp.Coordinates) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); + + modelBuilder.Entity() + .Property(s => s.Coordinates) + .HasColumnType("jsonb") + .HasConversion( + v => JsonSerializer.Serialize(v, options), + v => JsonSerializer.Deserialize>(v, options)); } } } diff --git a/ManagerService/Data/OldConfiguration.cs b/ManagerService/Data/OldConfiguration.cs index d45b1b5..8278913 100644 --- a/ManagerService/Data/OldConfiguration.cs +++ b/ManagerService/Data/OldConfiguration.cs @@ -88,26 +88,19 @@ namespace ManagerService.Data { return new ConfigurationDTO() { - id = Id, - label = Label, - title = Title, - imageId = ImageId, - imageSource = ImageSource, - loaderImageId = LoaderImageId, - loaderImageUrl = LoaderImageUrl, - 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, + Id = Id, + InstanceId = InstanceId, + Label = Label, + Title = Title, + ImageId = ImageId, + ImageSource = ImageSource, + PrimaryColor = PrimaryColor, + SecondaryColor = SecondaryColor, + Languages = Languages, + DateCreation = DateCreation, + IsOffline = IsOffline, + LoaderImageId = LoaderImageId, + LoaderImageUrl = LoaderImageUrl, sectionIds = sectionIds }; } @@ -115,27 +108,21 @@ namespace ManagerService.Data public ExportConfigurationDTO ToExportDTO(List sections, List resources) { return new ExportConfigurationDTO() { - id = Id, - label = Label, - title= Title, - imageId = ImageId, - imageSource = ImageSource, - loaderImageId = LoaderImageId, - loaderImageUrl = LoaderImageUrl, - dateCreation = DateCreation, - primaryColor = PrimaryColor, - languages = Languages, - secondaryColor = SecondaryColor, - isMobile = IsMobile, - isTablet = IsTablet, - isOffline = IsOffline, + Id = Id, + InstanceId = InstanceId, + Label = Label, + Title = Title, + ImageId = ImageId, + ImageSource = ImageSource, + PrimaryColor = PrimaryColor, + SecondaryColor = SecondaryColor, + Languages = Languages, + DateCreation = DateCreation, + IsOffline = IsOffline, + LoaderImageId = LoaderImageId, + LoaderImageUrl = LoaderImageUrl, 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/Section.cs b/ManagerService/Data/Section.cs index c1654aa..82bf12c 100644 --- a/ManagerService/Data/Section.cs +++ b/ManagerService/Data/Section.cs @@ -60,6 +60,8 @@ namespace ManagerService.Data public int? MeterZoneGPS { get; set; } + public bool isActive { get; set; } = true; + public SectionDTO ToDTO() { return new SectionDTO() @@ -68,6 +70,7 @@ namespace ManagerService.Data label = Label, title = Title, description = Description, + isActive = isActive, order = Order, type = Type, imageId = ImageId, diff --git a/ManagerService/Data/SubSection/SectionArticle.cs b/ManagerService/Data/SubSection/SectionArticle.cs index ced6b26..12451a3 100644 --- a/ManagerService/Data/SubSection/SectionArticle.cs +++ b/ManagerService/Data/SubSection/SectionArticle.cs @@ -1,10 +1,8 @@ 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 diff --git a/ManagerService/Data/SubSection/SectionEvent.cs b/ManagerService/Data/SubSection/SectionEvent.cs new file mode 100644 index 0000000..5ee15ec --- /dev/null +++ b/ManagerService/Data/SubSection/SectionEvent.cs @@ -0,0 +1,89 @@ +using ManagerService.DTOs; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +namespace ManagerService.Data.SubSection +{ + /// + /// Section event + /// + public class SectionEvent : Section + { + public DateTime StartDate { get; set; } + public DateTime EndDate { get; set; } + public List Programme { get; set; } = new(); + [Column(TypeName = "jsonb")] + public List ParcoursIds { get; set; } = new(); // Liens vers GeoPoints spécifiques + + public class ProgrammeBlock + { + [Key] + public string Id { get; set; } + [Column(TypeName = "jsonb")] + public List Title { get; set; } + [Column(TypeName = "jsonb")] + public List Description { get; set; } + public DateTime StartTime { get; set; } + public DateTime EndTime { get; set; } + + public List MapAnnotations { get; set; } + } + + public class MapAnnotation + { + [Key] + public string Id { get; set; } + [Column(TypeName = "jsonb")] + public List Type { get; set; } // "first_aid", "parking", etc. + [Column(TypeName = "jsonb")] + public List Label { get; set; } + public GeometryType GeometryType { get; set; } + [Column(TypeName = "jsonb")] + public List Coordinates { get; set; } = new(); // 1 point = marker, plusieurs = polyline/polygon + public string Icon { get; set; } // icon material if point + public ResourceDTO IconResourceDTO { get; set; } // Icon if point + } + + public enum GeometryType + { + Point, + Polyline, + Circle, + Polygon + } + + public class Coordinate + { + public double Latitude { get; set; } + public double Longitude { get; set; } + } + + /*public EventDTO ToDTO() + { + return new EventDTO() + { + id = Id, + label = Label, + title = Title.ToList(), + description = Description.ToList(), + order = Order, + type = Type, + imageId = ImageId, + imageSource = ImageSource, + configurationId = ConfigurationId, + isSubSection = IsSubSection, + parentId = ParentId, + dateCreation = DateCreation, + instanceId = InstanceId, + isBeacon = IsBeacon, + beaconId = BeaconId, + latitude = Latitude, + longitude = Longitude, + meterZoneGPS = MeterZoneGPS, + }; + }*/ + } +} diff --git a/ManagerService/Data/SubSection/SectionMap.cs b/ManagerService/Data/SubSection/SectionMap.cs index 43175b1..1b5586c 100644 --- a/ManagerService/Data/SubSection/SectionMap.cs +++ b/ManagerService/Data/SubSection/SectionMap.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; +using static ManagerService.Data.SubSection.SectionEvent; namespace ManagerService.Data.SubSection @@ -81,9 +82,12 @@ namespace ManagerService.Data.SubSection public int? CategorieId { get; set; } - public string Latitude { get; set; } + public GeometryType GeometryType { get; set; } - public string Longitude { get; set; } + [Column(TypeName = "jsonb")] + public List Coordinates { get; set; } = new(); // 1 point = marker, plusieurs = polyline/polygon + + public string PolyColor { get; set; } // color of the polyline or polygon public string ImageResourceId { get; set; } @@ -109,9 +113,182 @@ namespace ManagerService.Data.SubSection [Column(TypeName = "jsonb")] public List Site { get; set; } - public string SectionMapId { get; set; } + public string? SectionMapId { get; set; } - [ForeignKey("SectionMapId")] - public SectionMap SectionMap { get; set; } + [ForeignKey(nameof(SectionMapId))] + public SectionMap? SectionMap { get; set; } + + public string? SectionEventId { get; set; } + + [ForeignKey(nameof(SectionEventId))] + public SectionEvent? SectionEvent { get; set; } } + + public class GuidedPath // Parcours + { + [Key] + public string Id { get; set; } + + [Required] + public string InstanceId { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Title { get; set; } + + [Column(TypeName = "jsonb")] + public List Description { get; set; } + + // Lié à une carte (optionnel) + public string? SectionMapId { get; set; } + [ForeignKey("SectionMapId")] + public SectionMap? SectionMap { get; set; } + + // Lié à un événement (optionnel) + public string? SectionEventId { get; set; } + [ForeignKey("SectionEventId")] + public SectionEvent? SectionEvent { get; set; } + + // Type de parcours + public bool IsLinear { get; set; } = true; // Avancer dans l’ordre - Ordre obligatoire + public bool RequireSuccessToAdvance { get; set; } = false; // Par exemple: résoudre une énigme + public bool HideNextStepsUntilComplete { get; set; } = false; // Étapes cachées tant que non terminées + + public int Order { get; set; } + + public List Steps { get; set; } = new(); + } + + public class GuidedStep // Étape d’un parcours + { + [Key] + public string Id { get; set; } + + [Required] + public string GuidedPathId { get; set; } + + [ForeignKey("GuidedPathId")] + public GuidedPath GuidedPath { get; set; } + + public int Order { get; set; } + + [Required] + [Column(TypeName = "jsonb")] + public List Title { get; set; } + + [Column(TypeName = "jsonb")] + public List Description { get; set; } + + public GeometryType GeometryType { get; set; } = GeometryType.Point; // Polygon, Circle, Point + + [Column(TypeName = "jsonb")] + public List Coordinates { get; set; } = new(); // Polygon ou centre du cercle + + public double? ZoneRadiusMeters { get; set; } // Optionnel, utile si zone cercle ou point + + public string ImageUrl { get; set; } + + public int? TriggerGeoPointId { get; set; } // Lieu lié à l'étape et genre si on veut plus d'info ou pourrait afficher les infos du geopoint. + + [ForeignKey("TriggerGeoPointId")] + public GeoPoint TriggerGeoPoint { get; set; } + + public bool IsHiddenInitially { get; set; } = false; + + public QuestionType ValidationQuestionType { get; set; } = QuestionType.Simple; + + // Exemple pour escape game + [Column(TypeName = "jsonb")] + public List ValidationQuestion { get; set; } // TODO type of question ? choix multiple ou direct ? + + [Column(TypeName = "jsonb")] + public List ExpectedAnswer { get; set; } + + [Column(TypeName = "jsonb")] + public List MultipleChoiceOptions { get; set; } // Pour choix multiples + + // Option : si true, cette étape a un compte à rebourds, false sinon + public bool IsStepTimer { get; set; } = false; + + // Option : si true, cette étape doit être validée avant de passer à la suivante + public bool IsStepLocked { get; set; } = true; + + // Timer en secondes (durée max pour valider cette étape, optionnel) + public int? TimerSeconds { get; set; } + + // Option : message ou action à effectuer si timer expire (ex: afficher aide, fin du jeu...) + [Column(TypeName = "jsonb")] + public List TimerExpiredMessage { get; set; } + } + + public class ChoiceOptionDTO + { + public string Id { get; set; } // Identifiant unique pour la réponse + public List Label { get; set; } // Texte à afficher + public bool IsCorrect { get; set; } // Indique si c’est une bonne réponse + } + + public enum QuestionType + { + Simple, // Réponse texte libre + MultipleChoice // Choix parmi plusieurs options + } + + // parcours libre + /*{ + "IsLinear": false, + "RequireSuccessToAdvance": false, + "HideNextStepsUntilComplete": false, + "Steps": [ + { "Title": "La tour", "GeoPointId": "...", "IsOptional": false }, + { "Title": "Les jardins", "GeoPointId": "...", "IsOptional": false } + ] + }*/ + // Parcours escape game + /*{ + "IsLinear": true, + "RequireSuccessToAdvance": true, + "HideNextStepsUntilComplete": true, + "Steps": [ + { "Title": "Enigme 1", "RiddleQuestion": "Quel est le code ?", "RiddleAnswer": "1234" }, + { "Title": "Enigme 2", "RiddleQuestion": "Combien de colonnes ?", "RiddleAnswer": "6" } + ] + }*/ + + /* + * { + "Id": "escape001", + "IsLinear": true, + "RequireSuccessToAdvance": true, + "HideNextStepsUntilComplete": true, + "Steps": [ + { + "Id": "step1", + "Title": [{ "Lang": "fr", "Text": "Enigme 1" }], + "TriggerGeoPoint": { + "GeometryType": "Circle", + "Coordinates": [{ "Latitude": 49.5, "Longitude": 5.9 }], + "ZoneRadiusMeters": 30 + }, + "ValidationQuestion": [{ "Lang": "fr", "Text": "Quel est le code secret ?" }], + "ExpectedAnswer": [{ "Lang": "fr", "Text": "1234" }], + "IsStepTimer": true, + "TimerSeconds": 300, + "IsStepLocked": true + }, + { + "Id": "step2", + "Title": [{ "Lang": "fr", "Text": "Enigme 2" }], + "TriggerGeoPoint": { + "GeometryType": "Point", + "Coordinates": [{ "Latitude": 49.51, "Longitude": 5.91 }] + }, + "ValidationQuestion": [{ "Lang": "fr", "Text": "Combien de colonnes ?" }], + "ExpectedAnswer": [{ "Lang": "fr", "Text": "6" }], + "IsStepTimer": false, + "IsStepLocked": true + } + ] + } + */ } diff --git a/ManagerService/Data/SubSection/SectionPuzzle.cs b/ManagerService/Data/SubSection/SectionPuzzle.cs index 9e25de0..db04310 100644 --- a/ManagerService/Data/SubSection/SectionPuzzle.cs +++ b/ManagerService/Data/SubSection/SectionPuzzle.cs @@ -31,6 +31,8 @@ namespace ManagerService.Data.SubSection [Required] public int PuzzleCols { get; set; } = 3; + public bool IsSlidingPuzzle { get; set; } = false; + public PuzzleDTO ToDTO() { diff --git a/ManagerService/Migrations/20250709151627_AddedApplicationInstanceAndMisc.Designer.cs b/ManagerService/Migrations/20250709151627_AddedApplicationInstanceAndMisc.Designer.cs new file mode 100644 index 0000000..cc1e3ae --- /dev/null +++ b/ManagerService/Migrations/20250709151627_AddedApplicationInstanceAndMisc.Designer.cs @@ -0,0 +1,978 @@ +// +using System; +using System.Collections.Generic; +using Manager.DTOs; +using ManagerService.DTOs; +using ManagerService.Data; +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("20250709151627_AddedApplicationInstanceAndMisc")] + partial class AddedApplicationInstanceAndMisc + { + /// + 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.DTOs.ResourceDTO", b => + { + b.Property("id") + .HasColumnType("text"); + + b.Property("dateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("instanceId") + .HasColumnType("text"); + + b.Property("label") + .HasColumnType("text"); + + b.Property("type") + .HasColumnType("integer"); + + b.Property("url") + .HasColumnType("text"); + + b.HasKey("id"); + + b.ToTable("ResourceDTO"); + }); + + 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("IsOffline") + .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("SecondaryColor") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.ToTable("Configurations"); + }); + + modelBuilder.Entity("ManagerService.Data.Device", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BatteryLevel") + .HasColumnType("text"); + + b.Property("ConfigurationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Connected") + .HasColumnType("boolean"); + + b.Property("ConnectionLevel") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdate") + .HasColumnType("timestamp with time zone"); + + b.Property("Identifier") + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IpAddressETH") + .HasColumnType("text"); + + b.Property("IpAddressWLAN") + .HasColumnType("text"); + + b.Property("LastBatteryLevel") + .HasColumnType("timestamp with time zone"); + + b.Property("LastConnectionLevel") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ConfigurationId"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("ManagerService.Data.Instance", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("IsMobile") + .HasColumnType("boolean"); + + b.Property("IsPushNotification") + .HasColumnType("boolean"); + + b.Property("IsStatistic") + .HasColumnType("boolean"); + + b.Property("IsTablet") + .HasColumnType("boolean"); + + b.Property("IsVR") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PinCode") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Instances"); + }); + + modelBuilder.Entity("ManagerService.Data.Resource", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("Url") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Resources"); + }); + + modelBuilder.Entity("ManagerService.Data.Section", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BeaconId") + .HasColumnType("integer"); + + b.Property("ConfigurationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("jsonb"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(13) + .HasColumnType("character varying(13)"); + + b.Property("ImageId") + .HasColumnType("text"); + + b.Property("ImageSource") + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsBeacon") + .HasColumnType("boolean"); + + b.Property("IsSubSection") + .HasColumnType("boolean"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text"); + + b.Property("Latitude") + .HasColumnType("text"); + + b.Property("Longitude") + .HasColumnType("text"); + + b.Property("MeterZoneGPS") + .HasColumnType("integer"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ParentId") + .HasColumnType("text"); + + b.Property("SectionMenuId") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("isActive") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("SectionMenuId"); + + b.ToTable("Sections"); + + b.HasDiscriminator().HasValue("Base"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategorieId") + .HasColumnType("integer"); + + b.Property("Contents") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Coordinates") + .HasColumnType("jsonb"); + + b.Property("Description") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Email") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("GeometryType") + .HasColumnType("integer"); + + b.Property("ImageResourceId") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("PolyColor") + .HasColumnType("text"); + + b.Property("Prices") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Schedules") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionEventId") + .HasColumnType("text"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.Property("Site") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionEventId"); + + b.HasIndex("SectionMapId"); + + b.ToTable("GeoPoints"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedPath", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("jsonb"); + + b.Property("HideNextStepsUntilComplete") + .HasColumnType("boolean"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsLinear") + .HasColumnType("boolean"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("RequireSuccessToAdvance") + .HasColumnType("boolean"); + + b.Property("SectionEventId") + .HasColumnType("text"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionEventId"); + + b.HasIndex("SectionMapId"); + + b.ToTable("GuidedPaths"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedStep", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Coordinates") + .HasColumnType("jsonb"); + + b.Property("Description") + .HasColumnType("jsonb"); + + b.Property("ExpectedAnswer") + .HasColumnType("jsonb"); + + b.Property("GeometryType") + .HasColumnType("integer"); + + b.Property("GuidedPathId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsHiddenInitially") + .HasColumnType("boolean"); + + b.Property("IsStepLocked") + .HasColumnType("boolean"); + + b.Property("IsStepTimer") + .HasColumnType("boolean"); + + b.Property("MultipleChoiceOptions") + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("TimerExpiredMessage") + .HasColumnType("jsonb"); + + b.Property("TimerSeconds") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("TriggerGeoPointId") + .HasColumnType("integer"); + + b.Property("ValidationQuestion") + .HasColumnType("jsonb"); + + b.Property("ValidationQuestionType") + .HasColumnType("integer"); + + b.Property("ZoneRadiusMeters") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("GuidedPathId"); + + b.HasIndex("TriggerGeoPointId"); + + b.ToTable("GuidedSteps"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Label") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property>("Responses") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionQuizId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionQuizId"); + + b.ToTable("QuizQuestions"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+MapAnnotation", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Coordinates") + .HasColumnType("jsonb"); + + b.Property("GeometryType") + .HasColumnType("integer"); + + b.Property("Icon") + .HasColumnType("text"); + + b.Property("IconResourceDTOid") + .HasColumnType("text"); + + b.Property>("Label") + .HasColumnType("jsonb"); + + b.Property("ProgrammeBlockId") + .HasColumnType("text"); + + b.Property>("Type") + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("IconResourceDTOid"); + + b.HasIndex("ProgrammeBlockId"); + + b.ToTable("MapAnnotation"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property>("Description") + .HasColumnType("jsonb"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("SectionEventId") + .HasColumnType("text"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property>("Title") + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionEventId"); + + b.ToTable("ProgrammeBlock"); + }); + + modelBuilder.Entity("ManagerService.Data.User", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Token") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionAgenda", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("AgendaMapProvider") + .HasColumnType("integer"); + + b.Property>("AgendaResourceIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasDiscriminator().HasValue("Agenda"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("ArticleAudioIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("ArticleContent") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("ArticleContents") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ArticleIsContentTop") + .HasColumnType("boolean"); + + b.Property("ArticleIsReadAudioAuto") + .HasColumnType("boolean"); + + b.HasDiscriminator().HasValue("Article"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property>("ParcoursIds") + .HasColumnType("jsonb"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.HasDiscriminator().HasValue("SectionEvent"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("MapCategories") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("MapCenterLatitude") + .HasColumnType("text"); + + b.Property("MapCenterLongitude") + .HasColumnType("text"); + + b.Property("MapMapProvider") + .HasColumnType("integer"); + + b.Property("MapMapType") + .HasColumnType("integer"); + + b.Property("MapResourceId") + .HasColumnType("text"); + + b.Property("MapTypeMapbox") + .HasColumnType("integer"); + + b.Property("MapZoom") + .HasColumnType("integer"); + + b.HasIndex("MapResourceId"); + + b.HasDiscriminator().HasValue("Map"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.HasDiscriminator().HasValue("Menu"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("PDFOrderedTranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasDiscriminator().HasValue("PDF"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("IsSlidingPuzzle") + .HasColumnType("boolean"); + + b.Property("PuzzleCols") + .HasColumnType("integer"); + + b.Property("PuzzleImageId") + .HasColumnType("text"); + + b.Property>("PuzzleMessageDebut") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("PuzzleMessageFin") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("PuzzleRows") + .HasColumnType("integer"); + + b.HasIndex("PuzzleImageId"); + + b.HasDiscriminator().HasValue("Puzzle"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("QuizBadLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("QuizGoodLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("QuizGreatLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("QuizMediumLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasDiscriminator().HasValue("Quiz"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("SliderContents") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasDiscriminator().HasValue("Slider"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionVideo", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("VideoSource") + .IsRequired() + .HasColumnType("text"); + + b.HasDiscriminator().HasValue("Video"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeather", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("WeatherCity") + .HasColumnType("text"); + + b.Property("WeatherResult") + .HasColumnType("text"); + + b.Property("WeatherUpdatedDate") + .HasColumnType("timestamp with time zone"); + + b.HasDiscriminator().HasValue("Weather"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeb", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("WebSource") + .IsRequired() + .HasColumnType("text"); + + b.HasDiscriminator().HasValue("Web"); + }); + + modelBuilder.Entity("ManagerService.Data.Device", b => + { + b.HasOne("ManagerService.Data.Configuration", "Configuration") + .WithMany() + .HasForeignKey("ConfigurationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Configuration"); + }); + + modelBuilder.Entity("ManagerService.Data.Section", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionMenu", null) + .WithMany("MenuSections") + .HasForeignKey("SectionMenuId"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionEvent", "SectionEvent") + .WithMany() + .HasForeignKey("SectionEventId"); + + b.HasOne("ManagerService.Data.SubSection.SectionMap", "SectionMap") + .WithMany("MapPoints") + .HasForeignKey("SectionMapId"); + + b.Navigation("SectionEvent"); + + b.Navigation("SectionMap"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedPath", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionEvent", "SectionEvent") + .WithMany() + .HasForeignKey("SectionEventId"); + + b.HasOne("ManagerService.Data.SubSection.SectionMap", "SectionMap") + .WithMany() + .HasForeignKey("SectionMapId"); + + b.Navigation("SectionEvent"); + + b.Navigation("SectionMap"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedStep", b => + { + b.HasOne("ManagerService.Data.SubSection.GuidedPath", "GuidedPath") + .WithMany("Steps") + .HasForeignKey("GuidedPathId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ManagerService.Data.SubSection.GeoPoint", "TriggerGeoPoint") + .WithMany() + .HasForeignKey("TriggerGeoPointId"); + + b.Navigation("GuidedPath"); + + b.Navigation("TriggerGeoPoint"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => + { + b.HasOne("ManagerService.Data.Resource", "Resource") + .WithMany() + .HasForeignKey("ResourceId"); + + b.HasOne("ManagerService.Data.SubSection.SectionQuiz", "SectionQuiz") + .WithMany("QuizQuestions") + .HasForeignKey("SectionQuizId"); + + b.Navigation("Resource"); + + b.Navigation("SectionQuiz"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+MapAnnotation", b => + { + b.HasOne("ManagerService.DTOs.ResourceDTO", "IconResourceDTO") + .WithMany() + .HasForeignKey("IconResourceDTOid"); + + b.HasOne("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", null) + .WithMany("MapAnnotations") + .HasForeignKey("ProgrammeBlockId"); + + b.Navigation("IconResourceDTO"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionEvent", null) + .WithMany("Programme") + .HasForeignKey("SectionEventId"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.HasOne("ManagerService.Data.Resource", "MapResource") + .WithMany() + .HasForeignKey("MapResourceId"); + + b.Navigation("MapResource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b => + { + b.HasOne("ManagerService.Data.Resource", "PuzzleImage") + .WithMany() + .HasForeignKey("PuzzleImageId"); + + b.Navigation("PuzzleImage"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedPath", b => + { + b.Navigation("Steps"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", b => + { + b.Navigation("MapAnnotations"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent", b => + { + b.Navigation("Programme"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.Navigation("MapPoints"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b => + { + b.Navigation("MenuSections"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.Navigation("QuizQuestions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ManagerService/Migrations/20250709151627_AddedApplicationInstanceAndMisc.cs b/ManagerService/Migrations/20250709151627_AddedApplicationInstanceAndMisc.cs new file mode 100644 index 0000000..2849561 --- /dev/null +++ b/ManagerService/Migrations/20250709151627_AddedApplicationInstanceAndMisc.cs @@ -0,0 +1,473 @@ +using System; +using System.Collections.Generic; +using ManagerService.DTOs; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class AddedApplicationInstanceAndMisc : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsDate", + table: "Configurations"); + + migrationBuilder.DropColumn( + name: "IsHour", + table: "Configurations"); + + migrationBuilder.DropColumn( + name: "IsMobile", + table: "Configurations"); + + migrationBuilder.DropColumn( + name: "IsSectionImageBackground", + table: "Configurations"); + + migrationBuilder.DropColumn( + name: "IsTablet", + table: "Configurations"); + + migrationBuilder.DropColumn( + name: "RoundedValue", + table: "Configurations"); + + migrationBuilder.DropColumn( + name: "ScreenPercentageSectionsMainPage", + table: "Configurations"); + + migrationBuilder.DropColumn( + name: "Longitude", + table: "GeoPoints"); + + migrationBuilder.AddColumn( + name: "SectionEventId", + table: "GeoPoints", + type: "text", + nullable: true); + + migrationBuilder.RenameColumn( + name: "Latitude", + table: "GeoPoints", + newName: "PolyColor"); + + migrationBuilder.AlterColumn( + name: "Discriminator", + table: "Sections", + type: "character varying(13)", + maxLength: 13, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(8)", + oldMaxLength: 8); + + migrationBuilder.AddColumn( + name: "EndDate", + table: "Sections", + type: "timestamp with time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "IsSlidingPuzzle", + table: "Sections", + type: "boolean", + nullable: true); + + migrationBuilder.AddColumn>( + name: "ParcoursIds", + table: "Sections", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn( + name: "StartDate", + table: "Sections", + type: "timestamp with time zone", + nullable: true); + + migrationBuilder.AddColumn( + name: "isActive", + table: "Sections", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsMobile", + table: "Instances", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsPushNotification", + table: "Instances", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsStatistic", + table: "Instances", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsTablet", + table: "Instances", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsVR", + table: "Instances", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "Coordinates", + table: "GeoPoints", + type: "jsonb", + nullable: true); + + migrationBuilder.AddColumn( + name: "GeometryType", + table: "GeoPoints", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "GuidedPaths", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + InstanceId = table.Column(type: "text", nullable: false), + Title = table.Column(type: "jsonb", nullable: false), + Description = table.Column(type: "jsonb", nullable: true), + SectionMapId = table.Column(type: "text", nullable: true), + SectionEventId = table.Column(type: "text", nullable: true), + IsLinear = table.Column(type: "boolean", nullable: false), + RequireSuccessToAdvance = table.Column(type: "boolean", nullable: false), + HideNextStepsUntilComplete = table.Column(type: "boolean", nullable: false), + Order = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GuidedPaths", x => x.Id); + table.ForeignKey( + name: "FK_GuidedPaths_Sections_SectionEventId", + column: x => x.SectionEventId, + principalTable: "Sections", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_GuidedPaths_Sections_SectionMapId", + column: x => x.SectionMapId, + principalTable: "Sections", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "ProgrammeBlock", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Title = table.Column>(type: "jsonb", nullable: true), + Description = table.Column>(type: "jsonb", nullable: true), + StartTime = table.Column(type: "timestamp with time zone", nullable: false), + EndTime = table.Column(type: "timestamp with time zone", nullable: false), + SectionEventId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ProgrammeBlock", x => x.Id); + table.ForeignKey( + name: "FK_ProgrammeBlock_Sections_SectionEventId", + column: x => x.SectionEventId, + principalTable: "Sections", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "ResourceDTO", + columns: table => new + { + id = table.Column(type: "text", nullable: false), + type = table.Column(type: "integer", nullable: false), + label = table.Column(type: "text", nullable: true), + url = table.Column(type: "text", nullable: true), + dateCreation = table.Column(type: "timestamp with time zone", nullable: false), + instanceId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ResourceDTO", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "GuidedSteps", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + GuidedPathId = table.Column(type: "text", nullable: false), + Order = table.Column(type: "integer", nullable: false), + Title = table.Column(type: "jsonb", nullable: false), + Description = table.Column(type: "jsonb", nullable: true), + GeometryType = table.Column(type: "integer", nullable: false), + Coordinates = table.Column(type: "jsonb", nullable: true), + ZoneRadiusMeters = table.Column(type: "double precision", nullable: true), + ImageUrl = table.Column(type: "text", nullable: true), + TriggerGeoPointId = table.Column(type: "integer", nullable: true), + IsHiddenInitially = table.Column(type: "boolean", nullable: false), + ValidationQuestionType = table.Column(type: "integer", nullable: false), + ValidationQuestion = table.Column(type: "jsonb", nullable: true), + ExpectedAnswer = table.Column(type: "jsonb", nullable: true), + MultipleChoiceOptions = table.Column(type: "jsonb", nullable: true), + IsStepTimer = table.Column(type: "boolean", nullable: false), + IsStepLocked = table.Column(type: "boolean", nullable: false), + TimerSeconds = table.Column(type: "integer", nullable: true), + TimerExpiredMessage = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GuidedSteps", x => x.Id); + table.ForeignKey( + name: "FK_GuidedSteps_GeoPoints_TriggerGeoPointId", + column: x => x.TriggerGeoPointId, + principalTable: "GeoPoints", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_GuidedSteps_GuidedPaths_GuidedPathId", + column: x => x.GuidedPathId, + principalTable: "GuidedPaths", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MapAnnotation", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Type = table.Column>(type: "jsonb", nullable: true), + Label = table.Column>(type: "jsonb", nullable: true), + GeometryType = table.Column(type: "integer", nullable: false), + Coordinates = table.Column(type: "jsonb", nullable: true), + Icon = table.Column(type: "text", nullable: true), + IconResourceDTOid = table.Column(type: "text", nullable: true), + ProgrammeBlockId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_MapAnnotation", x => x.Id); + table.ForeignKey( + name: "FK_MapAnnotation_ProgrammeBlock_ProgrammeBlockId", + column: x => x.ProgrammeBlockId, + principalTable: "ProgrammeBlock", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_MapAnnotation_ResourceDTO_IconResourceDTOid", + column: x => x.IconResourceDTOid, + principalTable: "ResourceDTO", + principalColumn: "id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_GeoPoints_SectionEventId", + table: "GeoPoints", + column: "SectionEventId"); + + migrationBuilder.CreateIndex( + name: "IX_GuidedPaths_SectionEventId", + table: "GuidedPaths", + column: "SectionEventId"); + + migrationBuilder.CreateIndex( + name: "IX_GuidedPaths_SectionMapId", + table: "GuidedPaths", + column: "SectionMapId"); + + migrationBuilder.CreateIndex( + name: "IX_GuidedSteps_GuidedPathId", + table: "GuidedSteps", + column: "GuidedPathId"); + + migrationBuilder.CreateIndex( + name: "IX_GuidedSteps_TriggerGeoPointId", + table: "GuidedSteps", + column: "TriggerGeoPointId"); + + migrationBuilder.CreateIndex( + name: "IX_MapAnnotation_IconResourceDTOid", + table: "MapAnnotation", + column: "IconResourceDTOid"); + + migrationBuilder.CreateIndex( + name: "IX_MapAnnotation_ProgrammeBlockId", + table: "MapAnnotation", + column: "ProgrammeBlockId"); + + migrationBuilder.CreateIndex( + name: "IX_ProgrammeBlock_SectionEventId", + table: "ProgrammeBlock", + column: "SectionEventId"); + + migrationBuilder.AddForeignKey( + name: "FK_GeoPoints_Sections_SectionEventId", + table: "GeoPoints", + column: "SectionEventId", + principalTable: "Sections", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_GeoPoints_Sections_SectionEventId", + table: "GeoPoints"); + + migrationBuilder.DropTable( + name: "GuidedSteps"); + + migrationBuilder.DropTable( + name: "MapAnnotation"); + + migrationBuilder.DropTable( + name: "GuidedPaths"); + + migrationBuilder.DropTable( + name: "ProgrammeBlock"); + + migrationBuilder.DropTable( + name: "ResourceDTO"); + + migrationBuilder.DropIndex( + name: "IX_GeoPoints_SectionEventId", + table: "GeoPoints"); + + migrationBuilder.DropColumn( + name: "EndDate", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "IsSlidingPuzzle", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "ParcoursIds", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "StartDate", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "isActive", + table: "Sections"); + + migrationBuilder.DropColumn( + name: "IsMobile", + table: "Instances"); + + migrationBuilder.DropColumn( + name: "IsPushNotification", + table: "Instances"); + + migrationBuilder.DropColumn( + name: "IsStatistic", + table: "Instances"); + + migrationBuilder.DropColumn( + name: "IsTablet", + table: "Instances"); + + migrationBuilder.DropColumn( + name: "IsVR", + table: "Instances"); + + migrationBuilder.DropColumn( + name: "Coordinates", + table: "GeoPoints"); + + migrationBuilder.DropColumn( + name: "GeometryType", + table: "GeoPoints"); + + migrationBuilder.RenameColumn( + name: "SectionEventId", + table: "GeoPoints", + newName: "Longitude"); + + migrationBuilder.RenameColumn( + name: "PolyColor", + table: "GeoPoints", + newName: "Latitude"); + + migrationBuilder.AlterColumn( + name: "Discriminator", + table: "Sections", + type: "character varying(8)", + maxLength: 8, + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(13)", + oldMaxLength: 13); + + migrationBuilder.AddColumn( + name: "IsDate", + table: "Configurations", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsHour", + table: "Configurations", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsMobile", + table: "Configurations", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsSectionImageBackground", + table: "Configurations", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "IsTablet", + table: "Configurations", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "RoundedValue", + table: "Configurations", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "ScreenPercentageSectionsMainPage", + table: "Configurations", + type: "integer", + nullable: true); + } + } +} diff --git a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs index c546831..91c4759 100644 --- a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs +++ b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs @@ -4,7 +4,6 @@ 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; @@ -26,6 +25,31 @@ namespace ManagerService.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("ManagerService.DTOs.ResourceDTO", b => + { + b.Property("id") + .HasColumnType("text"); + + b.Property("dateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("instanceId") + .HasColumnType("text"); + + b.Property("label") + .HasColumnType("text"); + + b.Property("type") + .HasColumnType("integer"); + + b.Property("url") + .HasColumnType("text"); + + b.HasKey("id"); + + b.ToTable("ResourceDTO"); + }); + modelBuilder.Entity("ManagerService.Data.Configuration", b => { b.Property("Id") @@ -44,24 +68,9 @@ namespace ManagerService.Migrations .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"); @@ -78,12 +87,6 @@ namespace ManagerService.Migrations b.Property("PrimaryColor") .HasColumnType("text"); - b.Property("RoundedValue") - .HasColumnType("integer"); - - b.Property("ScreenPercentageSectionsMainPage") - .HasColumnType("integer"); - b.Property("SecondaryColor") .HasColumnType("text"); @@ -157,6 +160,21 @@ namespace ManagerService.Migrations b.Property("DateCreation") .HasColumnType("timestamp with time zone"); + b.Property("IsMobile") + .HasColumnType("boolean"); + + b.Property("IsPushNotification") + .HasColumnType("boolean"); + + b.Property("IsStatistic") + .HasColumnType("boolean"); + + b.Property("IsTablet") + .HasColumnType("boolean"); + + b.Property("IsVR") + .HasColumnType("boolean"); + b.Property("Name") .IsRequired() .HasColumnType("text"); @@ -216,8 +234,8 @@ namespace ManagerService.Migrations b.Property("Discriminator") .IsRequired() - .HasMaxLength(8) - .HasColumnType("character varying(8)"); + .HasMaxLength(13) + .HasColumnType("character varying(13)"); b.Property("ImageId") .HasColumnType("text"); @@ -264,6 +282,9 @@ namespace ManagerService.Migrations b.Property("Type") .HasColumnType("integer"); + b.Property("isActive") + .HasColumnType("boolean"); + b.HasKey("Id"); b.HasIndex("SectionMenuId"); @@ -286,60 +307,181 @@ namespace ManagerService.Migrations b.Property("CategorieId") .HasColumnType("integer"); - b.Property>("Contents") + b.Property("Contents") .IsRequired() .HasColumnType("jsonb"); - b.Property>("Description") + b.Property("Coordinates") + .HasColumnType("jsonb"); + + b.Property("Description") .IsRequired() .HasColumnType("jsonb"); - b.Property>("Email") + b.Property("Email") .IsRequired() .HasColumnType("jsonb"); + b.Property("GeometryType") + .HasColumnType("integer"); + b.Property("ImageResourceId") .HasColumnType("text"); b.Property("ImageUrl") .HasColumnType("text"); - b.Property("Latitude") + b.Property("Phone") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("PolyColor") .HasColumnType("text"); - b.Property("Longitude") + b.Property("Prices") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Schedules") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionEventId") .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") + b.Property("Site") .IsRequired() .HasColumnType("jsonb"); - b.Property>("Title") + b.Property("Title") .IsRequired() .HasColumnType("jsonb"); b.HasKey("Id"); + b.HasIndex("SectionEventId"); + b.HasIndex("SectionMapId"); b.ToTable("GeoPoints"); }); + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedPath", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("jsonb"); + + b.Property("HideNextStepsUntilComplete") + .HasColumnType("boolean"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsLinear") + .HasColumnType("boolean"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("RequireSuccessToAdvance") + .HasColumnType("boolean"); + + b.Property("SectionEventId") + .HasColumnType("text"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionEventId"); + + b.HasIndex("SectionMapId"); + + b.ToTable("GuidedPaths"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedStep", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Coordinates") + .HasColumnType("jsonb"); + + b.Property("Description") + .HasColumnType("jsonb"); + + b.Property("ExpectedAnswer") + .HasColumnType("jsonb"); + + b.Property("GeometryType") + .HasColumnType("integer"); + + b.Property("GuidedPathId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("IsHiddenInitially") + .HasColumnType("boolean"); + + b.Property("IsStepLocked") + .HasColumnType("boolean"); + + b.Property("IsStepTimer") + .HasColumnType("boolean"); + + b.Property("MultipleChoiceOptions") + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("TimerExpiredMessage") + .HasColumnType("jsonb"); + + b.Property("TimerSeconds") + .HasColumnType("integer"); + + b.Property("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("TriggerGeoPointId") + .HasColumnType("integer"); + + b.Property("ValidationQuestion") + .HasColumnType("jsonb"); + + b.Property("ValidationQuestionType") + .HasColumnType("integer"); + + b.Property("ZoneRadiusMeters") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("GuidedPathId"); + + b.HasIndex("TriggerGeoPointId"); + + b.ToTable("GuidedSteps"); + }); + modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => { b.Property("Id") @@ -374,6 +516,68 @@ namespace ManagerService.Migrations b.ToTable("QuizQuestions"); }); + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+MapAnnotation", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Coordinates") + .HasColumnType("jsonb"); + + b.Property("GeometryType") + .HasColumnType("integer"); + + b.Property("Icon") + .HasColumnType("text"); + + b.Property("IconResourceDTOid") + .HasColumnType("text"); + + b.Property>("Label") + .HasColumnType("jsonb"); + + b.Property("ProgrammeBlockId") + .HasColumnType("text"); + + b.Property>("Type") + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("IconResourceDTOid"); + + b.HasIndex("ProgrammeBlockId"); + + b.ToTable("MapAnnotation"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property>("Description") + .HasColumnType("jsonb"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("SectionEventId") + .HasColumnType("text"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property>("Title") + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionEventId"); + + b.ToTable("ProgrammeBlock"); + }); + modelBuilder.Entity("ManagerService.Data.User", b => { b.Property("Id") @@ -449,6 +653,22 @@ namespace ManagerService.Migrations b.HasDiscriminator().HasValue("Article"); }); + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("EndDate") + .HasColumnType("timestamp with time zone"); + + b.Property>("ParcoursIds") + .HasColumnType("jsonb"); + + b.Property("StartDate") + .HasColumnType("timestamp with time zone"); + + b.HasDiscriminator().HasValue("SectionEvent"); + }); + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => { b.HasBaseType("ManagerService.Data.Section"); @@ -505,17 +725,20 @@ namespace ManagerService.Migrations { b.HasBaseType("ManagerService.Data.Section"); + b.Property("IsSlidingPuzzle") + .HasColumnType("boolean"); + b.Property("PuzzleCols") .HasColumnType("integer"); b.Property("PuzzleImageId") .HasColumnType("text"); - b.Property>("PuzzleMessageDebut") + b.Property>("PuzzleMessageDebut") .IsRequired() .HasColumnType("jsonb"); - b.Property>("PuzzleMessageFin") + b.Property>("PuzzleMessageFin") .IsRequired() .HasColumnType("jsonb"); @@ -619,13 +842,51 @@ namespace ManagerService.Migrations modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b => { + b.HasOne("ManagerService.Data.SubSection.SectionEvent", "SectionEvent") + .WithMany() + .HasForeignKey("SectionEventId"); + b.HasOne("ManagerService.Data.SubSection.SectionMap", "SectionMap") .WithMany("MapPoints") .HasForeignKey("SectionMapId"); + b.Navigation("SectionEvent"); + b.Navigation("SectionMap"); }); + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedPath", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionEvent", "SectionEvent") + .WithMany() + .HasForeignKey("SectionEventId"); + + b.HasOne("ManagerService.Data.SubSection.SectionMap", "SectionMap") + .WithMany() + .HasForeignKey("SectionMapId"); + + b.Navigation("SectionEvent"); + + b.Navigation("SectionMap"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedStep", b => + { + b.HasOne("ManagerService.Data.SubSection.GuidedPath", "GuidedPath") + .WithMany("Steps") + .HasForeignKey("GuidedPathId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ManagerService.Data.SubSection.GeoPoint", "TriggerGeoPoint") + .WithMany() + .HasForeignKey("TriggerGeoPointId"); + + b.Navigation("GuidedPath"); + + b.Navigation("TriggerGeoPoint"); + }); + modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => { b.HasOne("ManagerService.Data.Resource", "Resource") @@ -641,6 +902,26 @@ namespace ManagerService.Migrations b.Navigation("SectionQuiz"); }); + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+MapAnnotation", b => + { + b.HasOne("ManagerService.DTOs.ResourceDTO", "IconResourceDTO") + .WithMany() + .HasForeignKey("IconResourceDTOid"); + + b.HasOne("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", null) + .WithMany("MapAnnotations") + .HasForeignKey("ProgrammeBlockId"); + + b.Navigation("IconResourceDTO"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", b => + { + b.HasOne("ManagerService.Data.SubSection.SectionEvent", null) + .WithMany("Programme") + .HasForeignKey("SectionEventId"); + }); + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => { b.HasOne("ManagerService.Data.Resource", "MapResource") @@ -659,6 +940,21 @@ namespace ManagerService.Migrations b.Navigation("PuzzleImage"); }); + modelBuilder.Entity("ManagerService.Data.SubSection.GuidedPath", b => + { + b.Navigation("Steps"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent+ProgrammeBlock", b => + { + b.Navigation("MapAnnotations"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionEvent", b => + { + b.Navigation("Programme"); + }); + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => { b.Navigation("MapPoints"); diff --git a/ManagerService/Startup.cs b/ManagerService/Startup.cs index 9c8ff13..799f6a4 100644 --- a/ManagerService/Startup.cs +++ b/ManagerService/Startup.cs @@ -188,7 +188,7 @@ namespace ManagerService app.UseCors( #if DEBUG options => options - .SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:49430") + .SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:52444") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()