Update puzzle to game + misc

This commit is contained in:
Thomas Fransolet 2025-11-27 16:19:00 +01:00
parent e70b574091
commit 94443fa411
15 changed files with 1547 additions and 126 deletions

View File

@ -628,36 +628,36 @@ namespace ManagerService.Controllers
} }
} }
break; break;
case SectionPuzzle puzzle: case SectionGame puzzle:
if (puzzle.PuzzleMessageDebut != null) if (puzzle.GameMessageDebut != null)
{ {
foreach (var puzzleMessageDebut in puzzle.PuzzleMessageDebut) foreach (var gameMessageDebut in puzzle.GameMessageDebut)
{ {
if (puzzleMessageDebut.resourceId == id) if (gameMessageDebut.resourceId == id)
{ {
puzzleMessageDebut.resourceId = null; gameMessageDebut.resourceId = null;
puzzleMessageDebut.resource = null; gameMessageDebut.resource = null;
_myInfoMateDbContext.Entry(puzzle).Property(p => p.PuzzleMessageDebut).IsModified = true; _myInfoMateDbContext.Entry(puzzle).Property(p => p.GameMessageDebut).IsModified = true;
} }
} }
} }
if (puzzle.PuzzleMessageFin != null) if (puzzle.GameMessageFin != null)
{ {
foreach (var puzzleMessageFin in puzzle.PuzzleMessageFin) foreach (var gameMessageFin in puzzle.GameMessageFin)
{ {
if (puzzleMessageFin.resourceId == id) if (gameMessageFin.resourceId == id)
{ {
puzzleMessageFin.resourceId = null; gameMessageFin.resourceId = null;
puzzleMessageFin.resource = null; gameMessageFin.resource = null;
_myInfoMateDbContext.Entry(puzzle).Property(p => p.PuzzleMessageFin).IsModified = true; _myInfoMateDbContext.Entry(puzzle).Property(p => p.GameMessageFin).IsModified = true;
} }
} }
} }
if (puzzle.PuzzleImageId == id) if (puzzle.GamePuzzleImageId == id)
{ {
puzzle.PuzzleImageId = null; puzzle.GamePuzzleImageId = null;
puzzle.PuzzleImage = null; puzzle.GamePuzzleImage = null;
} }
break; break;
case SectionVideo video: // TO BE TESTED .. case SectionVideo video: // TO BE TESTED ..

View File

@ -208,9 +208,9 @@ namespace ManagerService.Controllers
var sectionEvent = _myInfoMateDbContext.Sections.OfType<SectionEvent>().Include(se => se.Programme).ThenInclude(se => se.MapAnnotations).FirstOrDefault(s => s.Id == id); var sectionEvent = _myInfoMateDbContext.Sections.OfType<SectionEvent>().Include(se => se.Programme).ThenInclude(se => se.MapAnnotations).FirstOrDefault(s => s.Id == id);
(dto as SectionEventDTO).Programme = sectionEvent.Programme; // TODO test ! Need dto ? (dto as SectionEventDTO).Programme = sectionEvent.Programme; // TODO test ! Need dto ?
break; break;
case SectionType.Puzzle: case SectionType.Game:
Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == (dto as PuzzleDTO).puzzleImageId); Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == (dto as GameDTO).puzzleImageId);
(dto as PuzzleDTO).puzzleImage = resource.ToDTO(); (dto as GameDTO).puzzleImage = resource.ToDTO();
break; break;
case SectionType.Map: case SectionType.Map:
var geoPoints = _myInfoMateDbContext.GeoPoints.Where(gp => gp.SectionMapId == section.Id)/*.OrderBy(gp => gp.or)*/.ToList(); var geoPoints = _myInfoMateDbContext.GeoPoints.Where(gp => gp.SectionMapId == section.Id)/*.OrderBy(gp => gp.or)*/.ToList();
@ -262,9 +262,9 @@ namespace ManagerService.Controllers
var subDTO = SectionFactory.ToDTO(subSection); var subDTO = SectionFactory.ToDTO(subSection);
switch (subSection.Type) switch (subSection.Type)
{ {
case SectionType.Puzzle: case SectionType.Game:
Resource resourceSub = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == (subDTO as PuzzleDTO).puzzleImageId); Resource resourceSub = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == (subDTO as GameDTO).puzzleImageId);
(subDTO as PuzzleDTO).puzzleImage = resourceSub?.ToDTO(); (subDTO as GameDTO).puzzleImage = resourceSub?.ToDTO();
break; break;
case SectionType.Map: case SectionType.Map:
var geoPointsSub = _myInfoMateDbContext.GeoPoints.Where(gp => gp.SectionMapId == subSection.Id).ToList(); var geoPointsSub = _myInfoMateDbContext.GeoPoints.Where(gp => gp.SectionMapId == subSection.Id).ToList();
@ -609,11 +609,11 @@ namespace ManagerService.Controllers
PDFOrderedTranslationAndResources = [] PDFOrderedTranslationAndResources = []
}; };
break; break;
case SectionType.Puzzle: case SectionType.Game:
section = new SectionPuzzle section = new SectionGame
{ {
PuzzleMessageDebut = [], GameMessageDebut = [],
PuzzleMessageFin = [] GameMessageFin = []
}; };
break; break;
case SectionType.Quiz: case SectionType.Quiz:
@ -1102,7 +1102,7 @@ namespace ManagerService.Controllers
/// <summary> /// <summary>
/// Useless, just to generate dto code /// Useless, just to generate dto code
/// </summary> /// </summary>
[ProducesResponseType(typeof(PuzzleDTO), 200)] [ProducesResponseType(typeof(GameDTO), 200)]
[HttpGet("PuzzleDTO")] [HttpGet("PuzzleDTO")]
public ObjectResult GetPuzzleDTO() public ObjectResult GetPuzzleDTO()
{ {

View File

@ -10,7 +10,7 @@
Quiz, Quiz,
Article, Article,
PDF, PDF,
Puzzle, Game,
Agenda, Agenda,
Weather, Weather,
Event Event

View File

@ -1,9 +1,10 @@
using ManagerService.DTOs; using ManagerService.DTOs;
using System.Collections.Generic; using System.Collections.Generic;
using static ManagerService.Data.SubSection.SectionGame;
namespace Manager.DTOs namespace Manager.DTOs
{ {
public class PuzzleDTO : SectionDTO public class GameDTO : SectionDTO
{ {
public List<TranslationAndResourceDTO> messageDebut { get; set; } public List<TranslationAndResourceDTO> messageDebut { get; set; }
public List<TranslationAndResourceDTO> messageFin { get; set; } public List<TranslationAndResourceDTO> messageFin { get; set; }
@ -11,5 +12,6 @@ namespace Manager.DTOs
public string puzzleImageId { get; set; } // But only image is possible public string puzzleImageId { get; set; } // But only image is possible
public int rows { get; set; } = 3; public int rows { get; set; } = 3;
public int cols { get; set; } = 3; public int cols { get; set; } = 3;
public GameTypes gameType { get; set; } = GameTypes.Puzzle;
} }
} }

View File

@ -40,7 +40,7 @@ namespace ManagerService.Data
public bool IsSectionImageBackground { get; set; } // => Chose layout of main page // Specific Kiosk public bool IsSectionImageBackground { get; set; } // => Chose layout of main page // Specific Kiosk
public LayoutMainPageType LayoutMainPage { get; set; } = LayoutMainPageType.MasonryGrid; // Specific Kiosk public LayoutMainPageType LayoutMainPage { get; set; } = LayoutMainPageType.MasonryGrid; // Specific Kiosk and mobile
public string LoaderImageId { get; set; } // Specific Kiosk public string LoaderImageId { get; set; } // Specific Kiosk

View File

@ -69,7 +69,7 @@ namespace ManagerService.Data
.HasValue<SectionMap>("Map") .HasValue<SectionMap>("Map")
.HasValue<SectionMenu>("Menu") .HasValue<SectionMenu>("Menu")
.HasValue<SectionPdf>("PDF") .HasValue<SectionPdf>("PDF")
.HasValue<SectionPuzzle>("Puzzle") .HasValue<SectionGame>("Game")
.HasValue<SectionQuiz>("Quiz") .HasValue<SectionQuiz>("Quiz")
.HasValue<SectionSlider>("Slider") .HasValue<SectionSlider>("Slider")
.HasValue<SectionVideo>("Video") .HasValue<SectionVideo>("Video")

View File

@ -31,6 +31,11 @@ namespace ManagerService.Data.SubSection
[ForeignKey("SectionEventId")] [ForeignKey("SectionEventId")]
public SectionEvent? SectionEvent { get; set; } public SectionEvent? SectionEvent { get; set; }
// Lié à une section game (optionnel) => Escape game / geolocalisé ou non
public string? SectionGameId { get; set; }
[ForeignKey("SectionGameId")]
public SectionGame? SectionGame { get; set; }
// Type de parcours // Type de parcours
public bool IsLinear { get; set; } = true; // Avancer dans lordre - Ordre obligatoire public bool IsLinear { get; set; } = true; // Avancer dans lordre - Ordre obligatoire
public bool RequireSuccessToAdvance { get; set; } = false; // Par exemple: résoudre une énigme public bool RequireSuccessToAdvance { get; set; } = false; // Par exemple: résoudre une énigme

View File

@ -27,7 +27,7 @@ namespace ManagerService.Data.SubSection
[Column(TypeName = "jsonb")] [Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; } public List<TranslationDTO> Description { get; set; }
public Geometry Geometry { get; set; } // Polygon ou centre du cercle public Geometry? Geometry { get; set; } // Polygon ou centre du cercle
public double? ZoneRadiusMeters { get; set; } // Optionnel, utile si zone cercle ou point public double? ZoneRadiusMeters { get; set; } // Optionnel, utile si zone cercle ou point
@ -36,7 +36,7 @@ namespace ManagerService.Data.SubSection
public int? TriggerGeoPointId { get; set; } // Lieu lié à l'étape et genre si on veut plus d'info ou pourrait afficher les infos du geopoint. public int? TriggerGeoPointId { get; set; } // Lieu lié à l'étape et genre si on veut plus d'info ou pourrait afficher les infos du geopoint.
[ForeignKey("TriggerGeoPointId")] [ForeignKey("TriggerGeoPointId")]
public GeoPoint TriggerGeoPoint { get; set; } public GeoPoint? TriggerGeoPoint { get; set; }
public bool IsHiddenInitially { get; set; } = false; public bool IsHiddenInitially { get; set; } = false;

View File

@ -10,33 +10,32 @@ using System.Linq;
namespace ManagerService.Data.SubSection namespace ManagerService.Data.SubSection
{ {
/// <summary> /// <summary>
/// Section puzzle /// Section game
/// </summary> /// </summary>
public class SectionPuzzle : Section public class SectionGame : Section
{ {
[Required] [Required]
[Column(TypeName = "jsonb")] [Column(TypeName = "jsonb")]
public List<TranslationAndResourceDTO> PuzzleMessageDebut { get; set; } public List<TranslationAndResourceDTO> GameMessageDebut { get; set; }
[Required] [Required]
[Column(TypeName = "jsonb")] [Column(TypeName = "jsonb")]
public List<TranslationAndResourceDTO> PuzzleMessageFin { get; set; } public List<TranslationAndResourceDTO> GameMessageFin { get; set; }
public string PuzzleImageId { get; set; } // But only image is possible public string GamePuzzleImageId { get; set; } // But only image is possible
public Resource PuzzleImage { get; set; } // But only image is possible public Resource GamePuzzleImage { get; set; } // But only image is possible
[Required] [Required]
public int PuzzleRows { get; set; } = 3; public int GamePuzzleRows { get; set; } = 3;
[Required] [Required]
public int PuzzleCols { get; set; } = 3; public int GamePuzzleCols { get; set; } = 3;
public bool IsSlidingPuzzle { get; set; } = false; public GameTypes GameType { get; set; } = GameTypes.Puzzle;
public GameDTO ToDTO()
public PuzzleDTO ToDTO()
{ {
return new PuzzleDTO() return new GameDTO()
{ {
id = Id, id = Id,
label = Label, label = Label,
@ -56,13 +55,21 @@ namespace ManagerService.Data.SubSection
latitude = Latitude, latitude = Latitude,
longitude = Longitude, longitude = Longitude,
meterZoneGPS = MeterZoneGPS, meterZoneGPS = MeterZoneGPS,
messageDebut = PuzzleMessageDebut, messageDebut = GameMessageDebut,
messageFin = PuzzleMessageFin, messageFin = GameMessageFin,
puzzleImage = PuzzleImage.ToDTO(), puzzleImage = GamePuzzleImage.ToDTO(),
puzzleImageId = PuzzleImageId, puzzleImageId = GamePuzzleImageId,
rows = PuzzleRows, rows = GamePuzzleRows,
cols = PuzzleCols cols = GamePuzzleCols,
gameType = GameType
}; };
} }
public enum GameTypes
{
Puzzle,
SlidingPuzzle,
Escape
}
} }
} }

View File

@ -42,7 +42,8 @@ namespace ManagerService.Helpers
public static Geometry FromDto(this GeometryDTO dto, GeometryFactory factory = null!) public static Geometry FromDto(this GeometryDTO dto, GeometryFactory factory = null!)
{ {
factory ??= NtsGeometryServices.Instance.CreateGeometryFactory(); factory ??= NtsGeometryServices.Instance.CreateGeometryFactory(srid: 4326);
return dto.type switch return dto.type switch
{ {
@ -56,7 +57,8 @@ namespace ManagerService.Helpers
private static Point CreatePoint(GeometryDTO dto, GeometryFactory factory) private static Point CreatePoint(GeometryDTO dto, GeometryFactory factory)
{ {
var coords = ((JsonElement)dto.coordinates).Deserialize<List<double>>(); var coords = ((JsonElement)dto.coordinates).Deserialize<List<double>>();
return factory.CreatePoint(new Coordinate(coords[0], coords[1])); var point = factory.CreatePoint(new Coordinate(coords[0], coords[1]));
return point;
} }
private static LineString CreateLineString(GeometryDTO dto, GeometryFactory factory) private static LineString CreateLineString(GeometryDTO dto, GeometryFactory factory)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ManagerService.Migrations
{
/// <inheritdoc />
public partial class UpdatePuzzleToGame : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Sections_Resources_PuzzleImageId",
table: "Sections");
migrationBuilder.DropColumn(
name: "IsSlidingPuzzle",
table: "Sections");
migrationBuilder.RenameColumn(
name: "PuzzleRows",
table: "Sections",
newName: "GameType");
migrationBuilder.RenameColumn(
name: "PuzzleMessageFin",
table: "Sections",
newName: "GameMessageFin");
migrationBuilder.RenameColumn(
name: "PuzzleMessageDebut",
table: "Sections",
newName: "GameMessageDebut");
migrationBuilder.RenameColumn(
name: "PuzzleImageId",
table: "Sections",
newName: "GamePuzzleImageId");
migrationBuilder.RenameColumn(
name: "PuzzleCols",
table: "Sections",
newName: "GamePuzzleRows");
migrationBuilder.RenameIndex(
name: "IX_Sections_PuzzleImageId",
table: "Sections",
newName: "IX_Sections_GamePuzzleImageId");
migrationBuilder.AddColumn<int>(
name: "GamePuzzleCols",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SectionGameId",
table: "GuidedPaths",
type: "text",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_GuidedPaths_SectionGameId",
table: "GuidedPaths",
column: "SectionGameId");
migrationBuilder.AddForeignKey(
name: "FK_GuidedPaths_Sections_SectionGameId",
table: "GuidedPaths",
column: "SectionGameId",
principalTable: "Sections",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Sections_Resources_GamePuzzleImageId",
table: "Sections",
column: "GamePuzzleImageId",
principalTable: "Resources",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_GuidedPaths_Sections_SectionGameId",
table: "GuidedPaths");
migrationBuilder.DropForeignKey(
name: "FK_Sections_Resources_GamePuzzleImageId",
table: "Sections");
migrationBuilder.DropIndex(
name: "IX_GuidedPaths_SectionGameId",
table: "GuidedPaths");
migrationBuilder.DropColumn(
name: "GamePuzzleCols",
table: "Sections");
migrationBuilder.DropColumn(
name: "SectionGameId",
table: "GuidedPaths");
migrationBuilder.RenameColumn(
name: "GameType",
table: "Sections",
newName: "PuzzleRows");
migrationBuilder.RenameColumn(
name: "GamePuzzleRows",
table: "Sections",
newName: "PuzzleCols");
migrationBuilder.RenameColumn(
name: "GamePuzzleImageId",
table: "Sections",
newName: "PuzzleImageId");
migrationBuilder.RenameColumn(
name: "GameMessageFin",
table: "Sections",
newName: "PuzzleMessageFin");
migrationBuilder.RenameColumn(
name: "GameMessageDebut",
table: "Sections",
newName: "PuzzleMessageDebut");
migrationBuilder.RenameIndex(
name: "IX_Sections_GamePuzzleImageId",
table: "Sections",
newName: "IX_Sections_PuzzleImageId");
migrationBuilder.AddColumn<bool>(
name: "IsSlidingPuzzle",
table: "Sections",
type: "boolean",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Sections_Resources_PuzzleImageId",
table: "Sections",
column: "PuzzleImageId",
principalTable: "Resources",
principalColumn: "Id");
}
}
}

View File

@ -554,6 +554,9 @@ namespace ManagerService.Migrations
b.Property<string>("SectionEventId") b.Property<string>("SectionEventId")
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("SectionGameId")
.HasColumnType("text");
b.Property<string>("SectionMapId") b.Property<string>("SectionMapId")
.HasColumnType("text"); .HasColumnType("text");
@ -565,6 +568,8 @@ namespace ManagerService.Migrations
b.HasIndex("SectionEventId"); b.HasIndex("SectionEventId");
b.HasIndex("SectionGameId");
b.HasIndex("SectionMapId"); b.HasIndex("SectionMapId");
b.ToTable("GuidedPaths"); b.ToTable("GuidedPaths");
@ -840,6 +845,35 @@ namespace ManagerService.Migrations
b.HasDiscriminator().HasValue("Event"); b.HasDiscriminator().HasValue("Event");
}); });
modelBuilder.Entity("ManagerService.Data.SubSection.SectionGame", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<List<TranslationAndResourceDTO>>("GameMessageDebut")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResourceDTO>>("GameMessageFin")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("GamePuzzleCols")
.HasColumnType("integer");
b.Property<string>("GamePuzzleImageId")
.HasColumnType("text");
b.Property<int>("GamePuzzleRows")
.HasColumnType("integer");
b.Property<int>("GameType")
.HasColumnType("integer");
b.HasIndex("GamePuzzleImageId");
b.HasDiscriminator().HasValue("Game");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{ {
b.HasBaseType("ManagerService.Data.Section"); b.HasBaseType("ManagerService.Data.Section");
@ -892,35 +926,6 @@ namespace ManagerService.Migrations
b.HasDiscriminator().HasValue("PDF"); b.HasDiscriminator().HasValue("PDF");
}); });
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<bool>("IsSlidingPuzzle")
.HasColumnType("boolean");
b.Property<int>("PuzzleCols")
.HasColumnType("integer");
b.Property<string>("PuzzleImageId")
.HasColumnType("text");
b.Property<List<TranslationAndResourceDTO>>("PuzzleMessageDebut")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResourceDTO>>("PuzzleMessageFin")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("PuzzleRows")
.HasColumnType("integer");
b.HasIndex("PuzzleImageId");
b.HasDiscriminator().HasValue("Puzzle");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
{ {
b.HasBaseType("ManagerService.Data.Section"); b.HasBaseType("ManagerService.Data.Section");
@ -1087,12 +1092,18 @@ namespace ManagerService.Migrations
.WithMany() .WithMany()
.HasForeignKey("SectionEventId"); .HasForeignKey("SectionEventId");
b.HasOne("ManagerService.Data.SubSection.SectionGame", "SectionGame")
.WithMany()
.HasForeignKey("SectionGameId");
b.HasOne("ManagerService.Data.SubSection.SectionMap", "SectionMap") b.HasOne("ManagerService.Data.SubSection.SectionMap", "SectionMap")
.WithMany() .WithMany()
.HasForeignKey("SectionMapId"); .HasForeignKey("SectionMapId");
b.Navigation("SectionEvent"); b.Navigation("SectionEvent");
b.Navigation("SectionGame");
b.Navigation("SectionMap"); b.Navigation("SectionMap");
}); });
@ -1160,6 +1171,15 @@ namespace ManagerService.Migrations
.HasForeignKey("SectionEventId"); .HasForeignKey("SectionEventId");
}); });
modelBuilder.Entity("ManagerService.Data.SubSection.SectionGame", b =>
{
b.HasOne("ManagerService.Data.Resource", "GamePuzzleImage")
.WithMany()
.HasForeignKey("GamePuzzleImageId");
b.Navigation("GamePuzzleImage");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{ {
b.HasOne("ManagerService.Data.Resource", "MapResource") b.HasOne("ManagerService.Data.Resource", "MapResource")
@ -1169,15 +1189,6 @@ namespace ManagerService.Migrations
b.Navigation("MapResource"); b.Navigation("MapResource");
}); });
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
{
b.HasOne("ManagerService.Data.Resource", "PuzzleImage")
.WithMany()
.HasForeignKey("PuzzleImageId");
b.Navigation("PuzzleImage");
});
modelBuilder.Entity("ManagerService.Data.ApplicationInstance", b => modelBuilder.Entity("ManagerService.Data.ApplicationInstance", b =>
{ {
b.Navigation("Configurations"); b.Navigation("Configurations");

View File

@ -18,7 +18,7 @@ namespace ManagerService.Services
MapDTO mapDTO = new MapDTO(); MapDTO mapDTO = new MapDTO();
MenuDTO menuDTO = new MenuDTO(); MenuDTO menuDTO = new MenuDTO();
PdfDTO pdfDTO = new PdfDTO(); PdfDTO pdfDTO = new PdfDTO();
PuzzleDTO puzzleDTO = new PuzzleDTO(); GameDTO puzzleDTO = new GameDTO();
QuizDTO quizDTO = new QuizDTO(); QuizDTO quizDTO = new QuizDTO();
SliderDTO sliderDTO = new SliderDTO(); SliderDTO sliderDTO = new SliderDTO();
VideoDTO videoDTO = new VideoDTO(); VideoDTO videoDTO = new VideoDTO();
@ -45,8 +45,8 @@ namespace ManagerService.Services
case SectionType.PDF: case SectionType.PDF:
pdfDTO = JsonConvert.DeserializeObject<PdfDTO>(jsonElement.ToString()); pdfDTO = JsonConvert.DeserializeObject<PdfDTO>(jsonElement.ToString());
break; break;
case SectionType.Puzzle: case SectionType.Game:
puzzleDTO = JsonConvert.DeserializeObject<PuzzleDTO>(jsonElement.ToString()); puzzleDTO = JsonConvert.DeserializeObject<GameDTO>(jsonElement.ToString());
break; break;
case SectionType.Quiz: case SectionType.Quiz:
quizDTO = JsonConvert.DeserializeObject<QuizDTO>(jsonElement.ToString()); quizDTO = JsonConvert.DeserializeObject<QuizDTO>(jsonElement.ToString());
@ -215,7 +215,7 @@ namespace ManagerService.Services
Type = dto.type, Type = dto.type,
PDFOrderedTranslationAndResources = pdfDTO.pdfs PDFOrderedTranslationAndResources = pdfDTO.pdfs
}, },
SectionType.Puzzle => new SectionPuzzle SectionType.Game => new SectionGame
{ {
Id = dto.id, Id = dto.id,
DateCreation = dto.dateCreation.Value, DateCreation = dto.dateCreation.Value,
@ -235,11 +235,11 @@ namespace ManagerService.Services
Longitude = dto.longitude, Longitude = dto.longitude,
MeterZoneGPS = dto.meterZoneGPS, MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type, Type = dto.type,
PuzzleMessageDebut = puzzleDTO.messageDebut, GameMessageDebut = puzzleDTO.messageDebut,
PuzzleMessageFin = puzzleDTO.messageFin, GameMessageFin = puzzleDTO.messageFin,
PuzzleImageId = puzzleDTO.puzzleImageId, GamePuzzleImageId = puzzleDTO.puzzleImageId,
PuzzleRows = puzzleDTO.rows, GamePuzzleRows = puzzleDTO.rows,
PuzzleCols = puzzleDTO.cols GamePuzzleCols = puzzleDTO.cols
}, },
SectionType.Quiz => new SectionQuiz SectionType.Quiz => new SectionQuiz
{ {
@ -516,32 +516,32 @@ namespace ManagerService.Services
type = pdf.Type, type = pdf.Type,
pdfs = pdf.PDFOrderedTranslationAndResources pdfs = pdf.PDFOrderedTranslationAndResources
}, },
SectionPuzzle puzzle => new PuzzleDTO SectionGame game => new GameDTO
{ {
id = puzzle.Id, id = game.Id,
dateCreation = puzzle.DateCreation, dateCreation = game.DateCreation,
configurationId = puzzle.ConfigurationId, configurationId = game.ConfigurationId,
instanceId = puzzle.InstanceId, instanceId = game.InstanceId,
label = puzzle.Label, label = game.Label,
title = puzzle.Title, title = game.Title,
description = puzzle.Description, description = game.Description,
order = puzzle.Order, order = game.Order,
imageId = puzzle.ImageId, imageId = game.ImageId,
imageSource = puzzle.ImageSource, imageSource = game.ImageSource,
isSubSection = puzzle.IsSubSection, isSubSection = game.IsSubSection,
parentId = puzzle.ParentId, parentId = game.ParentId,
isBeacon = puzzle.IsBeacon, isBeacon = game.IsBeacon,
beaconId = puzzle.BeaconId, beaconId = game.BeaconId,
latitude = puzzle.Latitude, latitude = game.Latitude,
longitude = puzzle.Longitude, longitude = game.Longitude,
meterZoneGPS = puzzle.MeterZoneGPS, meterZoneGPS = game.MeterZoneGPS,
type = puzzle.Type, type = game.Type,
messageDebut = puzzle.PuzzleMessageDebut, messageDebut = game.GameMessageDebut,
messageFin = puzzle.PuzzleMessageFin, messageFin = game.GameMessageFin,
puzzleImage = puzzle.PuzzleImage?.ToDTO(), puzzleImage = game.GamePuzzleImage?.ToDTO(),
puzzleImageId = puzzle.PuzzleImageId, puzzleImageId = game.GamePuzzleImageId,
rows = puzzle.PuzzleRows, rows = game.GamePuzzleRows,
cols = puzzle.PuzzleCols cols = game.GamePuzzleCols
}, },
SectionQuiz quiz => new QuizDTO SectionQuiz quiz => new QuizDTO
{ {

View File

@ -161,6 +161,8 @@ namespace ManagerService
services.AddDbContext<MyInfoMateDbContext>(options => services.AddDbContext<MyInfoMateDbContext>(options =>
options.UseNpgsql(dataSource, o => o.UseNetTopologySuite()) options.UseNpgsql(dataSource, o => o.UseNetTopologySuite())
.EnableSensitiveDataLogging() // montre les valeurs des paramètres
.LogTo(Console.WriteLine, LogLevel.Information)
); );
} }
@ -188,7 +190,7 @@ namespace ManagerService
app.UseCors( app.UseCors(
#if DEBUG #if DEBUG
options => options options => options
.SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:57209") .SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:55307")
.AllowAnyMethod() .AllowAnyMethod()
.AllowAnyHeader() .AllowAnyHeader()
.AllowCredentials() .AllowCredentials()