Map -> Categories working !

This commit is contained in:
Thomas Fransolet 2025-05-14 16:56:14 +02:00
parent 8635e75c06
commit 4713bc14dc
2 changed files with 40 additions and 13 deletions

View File

@ -399,7 +399,15 @@ namespace ManagerService.Controllers
section.ParentId = newSection.parentId; section.ParentId = newSection.parentId;
section.Type = newSection.type; 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.IsBeacon = newSection.isBeacon;
section.BeaconId = newSection.beaconId; section.BeaconId = newSection.beaconId;
@ -551,8 +559,8 @@ namespace ManagerService.Controllers
// TODO Endpoint categories // TODO Endpoint categories
// TODO Endpoint points // TODO Endpoint points
/*map.Categories = []; map.MapCategories = updatedSectionDB.MapCategories;
map.Points = [];*/ //_myInfoMateDbContext.Entry(map).Property(p => p.MapCategories).IsModified = true;
break; break;
case SectionMenu menu: case SectionMenu menu:
@ -667,14 +675,34 @@ namespace ManagerService.Controllers
_myInfoMateDbContext.Remove(section); _myInfoMateDbContext.Remove(section);
//_sectionService.Remove(id); //_sectionService.Remove(id);
// update order from rest // TODO TEST var configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == section.ConfigurationId);
List<Section> sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection).ToList();
int i = 1; if (configuration.IsMobile)
foreach (var sectionDb in sections.OrderBy(s => s.Order))
{ {
sectionDb.Order = i; // TODO !!
i++; // update order only with article and quiz (FOR NOW)
List<Section> sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection && (s.Type == SectionType.Article || s.Type == SectionType.Quiz)).ToList();
int i = 1;
List<Section> 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<Section> sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection).ToList();
int i = 1;
List<Section> orderedSection = sections.OrderBy(s => s.Order).ToList();
foreach (var sectionDb in orderedSection)
{
sectionDb.Order = i;
i++;
}
}
_myInfoMateDbContext.SaveChanges(); _myInfoMateDbContext.SaveChanges();

View File

@ -141,8 +141,7 @@ namespace ManagerService.Services
MapResourceId = mapDTO.iconResourceId, MapResourceId = mapDTO.iconResourceId,
MapCenterLatitude = mapDTO.centerLatitude, MapCenterLatitude = mapDTO.centerLatitude,
MapCenterLongitude = mapDTO.centerLongitude, MapCenterLongitude = mapDTO.centerLongitude,
MapCategories = null, //((MapDTO)dto).categories, // TODO specific MapCategories = mapDTO.categories
MapPoints = null // ((MapDTO)dto).points, // TODO specific
}, },
SectionType.Menu => new SectionMenu SectionType.Menu => new SectionMenu
{ {
@ -416,7 +415,7 @@ namespace ManagerService.Services
iconResourceId = map.MapResourceId, iconResourceId = map.MapResourceId,
centerLatitude = map.MapCenterLatitude, centerLatitude = map.MapCenterLatitude,
centerLongitude = map.MapCenterLongitude, centerLongitude = map.MapCenterLongitude,
categories = null, // map.MapCategories, // TODO specific categories = map.MapCategories,
//points = null // map.MapPoints // TODO specific //points = null // map.MapPoints // TODO specific
}, },
SectionMenu menu => new MenuDTO SectionMenu menu => new MenuDTO