diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs index 115383a..be077ed 100644 --- a/ManagerService/Controllers/ResourceController.cs +++ b/ManagerService/Controllers/ResourceController.cs @@ -633,10 +633,10 @@ namespace ManagerService.Controllers { foreach (var puzzleMessageDebut in puzzle.PuzzleMessageDebut) { - if (puzzleMessageDebut.ResourceId == id) + if (puzzleMessageDebut.resourceId == id) { - puzzleMessageDebut.ResourceId = null; - puzzleMessageDebut.Resource = null; + puzzleMessageDebut.resourceId = null; + puzzleMessageDebut.resource = null; _myInfoMateDbContext.Entry(puzzle).Property(p => p.PuzzleMessageDebut).IsModified = true; } } @@ -645,10 +645,10 @@ namespace ManagerService.Controllers { foreach (var puzzleMessageFin in puzzle.PuzzleMessageFin) { - if (puzzleMessageFin.ResourceId == id) + if (puzzleMessageFin.resourceId == id) { - puzzleMessageFin.ResourceId = null; - puzzleMessageFin.Resource = null; + puzzleMessageFin.resourceId = null; + puzzleMessageFin.resource = null; _myInfoMateDbContext.Entry(puzzle).Property(p => p.PuzzleMessageFin).IsModified = true; } } diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index 5a979c7..6a3733b 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -146,7 +146,7 @@ namespace ManagerService.Controllers if (configuration != null) { - List
sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && !s.IsSubSection).ToList(); + List
sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && !s.IsSubSection).OrderBy(s => s.Order).ToList(); List sectionsToReturn = new List(); foreach (var section in sections) @@ -155,8 +155,12 @@ namespace ManagerService.Controllers switch (section.Type) { + case SectionType.Puzzle: + Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == (dto as PuzzleDTO).puzzleImageId); + (dto as PuzzleDTO).puzzleImage = resource.ToDTO(); + break; case SectionType.Map: - var geoPoints = _myInfoMateDbContext.GeoPoints.Where(gp => gp.SectionMapId == section.Id).ToList(); + var geoPoints = _myInfoMateDbContext.GeoPoints.Where(gp => gp.SectionMapId == section.Id)/*.OrderBy(gp => gp.or)*/.ToList(); List geoPointDTOs = new List(); foreach (var geoPoint in geoPoints) { @@ -180,7 +184,7 @@ namespace ManagerService.Controllers (dto as MapDTO).points = geoPointDTOs; break; case SectionType.Quiz: - var quizQuestions = _myInfoMateDbContext.QuizQuestions.Where(qq => qq.SectionQuizId == section.Id).ToList(); + var quizQuestions = _myInfoMateDbContext.QuizQuestions.Where(qq => qq.SectionQuizId == section.Id).OrderBy(q => q.Order).ToList(); List questionDTOs = new List(); foreach (var quizQuestion in quizQuestions) { @@ -198,13 +202,17 @@ namespace ManagerService.Controllers (dto as QuizDTO).questions = questionDTOs; break; case SectionType.Menu: - var subSections = _myInfoMateDbContext.Sections.Where(s => s.IsSubSection && s.ParentId == section.Id).ToList(); + var subSections = _myInfoMateDbContext.Sections.Where(s => s.IsSubSection && s.ParentId == section.Id).OrderBy(s => s.Order).ToList(); List subSectionToReturn = new List(); foreach (var subSection in subSections) { var subDTO = SectionFactory.ToDTO(subSection); switch (subSection.Type) { + case SectionType.Puzzle: + Resource resourceSub = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == (subDTO as PuzzleDTO).puzzleImageId); + (subDTO as PuzzleDTO).puzzleImage = resourceSub?.ToDTO(); + break; case SectionType.Map: var geoPointsSub = _myInfoMateDbContext.GeoPoints.Where(gp => gp.SectionMapId == subSection.Id).ToList(); List geoPointDTOsSub = new List(); @@ -231,7 +239,7 @@ namespace ManagerService.Controllers (subDTO as MapDTO).points = geoPointDTOsSub; break; case SectionType.Quiz: - var quizQuestionsSub = _myInfoMateDbContext.QuizQuestions.Where(qq => qq.SectionQuizId == subSection.Id).ToList(); + var quizQuestionsSub = _myInfoMateDbContext.QuizQuestions.Where(qq => qq.SectionQuizId == subSection.Id).OrderBy(q => q.Order).ToList(); List questionDTOsSub = new List(); foreach (var quizQuestionSub in quizQuestionsSub) { @@ -321,7 +329,7 @@ namespace ManagerService.Controllers if (id == null) throw new ArgumentNullException("Param is null"); - List
sections = _myInfoMateDbContext.Sections.Where(s => s.ParentId == id && s.IsSubSection).ToList(); + List
sections = _myInfoMateDbContext.Sections.Where(s => s.ParentId == id && s.IsSubSection).OrderBy(s=> s.Order).ToList(); //List sections = _sectionService.GetAllSubSection(id); List sectionsToReturn = new List(); diff --git a/ManagerService/Data/SubSection/SectionPuzzle.cs b/ManagerService/Data/SubSection/SectionPuzzle.cs index a800aac..9e25de0 100644 --- a/ManagerService/Data/SubSection/SectionPuzzle.cs +++ b/ManagerService/Data/SubSection/SectionPuzzle.cs @@ -16,11 +16,11 @@ namespace ManagerService.Data.SubSection { [Required] [Column(TypeName = "jsonb")] - public List PuzzleMessageDebut { get; set; } + public List PuzzleMessageDebut { get; set; } [Required] [Column(TypeName = "jsonb")] - public List PuzzleMessageFin { get; set; } + public List PuzzleMessageFin { get; set; } public string PuzzleImageId { get; set; } // But only image is possible public Resource PuzzleImage { get; set; } // But only image is possible @@ -54,8 +54,8 @@ namespace ManagerService.Data.SubSection latitude = Latitude, longitude = Longitude, meterZoneGPS = MeterZoneGPS, - messageDebut = PuzzleMessageDebut.Select(md => md.ToDTO()).ToList(), - messageFin = PuzzleMessageFin.Select(mf => mf.ToDTO()).ToList(), + messageDebut = PuzzleMessageDebut, + messageFin = PuzzleMessageFin, puzzleImage = PuzzleImage.ToDTO(), puzzleImageId = PuzzleImageId, rows = PuzzleRows, diff --git a/ManagerService/Services/SectionFactory.cs b/ManagerService/Services/SectionFactory.cs index 76835de..05cac34 100644 --- a/ManagerService/Services/SectionFactory.cs +++ b/ManagerService/Services/SectionFactory.cs @@ -207,8 +207,8 @@ namespace ManagerService.Services Longitude = dto.longitude, MeterZoneGPS = dto.meterZoneGPS, Type = dto.type, - PuzzleMessageDebut = puzzleDTO.messageDebut.Select(md => new TranslationAndResource().FromDTO(md)).ToList(), - PuzzleMessageFin = puzzleDTO.messageFin.Select(mf => new TranslationAndResource().FromDTO(mf)).ToList(), + PuzzleMessageDebut = puzzleDTO.messageDebut, + PuzzleMessageFin = puzzleDTO.messageFin, PuzzleImageId = puzzleDTO.puzzleImageId, PuzzleRows = puzzleDTO.rows, PuzzleCols = puzzleDTO.cols @@ -482,8 +482,9 @@ namespace ManagerService.Services longitude = puzzle.Longitude, meterZoneGPS = puzzle.MeterZoneGPS, type = puzzle.Type, - messageDebut = puzzle.PuzzleMessageDebut.Select(md => md.ToDTO()).ToList(), - messageFin = puzzle.PuzzleMessageFin.Select(mf => mf.ToDTO()).ToList(), + messageDebut = puzzle.PuzzleMessageDebut, + messageFin = puzzle.PuzzleMessageFin, + puzzleImage = puzzle.PuzzleImage?.ToDTO(), puzzleImageId = puzzle.PuzzleImageId, rows = puzzle.PuzzleRows, cols = puzzle.PuzzleCols