From 4713bc14dc681b036c9cb121d2ca84212d3be30c Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 14 May 2025 16:56:14 +0200 Subject: [PATCH] Map -> Categories working ! --- .../Controllers/SectionController.cs | 48 +++++++++++++++---- ManagerService/Services/SectionFactory.cs | 5 +- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index 43420d4..bfbe297 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -399,7 +399,15 @@ namespace ManagerService.Controllers section.ParentId = newSection.parentId; section.Type = newSection.type; - section.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection)+1; + // TODO !! + 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 = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection) + 1; + } section.IsBeacon = newSection.isBeacon; section.BeaconId = newSection.beaconId; @@ -551,8 +559,8 @@ namespace ManagerService.Controllers // TODO Endpoint categories // TODO Endpoint points - /*map.Categories = []; - map.Points = [];*/ + map.MapCategories = updatedSectionDB.MapCategories; + //_myInfoMateDbContext.Entry(map).Property(p => p.MapCategories).IsModified = true; break; case SectionMenu menu: @@ -667,14 +675,34 @@ namespace ManagerService.Controllers _myInfoMateDbContext.Remove(section); //_sectionService.Remove(id); - // update order from rest // TODO TEST - List
sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection).ToList(); - int i = 1; - foreach (var sectionDb in sections.OrderBy(s => s.Order)) - { - sectionDb.Order = i; - i++; + var configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == section.ConfigurationId); + + if (configuration.IsMobile) + { + // 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++; + } + } + _myInfoMateDbContext.SaveChanges(); diff --git a/ManagerService/Services/SectionFactory.cs b/ManagerService/Services/SectionFactory.cs index 4514ff7..4d6b847 100644 --- a/ManagerService/Services/SectionFactory.cs +++ b/ManagerService/Services/SectionFactory.cs @@ -141,8 +141,7 @@ namespace ManagerService.Services MapResourceId = mapDTO.iconResourceId, MapCenterLatitude = mapDTO.centerLatitude, MapCenterLongitude = mapDTO.centerLongitude, - MapCategories = null, //((MapDTO)dto).categories, // TODO specific - MapPoints = null // ((MapDTO)dto).points, // TODO specific + MapCategories = mapDTO.categories }, SectionType.Menu => new SectionMenu { @@ -416,7 +415,7 @@ namespace ManagerService.Services iconResourceId = map.MapResourceId, centerLatitude = map.MapCenterLatitude, centerLongitude = map.MapCenterLongitude, - categories = null, // map.MapCategories, // TODO specific + categories = map.MapCategories, //points = null // map.MapPoints // TODO specific }, SectionMenu menu => new MenuDTO