fix puzzle + added order in back
This commit is contained in:
parent
79d1bc3db5
commit
75a6b0c323
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ namespace ManagerService.Controllers
|
||||
|
||||
if (configuration != null)
|
||||
{
|
||||
List<Section> sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && !s.IsSubSection).ToList();
|
||||
List<Section> sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && !s.IsSubSection).OrderBy(s => s.Order).ToList();
|
||||
List<object> sectionsToReturn = new List<object>();
|
||||
|
||||
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<GeoPointDTO> geoPointDTOs = new List<GeoPointDTO>();
|
||||
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<QuestionDTO> questionDTOs = new List<QuestionDTO>();
|
||||
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<object> subSectionToReturn = new List<object>();
|
||||
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<GeoPointDTO> geoPointDTOsSub = new List<GeoPointDTO>();
|
||||
@ -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<QuestionDTO> questionDTOsSub = new List<QuestionDTO>();
|
||||
foreach (var quizQuestionSub in quizQuestionsSub)
|
||||
{
|
||||
@ -321,7 +329,7 @@ namespace ManagerService.Controllers
|
||||
if (id == null)
|
||||
throw new ArgumentNullException("Param is null");
|
||||
|
||||
List<Section> sections = _myInfoMateDbContext.Sections.Where(s => s.ParentId == id && s.IsSubSection).ToList();
|
||||
List<Section> sections = _myInfoMateDbContext.Sections.Where(s => s.ParentId == id && s.IsSubSection).OrderBy(s=> s.Order).ToList();
|
||||
//List<OldSection> sections = _sectionService.GetAllSubSection(id);
|
||||
|
||||
List<object> sectionsToReturn = new List<object>();
|
||||
|
||||
@ -16,11 +16,11 @@ namespace ManagerService.Data.SubSection
|
||||
{
|
||||
[Required]
|
||||
[Column(TypeName = "jsonb")]
|
||||
public List<TranslationAndResource> PuzzleMessageDebut { get; set; }
|
||||
public List<TranslationAndResourceDTO> PuzzleMessageDebut { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column(TypeName = "jsonb")]
|
||||
public List<TranslationAndResource> PuzzleMessageFin { get; set; }
|
||||
public List<TranslationAndResourceDTO> 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,
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user