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.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<Section> 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<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();

View File

@ -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