diff --git a/ManagerService/Controllers/SectionAgendaController.cs b/ManagerService/Controllers/SectionAgendaController.cs
index 73634c9..4881b8d 100644
--- a/ManagerService/Controllers/SectionAgendaController.cs
+++ b/ManagerService/Controllers/SectionAgendaController.cs
@@ -1,20 +1,17 @@
-using Manager.DTOs;
-using Manager.Helpers;
-using ManagerService.Data;
+using ManagerService.Data;
using ManagerService.Data.SubSection;
-using ManagerService.DTOs;
using ManagerService.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
-using Mqtt.Client.AspNetCore.Services;
-using Newtonsoft.Json;
using NSwag.Annotations;
-using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text.Json;
+using System;
+using ManagerService.DTOs;
+using ManagerService.Helpers;
namespace ManagerService.Controllers
{
@@ -37,137 +34,76 @@ namespace ManagerService.Controllers
}
///
- /// Create a new section
+ /// Get all event from section
///
- /// New section info
- /*[ProducesResponseType(typeof(SectionDTO), 200)]
- [ProducesResponseType(typeof(string), 400)]
- [ProducesResponseType(typeof(string), 409)]
+ /// Section id
+ [AllowAnonymous]
+ [ProducesResponseType(typeof(List), 200)]
+ [ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
- [HttpPost()]
- public ObjectResult Create([FromBody] SectionDTO newSection)
+ [HttpGet("{sectionAgendaId}/events")]
+ public ObjectResult GetAllEventAgendaFromSection(string sectionAgendaId)
{
try
{
- if (newSection == null)
+ SectionAgenda sectionAgenda = _myInfoMateDbContext.Sections.OfType().Include(sa => sa.EventAgendas).ThenInclude(sa => sa.Resource).FirstOrDefault(sa => sa.Id == sectionAgendaId);
+
+ if (sectionAgenda == null)
+ throw new KeyNotFoundException("Section agenda does not exist");
+
+ /*List programmeBlocks = new List();
+ foreach (var program in sectionEvent.Programme)
+ {
+ foreach (var mapAnnotation in program.MapAnnotations) {
+ var resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == mapAnnotation.IconResourceId);
+ if (resource != null)
+ {
+ mapAnnotation.IconResource = resource; // TO check.. use DTO instead ?
+ }
+ }
+ }*/
+
+ return new OkObjectResult(sectionAgenda.EventAgendas.Select(ea => ea.ToDTO()));
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Create new event
+ ///
+ /// Section agenda Id
+ /// EventAgenda
+ [ProducesResponseType(typeof(EventAgendaDTO), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 409)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPost("{sectionAgendaId}/event")]
+ public ObjectResult CreateEventAgenda(string sectionAgendaId, [FromBody] EventAgendaDTO eventAgendaDTO)
+ {
+ try
+ {
+ if (sectionAgendaId == null)
throw new ArgumentNullException("Section param is null");
- if (newSection.configurationId == null)
- throw new ArgumentNullException("Configuration param is null");
+ if (eventAgendaDTO == null)
+ throw new ArgumentNullException("EventAgenda param is null");
- var configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == newSection.configurationId);
- if (configuration == null)
- throw new KeyNotFoundException("Configuration does not exist");
+ var existingSection = _myInfoMateDbContext.Sections.OfType().Include(sa => sa.EventAgendas).FirstOrDefault(sa => sa.Id == sectionAgendaId);
+ if (existingSection == null)
+ throw new KeyNotFoundException("Section agenda does not exist");
- // Todo add some verification ?
- Section section = new Section();
-
- // Preparation
- List languages = _configuration.GetSection("SupportedLanguages").Get>();
-
- switch (newSection.type)
- {
- case SectionType.Map:
- section = new SectionMap
- {
- MapMapType = MapTypeApp.hybrid,
- MapTypeMapbox = MapTypeMapBox.standard,
- MapMapProvider = MapProvider.Google,
- MapZoom = 18,
- MapPoints = new List(),
- MapCategories = new List()
- };
- break;
- case SectionType.Slider:
- section = new SectionSlider
- {
- SliderContents = new List()
- };
- break;
- case SectionType.Video:
- section = new SectionVideo
- {
- VideoSource = "",
- };
- break;
- case SectionType.Web:
- section = new SectionWeb
- {
- WebSource = "",
- };
- break;
- case SectionType.Menu:
- section = new SectionMenu
- {
- MenuSections = new List(),
- };
- break;
- case SectionType.Quiz:
- section = new SectionQuiz
- {
- QuizQuestions = new List(),
- // TODO levels ?
- };
- break;
- case SectionType.Article:
- section = new SectionArticle
- {
- ArticleContents = new List(),
- ArticleContent = LanguageInit.Init("Content", languages),
- ArticleAudioIds = LanguageInit.Init("Audio", languages, true)
- };
- break;
- case SectionType.PDF:
- section = new SectionPdf
- {
- PDFOrderedTranslationAndResources = []
- };
- break;
- case SectionType.Puzzle:
- section = new SectionPuzzle
- {
- PuzzleMessageDebut = [],
- PuzzleMessageFin = []
- };
- break;
- case SectionType.Agenda:
- section = new SectionAgenda
- {
- AgendaResourceIds = new List()
- };
- break;
- case SectionType.Weather:
- section = new SectionWeather();
- break;
- }
-
- section.InstanceId = newSection.instanceId;
- section.Label = newSection.label;
- section.ImageId = newSection.imageId;
- section.ImageSource = newSection.imageSource;
- section.ConfigurationId = newSection.configurationId;
- section.DateCreation = DateTime.Now.ToUniversalTime();
- section.IsSubSection = newSection.isSubSection;
- section.ParentId = newSection.parentId;
- section.Type = newSection.type;
-
- section.Order = _myInfoMateDbContext.Sections.Count(s => s.ConfigurationId == newSection.configurationId && !s.IsSubSection) + 1;
-
- section.IsBeacon = newSection.isBeacon;
- section.BeaconId = newSection.beaconId;
- section.Latitude = newSection.latitude;
- section.Longitude = newSection.longitude;
- section.MeterZoneGPS = newSection.meterZoneGPS;
-
- section.Title = LanguageInit.Init("Title", languages);
- section.Description = LanguageInit.Init("Description", languages);
-
- section.Id = idService.GenerateHexId();
- //_sectionService.Create(section);
- _myInfoMateDbContext.Add(section);
+ EventAgenda eventAgenda = new EventAgenda().FromDTO(eventAgendaDTO);
+ _myInfoMateDbContext.EventAgendas.Add(eventAgenda);
_myInfoMateDbContext.SaveChanges();
- return new OkObjectResult(section.ToDTO());
+ return new OkObjectResult(eventAgenda.ToDTO());
}
catch (ArgumentNullException ex)
{
@@ -181,99 +117,61 @@ namespace ManagerService.Controllers
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
- }*/
+ }
///
- /// Update sections order
+ /// Update an event agenda
///
- /// New sections order
- /*[ProducesResponseType(typeof(string), 200)]
+ /// EventAgenda to update
+ [ProducesResponseType(typeof(EventAgendaDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
- [HttpPut("order")]
- public ObjectResult UpdateOrder([FromBody] List updatedSectionsOrder)
- {
- // TODO REWRITE LOGIC..
- try
- {
- if (updatedSectionsOrder == null)
- throw new ArgumentNullException("Sections param is null");
-
- foreach (var section in updatedSectionsOrder)
- {
- var sectionDB = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == section.id);
- if (sectionDB == null)
- throw new KeyNotFoundException($"Section {section.label} with id {section.id} does not exist");
- }
-
- foreach (var updatedSection in updatedSectionsOrder)
- {
- var section = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == updatedSection.id);
- //OldSection section = _sectionService.GetById(updatedSection.id);
- section.Order = updatedSection.order.GetValueOrDefault();
- _myInfoMateDbContext.SaveChanges();
-
- //_sectionService.Update(section.Id, section);
- }
-
- if (updatedSectionsOrder.Count > 0) {
- MqttClientService.PublishMessage($"config/{updatedSectionsOrder[0].configurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
- }
-
- return new ObjectResult("Sections order has been successfully modified") { StatusCode = 200 };
- }
- catch (ArgumentNullException ex)
- {
- return new BadRequestObjectResult(ex.Message) { };
- }
- catch (KeyNotFoundException ex)
- {
- return new NotFoundObjectResult(ex.Message) { };
- }
- catch (Exception ex)
- {
- return new ObjectResult(ex.Message) { StatusCode = 500 };
- }
- }*/
-
-
- ///
- /// Delete a section
- ///
- /// Id of section to delete
- /*[ProducesResponseType(typeof(string), 202)]
- [ProducesResponseType(typeof(string), 400)]
- [ProducesResponseType(typeof(string), 404)]
- [ProducesResponseType(typeof(string), 500)]
- [HttpDelete("{id}")]
- public ObjectResult Delete(string id)
+ [HttpPut("event")]
+ public ObjectResult UpdateEventAgenda([FromBody] EventAgendaDTO eventAgendaDTO)
{
try
{
- if (id == null)
- throw new ArgumentNullException("Section param is null");
+ if (eventAgendaDTO == null)
+ throw new ArgumentNullException("EventAgenda param is null");
- var section = _myInfoMateDbContext.Sections.FirstOrDefault(s => s.Id == id);
- if (section == null)
- throw new KeyNotFoundException("Section does not exist");
+ var existing = _myInfoMateDbContext.EventAgendas.FirstOrDefault(ea => ea.Id == eventAgendaDTO.Id);
+ if (existing == null)
+ throw new KeyNotFoundException("EventAgenda does not exist");
- _myInfoMateDbContext.Remove(section);
- //_sectionService.Remove(id);
+ existing.Label = eventAgendaDTO.Label;
+ existing.Description = eventAgendaDTO.Description;
+ existing.Type = eventAgendaDTO.Type;
+ existing.DateAdded = eventAgendaDTO.DateAdded;
+ existing.DateFrom = eventAgendaDTO.DateFrom;
+ existing.DateTo = eventAgendaDTO.DateTo;
+ existing.Website = eventAgendaDTO.Website;
+ existing.ResourceId = eventAgendaDTO.ResourceId;
+ existing.Phone = eventAgendaDTO.Phone;
+ existing.Email = eventAgendaDTO.Email;
+ existing.SectionAgendaId = eventAgendaDTO.SectionAgendaId;
+ existing.SectionEventId = eventAgendaDTO.SectionEventId;
- // update order from rest // TODO TEST
- List 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++;
+ if (eventAgendaDTO.Address != null)
+ {
+ existing.Address = new EventAddress
+ {
+ Address = eventAgendaDTO.Address.Address,
+ StreetNumber = eventAgendaDTO.Address.StreetNumber,
+ StreetName = eventAgendaDTO.Address.StreetName,
+ City = eventAgendaDTO.Address.City,
+ State = eventAgendaDTO.Address.State,
+ PostCode = eventAgendaDTO.Address.PostCode,
+ Country = eventAgendaDTO.Address.Country,
+ Geometry = eventAgendaDTO.Address.Geometry?.FromDto(),
+ PolyColor = eventAgendaDTO.Address.PolyColor,
+ Zoom = eventAgendaDTO.Address.Zoom
+ };
}
_myInfoMateDbContext.SaveChanges();
- return new ObjectResult("The section has been deleted") { StatusCode = 202 };
-
+ return new OkObjectResult(existing.ToDTO());
}
catch (ArgumentNullException ex)
{
@@ -287,6 +185,41 @@ namespace ManagerService.Controllers
{
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
- }*/
+ }
+
+ ///
+ /// Delete an eventAgenda
+ ///
+ /// Id of the eventAgenda to delete
+ [ProducesResponseType(typeof(string), 202)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpDelete("event/{eventAgendaId}")]
+ public ObjectResult DeleteEventAgenda(int eventAgendaId)
+ {
+ try
+ {
+ var eventAgenda = _myInfoMateDbContext.EventAgendas.FirstOrDefault(ea => ea.Id == eventAgendaId);
+ if (eventAgenda == null)
+ throw new KeyNotFoundException("EventAgenda does not exist");
+
+ _myInfoMateDbContext.Remove(eventAgenda);
+ _myInfoMateDbContext.SaveChanges();
+
+ return new ObjectResult("The eventAgenda has been deleted") { StatusCode = 202 };
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
}
}
diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs
index 3a9608a..c810b50 100644
--- a/ManagerService/Controllers/SectionController.cs
+++ b/ManagerService/Controllers/SectionController.cs
@@ -161,6 +161,19 @@ namespace ManagerService.Controllers
switch (section.Type)
{
+ case SectionType.Agenda:
+ var eventAgendas = _myInfoMateDbContext.EventAgendas.Where(ea => ea.SectionAgendaId == section.Id)/*.OrderBy(gp => gp.or)*/.ToList();
+ List eventAgendaDTOs = new List();
+ foreach (var eventAgenda in eventAgendas)
+ {
+ eventAgendaDTOs.Add(eventAgenda.ToDTO());
+ }
+ (dto as AgendaDTO).events = eventAgendaDTOs;
+ break;
+ case SectionType.Event:
+ var sectionEvent = _myInfoMateDbContext.Sections.OfType().Include(se => se.Programme).ThenInclude(se => se.MapAnnotations).FirstOrDefault(s => s.Id == id);
+ (dto as SectionEventDTO).Programme = sectionEvent.Programme; // TODO test ! Need dto ?
+ break;
case SectionType.Puzzle:
Resource resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == (dto as PuzzleDTO).puzzleImageId);
(dto as PuzzleDTO).puzzleImage = resource.ToDTO();
@@ -515,7 +528,30 @@ namespace ManagerService.Controllers
// Preparation
List languages = _configuration.GetSection("SupportedLanguages").Get>();
- switch (newSection.type) {
+ switch (newSection.type)
+ {
+ case SectionType.Agenda:
+ section = new SectionAgenda
+ {
+ AgendaResourceIds = new List(),
+ EventAgendas = new List()
+ };
+ break;
+ case SectionType.Article:
+ section = new SectionArticle
+ {
+ ArticleContents = new List(),
+ ArticleContent = LanguageInit.Init("Content", languages),
+ ArticleAudioIds = LanguageInit.Init("Audio", languages, true)
+ };
+ break;
+ case SectionType.Event:
+ section = new SectionEvent
+ {
+ Programme = new List(),
+ ParcoursIds = new List()
+ };
+ break;
case SectionType.Map:
section = new SectionMap
{
@@ -527,45 +563,12 @@ namespace ManagerService.Controllers
MapCategories = new List()
};
break;
- case SectionType.Slider:
- section = new SectionSlider
- {
- SliderContents = new List()
- };
- break;
- case SectionType.Video:
- section = new SectionVideo
- {
- VideoSource = "",
- };
- break;
- case SectionType.Web:
- section = new SectionWeb
- {
- WebSource = "",
- };
- break;
case SectionType.Menu:
section = new SectionMenu
{
MenuSections = new List(),
};
break;
- case SectionType.Quiz:
- section = new SectionQuiz
- {
- QuizQuestions = new List(),
- // TODO levels ?
- };
- break;
- case SectionType.Article:
- section = new SectionArticle
- {
- ArticleContents = new List(),
- ArticleContent = LanguageInit.Init("Content", languages),
- ArticleAudioIds = LanguageInit.Init("Audio", languages, true)
- };
- break;
case SectionType.PDF:
section = new SectionPdf
{
@@ -579,15 +582,34 @@ namespace ManagerService.Controllers
PuzzleMessageFin = []
};
break;
- case SectionType.Agenda:
- section = new SectionAgenda
+ case SectionType.Quiz:
+ section = new SectionQuiz
{
- AgendaResourceIds = new List()
+ QuizQuestions = new List(),
+ // TODO levels ?
+ };
+ break;
+ case SectionType.Slider:
+ section = new SectionSlider
+ {
+ SliderContents = new List()
+ };
+ break;
+ case SectionType.Video:
+ section = new SectionVideo
+ {
+ VideoSource = "",
};
break;
case SectionType.Weather:
section = new SectionWeather();
break;
+ case SectionType.Web:
+ section = new SectionWeb
+ {
+ WebSource = "",
+ };
+ break;
}
section.InstanceId = newSection.instanceId;
@@ -869,6 +891,36 @@ namespace ManagerService.Controllers
if (section == null)
throw new KeyNotFoundException("Section does not exist");
+ if (section.Type == SectionType.Agenda)
+ {
+ var sectionAgenda = _myInfoMateDbContext.Sections.OfType().Include(sa => sa.EventAgendas).FirstOrDefault(sa => sa.Id == id);
+
+ _myInfoMateDbContext.RemoveRange(sectionAgenda.EventAgendas);
+ }
+
+ if (section.Type == SectionType.Event)
+ {
+ var sectionEvent = _myInfoMateDbContext.Sections.OfType().Include(se => se.Programme).ThenInclude(se => se.MapAnnotations).FirstOrDefault(s => s.Id == id);
+
+ foreach (var programBlock in sectionEvent.Programme)
+ {
+ _myInfoMateDbContext.RemoveRange(programBlock.MapAnnotations);
+ _myInfoMateDbContext.Remove(programBlock);
+ }
+
+ var guidedPaths = _myInfoMateDbContext.GuidedPaths.Include(gp => gp.Steps).Where(gp => gp.SectionEventId == id);
+ foreach (var guidedPath in guidedPaths)
+ {
+ _myInfoMateDbContext.RemoveRange(guidedPath.Steps);
+ _myInfoMateDbContext.Remove(guidedPath);
+ }
+
+ var applicationInstances = _myInfoMateDbContext.ApplicationInstances.Where(ai => ai.SectionEventId == id);
+ foreach (var applicationInstance in applicationInstances)
+ {
+ applicationInstance.SectionEventId = null;
+ }
+ }
if (section.Type == SectionType.Map)
{
@@ -891,43 +943,10 @@ namespace ManagerService.Controllers
_myInfoMateDbContext.RemoveRange(quizQuestions);
}
- if (section.Type == SectionType.Event)
- {
- var sectionEvent = _myInfoMateDbContext.Sections.OfType().Include(se => se.Programme).ThenInclude(se => se.MapAnnotations).FirstOrDefault(s => s.Id == id);
-
- foreach (var programBlock in sectionEvent.Programme)
- {
- _myInfoMateDbContext.RemoveRange(programBlock.MapAnnotations);
- _myInfoMateDbContext.Remove(programBlock);
- }
-
- var guidedPaths = _myInfoMateDbContext.GuidedPaths.Include(gp => gp.Steps).Where(gp => gp.SectionEventId == id);
- foreach (var guidedPath in guidedPaths)
- {
- _myInfoMateDbContext.RemoveRange(guidedPath.Steps);
- _myInfoMateDbContext.Remove(guidedPath);
- }
-
- var applicationInstances = _myInfoMateDbContext.ApplicationInstances.Where(ai => ai.SectionEventId == id);
- foreach (var applicationInstance in applicationInstances)
- {
- applicationInstance.SectionEventId = null; // Is that enough ?
- }
- }
-
- if (section.Type == SectionType.Agenda)
- {
- var sectionAgenda = _myInfoMateDbContext.Sections.OfType().Include(sa => sa.EventAgendas).FirstOrDefault(sa => sa.Id == id);
-
- _myInfoMateDbContext.RemoveRange(sectionAgenda.EventAgendas);
- }
-
_myInfoMateDbContext.Remove(section);
- //_sectionService.Remove(id);
var configuration = _myInfoMateDbContext.Configurations.FirstOrDefault(c => c.Id == section.ConfigurationId);
- // TODO TEST that in new format
List sections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == section.ConfigurationId && !s.IsSubSection).ToList();
int i = 1;
List orderedSection = sections.OrderBy(s => s.Order).ToList();
diff --git a/ManagerService/Controllers/SectionEventController.cs b/ManagerService/Controllers/SectionEventController.cs
index 23f2596..cff90d0 100644
--- a/ManagerService/Controllers/SectionEventController.cs
+++ b/ManagerService/Controllers/SectionEventController.cs
@@ -1,14 +1,12 @@
-using Manager.DTOs;
-using ManagerService.Data;
+using ManagerService.Data;
using ManagerService.Data.SubSection;
-using ManagerService.Helpers;
+using ManagerService.DTOs;
using ManagerService.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
-using Namotion.Reflection;
using NSwag.Annotations;
using System;
using System.Collections.Generic;
@@ -81,33 +79,33 @@ namespace ManagerService.Controllers
/// Create new programme block
///
/// Section event Id
- /// Programme block
- [ProducesResponseType(typeof(ProgrammeBlock), 200)]
+ /// Programme block
+ [ProducesResponseType(typeof(ProgrammeBlockDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 409)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost("{sectionEventId}/programmes")]
- public ObjectResult CreateProgrammeBlock(string sectionEventId, [FromBody] ProgrammeBlock programmeBlock)
+ public ObjectResult CreateProgrammeBlock(string sectionEventId, [FromBody] ProgrammeBlockDTO programmeBlockDTO)
{
try
{
if (sectionEventId == null)
throw new ArgumentNullException("Section param is null");
- if (programmeBlock == null)
+ if (programmeBlockDTO == null)
throw new ArgumentNullException("ProgrammeBlock param is null");
var existingSection = _myInfoMateDbContext.Sections.OfType().Include(se => se.Programme).FirstOrDefault(se => se.Id == sectionEventId);
if (existingSection == null)
throw new KeyNotFoundException("Section event does not exist");
- // TODO verification ?
+ ProgrammeBlock programmeBlock = new ProgrammeBlock().FromDTO(programmeBlockDTO);
programmeBlock.Id = idService.GenerateHexId();
existingSection.Programme.Add(programmeBlock);
_myInfoMateDbContext.SaveChanges();
- return new OkObjectResult(programmeBlock);
+ return new OkObjectResult(programmeBlock.ToDTO());
}
catch (ArgumentNullException ex)
{
@@ -127,23 +125,27 @@ namespace ManagerService.Controllers
/// Update a program block
///
/// ProgramBlock to update
- [ProducesResponseType(typeof(ProgrammeBlock), 200)]
+ [ProducesResponseType(typeof(ProgrammeBlockDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut("programmes")]
- public ObjectResult UpdateProgrammeBlock([FromBody] ProgrammeBlock programmeBlock)
+ public ObjectResult UpdateProgrammeBlock([FromBody] ProgrammeBlockDTO programmeBlockDTO)
{
try
{
- if (programmeBlock == null)
+ if (programmeBlockDTO == null)
throw new ArgumentNullException("ProgrammeBlock param is null");
- var existingProgramBlock = _myInfoMateDbContext.ProgrammeBlocks.FirstOrDefault(pb => pb.Id == programmeBlock.Id);
+ var existingProgramBlock = _myInfoMateDbContext.ProgrammeBlocks.FirstOrDefault(pb => pb.Id == programmeBlockDTO.Id);
if (existingProgramBlock == null)
throw new KeyNotFoundException("ProgrammeBlock does not exist");
- existingProgramBlock = programmeBlock; // TO TEST ..
+ existingProgramBlock.Title = programmeBlockDTO.Title;
+ existingProgramBlock.Description = programmeBlockDTO.Description;
+ existingProgramBlock.StartTime = programmeBlockDTO.StartTime;
+ existingProgramBlock.EndTime = programmeBlockDTO.EndTime;
+
_myInfoMateDbContext.SaveChanges();
return new OkObjectResult(existingProgramBlock);
@@ -207,7 +209,7 @@ namespace ManagerService.Controllers
///
/// Program block id
[AllowAnonymous]
- [ProducesResponseType(typeof(List), 200)]
+ [ProducesResponseType(typeof(List), 200)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpGet("{programBlockId}/map-annotations")]
@@ -232,7 +234,7 @@ namespace ManagerService.Controllers
}
}*/
- return new OkObjectResult(programmeBlock.MapAnnotations);
+ return new OkObjectResult(programmeBlock.MapAnnotations.Select(ma => ma.ToDTO()));
}
catch (KeyNotFoundException ex)
{
@@ -249,19 +251,19 @@ namespace ManagerService.Controllers
///
/// Programme block id
/// Map annotation
- [ProducesResponseType(typeof(MapAnnotation), 200)]
+ [ProducesResponseType(typeof(MapAnnotationDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 409)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost("{programmeBlockId}/map-annotations")]
- public ObjectResult CreateMapAnnotation(string programmeBlockId, [FromBody] MapAnnotation mapAnnotation)
+ public ObjectResult CreateMapAnnotation(string programmeBlockId, [FromBody] MapAnnotationDTO mapAnnotationDTO)
{
try
{
if (programmeBlockId == null)
throw new ArgumentNullException("ProgrammeBlockId param is null");
- if (mapAnnotation == null)
+ if (mapAnnotationDTO == null)
throw new ArgumentNullException("MapAnnotation param is null");
var existingProgrammeBloc = _myInfoMateDbContext.ProgrammeBlocks.Include(pb => pb.MapAnnotations).FirstOrDefault(pb => pb.Id == programmeBlockId);
@@ -269,6 +271,7 @@ namespace ManagerService.Controllers
throw new KeyNotFoundException("ProgrammeBlock does not exist");
// TODO verification ?
+ MapAnnotation mapAnnotation = new MapAnnotation().FromDTO(mapAnnotationDTO);
mapAnnotation.Id = idService.GenerateHexId();
existingProgrammeBloc.MapAnnotations.Add(mapAnnotation);
@@ -294,23 +297,30 @@ namespace ManagerService.Controllers
/// Update a map annotation
///
/// mapAnnotation to update
- [ProducesResponseType(typeof(MapAnnotation), 200)]
+ [ProducesResponseType(typeof(MapAnnotationDTO), 200)]
[ProducesResponseType(typeof(string), 400)]
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut("map-annotations")]
- public ObjectResult UpdateMapAnnotation([FromBody] MapAnnotation mapAnnotation)
+ public ObjectResult UpdateMapAnnotation([FromBody] MapAnnotationDTO mapAnnotationDTO)
{
try
{
- if (mapAnnotation == null)
+ if (mapAnnotationDTO == null)
throw new ArgumentNullException("MapAnnotation param is null");
- var existingMapAnnotation = _myInfoMateDbContext.MapAnnotations.FirstOrDefault(ma => ma.Id == mapAnnotation.Id);
+ var existingMapAnnotation = _myInfoMateDbContext.MapAnnotations.Include(ma => ma.IconResource).FirstOrDefault(ma => ma.Id == mapAnnotationDTO.Id);
if (existingMapAnnotation == null)
throw new KeyNotFoundException("MapAnnotation does not exist");
- existingMapAnnotation = mapAnnotation; // TO TEST ..
+ existingMapAnnotation.Type = mapAnnotationDTO.Type;
+ existingMapAnnotation.Label = mapAnnotationDTO.Label;
+ existingMapAnnotation.GeometryType = mapAnnotationDTO.GeometryType;
+ existingMapAnnotation.Geometry = mapAnnotationDTO.Geometry;
+ existingMapAnnotation.PolyColor = mapAnnotationDTO.PolyColor;
+ existingMapAnnotation.Icon = mapAnnotationDTO.Icon;
+ existingMapAnnotation.IconResourceId = mapAnnotationDTO.IconResourceId;
+
_myInfoMateDbContext.SaveChanges();
return new OkObjectResult(existingMapAnnotation);
diff --git a/ManagerService/Controllers/SectionMapController.cs b/ManagerService/Controllers/SectionMapController.cs
index 98b18b5..012a04b 100644
--- a/ManagerService/Controllers/SectionMapController.cs
+++ b/ManagerService/Controllers/SectionMapController.cs
@@ -1,6 +1,7 @@
using Manager.DTOs;
using ManagerService.Data;
using ManagerService.Data.SubSection;
+using ManagerService.DTOs;
using ManagerService.Helpers;
using ManagerService.Services;
using Microsoft.AspNetCore.Authorization;
@@ -8,10 +9,12 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
+using NetTopologySuite.Geometries;
using NSwag.Annotations;
using System;
using System.Collections.Generic;
using System.Linq;
+using static ManagerService.Data.SubSection.SectionEvent;
namespace ManagerService.Controllers
{
@@ -323,5 +326,349 @@ namespace ManagerService.Controllers
return new ObjectResult(ex.Message) { StatusCode = 500 };
}
}
+
+ ///
+ /// Get all guided path from section
+ ///
+ /// Section id
+ [AllowAnonymous]
+ [ProducesResponseType(typeof(List), 200)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpGet("{sectionMapId}/guided-path")]
+ public ObjectResult GetAllGuidedPathFromSection(string sectionMapId)
+ {
+ try
+ {
+ List guidedPaths = _myInfoMateDbContext.GuidedPaths
+ .Include(gp => gp.Steps).ThenInclude(gp => gp.QuizQuestions)
+ .Include(gp => gp.Steps).ThenInclude(gp => gp.TriggerGeoPoint)
+ .Where(gp => gp.SectionMapId == sectionMapId).ToList();
+
+ /*List programmeBlocks = new List();
+ foreach (var program in sectionEvent.Programme)
+ {
+ foreach (var mapAnnotation in program.MapAnnotations) {
+ var resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == mapAnnotation.IconResourceId);
+ if (resource != null)
+ {
+ mapAnnotation.IconResource = resource; // TO check.. use DTO instead ?
+ }
+ }
+ }*/
+
+ return new OkObjectResult(guidedPaths.Select(gp => gp.ToDTO()));
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Create new guided path
+ ///
+ /// Section map Id
+ /// guidedPath
+ [ProducesResponseType(typeof(GuidedPathDTO), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 409)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPost("{sectionMapId}/guided-path")]
+ public ObjectResult CreateGuidedPath(string sectionMapId, [FromBody] GuidedPathDTO guidedPathDTO)
+ {
+ try
+ {
+ if (sectionMapId == null)
+ throw new ArgumentNullException("Section param is null");
+
+ if (guidedPathDTO == null)
+ throw new ArgumentNullException("GuidedPath param is null");
+
+ var existingSection = _myInfoMateDbContext.Sections.OfType().FirstOrDefault(sm => sm.Id == sectionMapId);
+ if (existingSection == null)
+ throw new KeyNotFoundException("Section map does not exist");
+
+ GuidedPath guidedPath = new GuidedPath().FromDTO(guidedPathDTO);
+ guidedPath.Id = idService.GenerateHexId();
+ _myInfoMateDbContext.GuidedPaths.Add(guidedPath);
+ _myInfoMateDbContext.SaveChanges();
+
+ return new OkObjectResult(guidedPath.ToDTO());
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (InvalidOperationException ex)
+ {
+ return new ConflictObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Update a guided path
+ ///
+ /// GuidedPath to update
+ [ProducesResponseType(typeof(GuidedPathDTO), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPut("guided-path")]
+ public ObjectResult UpdateGuidedPath([FromBody] GuidedPathDTO guidedPathDTO)
+ {
+ try
+ {
+ if (guidedPathDTO == null)
+ throw new ArgumentNullException("GuidedPath param is null");
+
+ var existingGuidedPath = _myInfoMateDbContext.GuidedPaths.FirstOrDefault(gp => gp.Id == guidedPathDTO.Id);
+ if (existingGuidedPath == null)
+ throw new KeyNotFoundException("GuidedPath does not exist");
+
+ existingGuidedPath.InstanceId = guidedPathDTO.InstanceId;
+ existingGuidedPath.Title = guidedPathDTO.Title ?? new List();
+ existingGuidedPath.Description = guidedPathDTO.Description ?? new List();
+ existingGuidedPath.SectionMapId = guidedPathDTO.SectionMapId;
+ existingGuidedPath.SectionEventId = guidedPathDTO.SectionEventId;
+ existingGuidedPath.IsLinear = guidedPathDTO.IsLinear;
+ existingGuidedPath.RequireSuccessToAdvance = guidedPathDTO.RequireSuccessToAdvance;
+ existingGuidedPath.HideNextStepsUntilComplete = guidedPathDTO.HideNextStepsUntilComplete;
+ existingGuidedPath.Order = guidedPathDTO.Order;
+
+ _myInfoMateDbContext.SaveChanges();
+
+ return new OkObjectResult(existingGuidedPath);
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Delete a guided path
+ ///
+ /// Id of the guidedPath to delete
+ [ProducesResponseType(typeof(string), 202)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpDelete("guided-path/{guidedPathId}")]
+ public ObjectResult DeleteGuidedPath(string guidedPathId)
+ {
+ try
+ {
+ var guidedPath = _myInfoMateDbContext.GuidedPaths.FirstOrDefault(gp => gp.Id == guidedPathId);
+ if (guidedPath == null)
+ throw new KeyNotFoundException("GuidedPath does not exist");
+
+ _myInfoMateDbContext.Remove(guidedPath);
+ _myInfoMateDbContext.SaveChanges();
+
+ return new ObjectResult("The guidedPath has been deleted") { StatusCode = 202 };
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Get all guided step from guided path
+ ///
+ /// Guided path id
+ [AllowAnonymous]
+ [ProducesResponseType(typeof(List), 200)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpGet("guided-path/{guidedPathId}/guided-step")]
+ public ObjectResult GetAllGuidedStepFromGuidedPath(string guidedPathId)
+ {
+ try
+ {
+ List guidedSteps = _myInfoMateDbContext.GuidedSteps
+ .Include(gs => gs.QuizQuestions)
+ .Include(gs => gs.TriggerGeoPoint)
+ .Where(gs => gs.GuidedPathId == guidedPathId).ToList();
+
+ /*List programmeBlocks = new List();
+ foreach (var program in sectionEvent.Programme)
+ {
+ foreach (var mapAnnotation in program.MapAnnotations) {
+ var resource = _myInfoMateDbContext.Resources.FirstOrDefault(r => r.Id == mapAnnotation.IconResourceId);
+ if (resource != null)
+ {
+ mapAnnotation.IconResource = resource; // TO check.. use DTO instead ?
+ }
+ }
+ }*/
+
+ return new OkObjectResult(guidedSteps.Select(gs => gs.ToDTO()));
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Create new guided step
+ ///
+ /// guidedPath Id
+ /// guidedStep
+ [ProducesResponseType(typeof(GuidedStepDTO), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 409)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPost("guided-path/{guidedPathId}/guided-step")]
+ public ObjectResult CreateGuidedStep(string guidedPathId, [FromBody] GuidedStepDTO guidedStepDTO)
+ {
+ try
+ {
+ if (guidedPathId == null)
+ throw new ArgumentNullException("GuidedPathId param is null");
+
+ if (guidedStepDTO == null)
+ throw new ArgumentNullException("GuidedStep param is null");
+
+ GuidedStep guidedStep = new GuidedStep().FromDTO(guidedStepDTO);
+ guidedStep.Id = idService.GenerateHexId();
+
+ _myInfoMateDbContext.GuidedSteps.Add(guidedStep);
+ _myInfoMateDbContext.SaveChanges();
+
+ return new OkObjectResult(guidedStep.ToDTO());
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (InvalidOperationException ex)
+ {
+ return new ConflictObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Update a guided step
+ ///
+ /// GuidedStep to update
+ [ProducesResponseType(typeof(GuidedStepDTO), 200)]
+ [ProducesResponseType(typeof(string), 400)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpPut("guided-step")]
+ public ObjectResult UpdateGuidedStep([FromBody] GuidedStepDTO guidedStepDTO)
+ {
+ try
+ {
+ if (guidedStepDTO == null)
+ throw new ArgumentNullException("GuidedStep param is null");
+
+ var existingGuidedStep = _myInfoMateDbContext.GuidedSteps.FirstOrDefault(gs => gs.Id == guidedStepDTO.Id);
+ if (existingGuidedStep == null)
+ throw new KeyNotFoundException("GuidedStep does not exist");
+
+ existingGuidedStep.GuidedPathId = guidedStepDTO.GuidedPathId;
+ existingGuidedStep.Order = guidedStepDTO.Order;
+ existingGuidedStep.Title = guidedStepDTO.Title;
+ existingGuidedStep.Description = guidedStepDTO.Description;
+ existingGuidedStep.Geometry = guidedStepDTO.Geometry != null ? guidedStepDTO.Geometry : null; // TO TEST
+ existingGuidedStep.ZoneRadiusMeters = guidedStepDTO.ZoneRadiusMeters;
+ existingGuidedStep.ImageUrl = guidedStepDTO.ImageUrl;
+ existingGuidedStep.TriggerGeoPointId = guidedStepDTO.TriggerGeoPointId;
+ existingGuidedStep.IsHiddenInitially = guidedStepDTO.IsHiddenInitially;
+ existingGuidedStep.QuizQuestions = guidedStepDTO.QuizQuestions; // à convertir si besoin ?
+ existingGuidedStep.IsStepTimer = guidedStepDTO.IsStepTimer;
+ existingGuidedStep.IsStepLocked = guidedStepDTO.IsStepLocked;
+ existingGuidedStep.TimerSeconds = guidedStepDTO.TimerSeconds;
+ existingGuidedStep.TimerExpiredMessage = guidedStepDTO.TimerExpiredMessage;
+
+ _myInfoMateDbContext.SaveChanges();
+
+ return new OkObjectResult(existingGuidedStep);
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
+
+ ///
+ /// Delete a guided step
+ ///
+ /// Id of the guidedStep to delete
+ [ProducesResponseType(typeof(string), 202)]
+ [ProducesResponseType(typeof(string), 404)]
+ [ProducesResponseType(typeof(string), 500)]
+ [HttpDelete("guided-step/{guidedStepId}")]
+ public ObjectResult DeleteGuidedStep(string guidedStepId)
+ {
+ try
+ {
+ var guidedStep = _myInfoMateDbContext.GuidedSteps.Include(gs => gs.QuizQuestions).FirstOrDefault(gs => gs.Id == guidedStepId);
+ if (guidedStep == null)
+ throw new KeyNotFoundException("GuidedStep does not exist");
+
+ guidedStep.QuizQuestions.Clear();
+
+ _myInfoMateDbContext.Remove(guidedStep);
+ _myInfoMateDbContext.SaveChanges();
+
+ return new ObjectResult("The guidedStep has been deleted") { StatusCode = 202 };
+ }
+ catch (ArgumentNullException ex)
+ {
+ return new BadRequestObjectResult(ex.Message) { };
+ }
+ catch (KeyNotFoundException ex)
+ {
+ return new NotFoundObjectResult(ex.Message) { };
+ }
+ catch (Exception ex)
+ {
+ return new ObjectResult(ex.Message) { StatusCode = 500 };
+ }
+ }
}
}
diff --git a/ManagerService/DTOs/EventAgendaDTO.cs b/ManagerService/DTOs/EventAgendaDTO.cs
index 226be6e..31196dc 100644
--- a/ManagerService/DTOs/EventAgendaDTO.cs
+++ b/ManagerService/DTOs/EventAgendaDTO.cs
@@ -1,7 +1,5 @@
-using ManagerService.Data.SubSection;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System;
-using static ManagerService.Data.SubSection.SectionEvent;
using Manager.DTOs;
namespace ManagerService.DTOs
@@ -10,9 +8,9 @@ namespace ManagerService.DTOs
{
public int Id { get; set; }
- public List Label { get; set; }
+ public List Label { get; set; }
- public List Description { get; set; }
+ public List Description { get; set; }
public string Type { get; set; }
@@ -35,6 +33,7 @@ namespace ManagerService.DTOs
public string Email { get; set; }
public string SectionAgendaId { get; set; }
+ public string SectionEventId { get; set; }
}
diff --git a/ManagerService/DTOs/GuidedPathDTO.cs b/ManagerService/DTOs/GuidedPathDTO.cs
new file mode 100644
index 0000000..6631244
--- /dev/null
+++ b/ManagerService/DTOs/GuidedPathDTO.cs
@@ -0,0 +1,19 @@
+using System.Collections.Generic;
+
+namespace ManagerService.DTOs
+{
+ public class GuidedPathDTO
+ {
+ public string Id { get; set; }
+ public string InstanceId { get; set; }
+ public List Title { get; set; }
+ public List Description { get; set; }
+ public string? SectionMapId { get; set; }
+ public string? SectionEventId { get; set; }
+ public bool IsLinear { get; set; }
+ public bool RequireSuccessToAdvance { get; set; }
+ public bool HideNextStepsUntilComplete { get; set; }
+ public int Order { get; set; }
+ public List Steps { get; set; }
+ }
+}
diff --git a/ManagerService/DTOs/GuidedStepDTO.cs b/ManagerService/DTOs/GuidedStepDTO.cs
new file mode 100644
index 0000000..c0c80b3
--- /dev/null
+++ b/ManagerService/DTOs/GuidedStepDTO.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Manager.DTOs;
+using ManagerService.Data.SubSection;
+using NetTopologySuite.Geometries;
+
+namespace ManagerService.DTOs
+{
+ public class GuidedStepDTO
+ {
+ public string Id { get; set; }
+ public string GuidedPathId { get; set; }
+ public int Order { get; set; }
+ public List Title { get; set; }
+ public List Description { get; set; }
+ public Geometry Geometry { get; set; }
+ public double? ZoneRadiusMeters { get; set; }
+ public string ImageUrl { get; set; }
+ public int? TriggerGeoPointId { get; set; }
+ public GeoPointDTO? TriggerGeoPoint { get; set; }
+ public bool IsHiddenInitially { get; set; }
+ public bool IsStepTimer { get; set; }
+ public bool IsStepLocked { get; set; }
+ public int? TimerSeconds { get; set; }
+ public List TimerExpiredMessage { get; set; }
+ public List QuizQuestions { get; set; }
+ }
+}
diff --git a/ManagerService/DTOs/MapAnnotationDTO.cs b/ManagerService/DTOs/MapAnnotationDTO.cs
new file mode 100644
index 0000000..ce9e0cd
--- /dev/null
+++ b/ManagerService/DTOs/MapAnnotationDTO.cs
@@ -0,0 +1,19 @@
+using NetTopologySuite.Geometries;
+using System.Collections.Generic;
+using ManagerService.Data.SubSection;
+
+namespace ManagerService.DTOs
+{
+ public class MapAnnotationDTO
+ {
+ public string Id { get; set; }
+ public List Type { get; set; }
+ public List Label { get; set; }
+ public SectionEvent.GeometryType GeometryType { get; set; }
+ public Geometry Geometry { get; set; }
+ public string PolyColor { get; set; }
+ public string Icon { get; set; }
+ public string IconResourceId { get; set; }
+ public ResourceDTO IconResource { get; set; }
+ }
+}
diff --git a/ManagerService/DTOs/ProgrammeBlockDTO.cs b/ManagerService/DTOs/ProgrammeBlockDTO.cs
new file mode 100644
index 0000000..97e23c9
--- /dev/null
+++ b/ManagerService/DTOs/ProgrammeBlockDTO.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+
+namespace ManagerService.DTOs
+{
+ public class ProgrammeBlockDTO
+ {
+ public string Id { get; set; }
+ public List Title { get; set; }
+ public List Description { get; set; }
+ public DateTime StartTime { get; set; }
+ public DateTime EndTime { get; set; }
+ public List MapAnnotations { get; set; }
+ }
+}
diff --git a/ManagerService/DTOs/SubSection/AgendaDTO.cs b/ManagerService/DTOs/SubSection/AgendaDTO.cs
index 1bd1f3c..10ba5cb 100644
--- a/ManagerService/DTOs/SubSection/AgendaDTO.cs
+++ b/ManagerService/DTOs/SubSection/AgendaDTO.cs
@@ -7,5 +7,6 @@ namespace Manager.DTOs
{
public List resourceIds { get; set; } // All json files for all languages
public MapProvider? agendaMapProvider { get; set; } // Default = Google
+ public List events { get; set; }
}
}
diff --git a/ManagerService/DTOs/SubSection/MapDTO.cs b/ManagerService/DTOs/SubSection/MapDTO.cs
index 0a15d19..bcb4c30 100644
--- a/ManagerService/DTOs/SubSection/MapDTO.cs
+++ b/ManagerService/DTOs/SubSection/MapDTO.cs
@@ -33,6 +33,8 @@ namespace Manager.DTOs
public List site { get; set; }
public GeometryDTO geometry { get; set; }
public string polyColor { get; set; } // color of the polyline or polygon
+ public string sectionMapId { get; set; }
+ public string sectionEventId { get; set; }
}
public class CategorieDTO
diff --git a/ManagerService/Data/SubSection/EventAgenda.cs b/ManagerService/Data/SubSection/EventAgenda.cs
index 02aff80..b8eddf3 100644
--- a/ManagerService/Data/SubSection/EventAgenda.cs
+++ b/ManagerService/Data/SubSection/EventAgenda.cs
@@ -1,12 +1,11 @@
using Manager.DTOs;
using ManagerService.DTOs;
+using ManagerService.Helpers;
using NetTopologySuite.Geometries;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-using System.Drawing.Drawing2D;
-using static ManagerService.Data.SubSection.SectionEvent;
namespace ManagerService.Data.SubSection
{
@@ -58,8 +57,77 @@ namespace ManagerService.Data.SubSection
[ForeignKey("SectionEventId")]
public SectionEvent? SectionEvent { get; set; } // Genre lancer l'event (vue vraiment detail d'un event)
- }
+ public EventAgendaDTO ToDTO()
+ {
+ return new EventAgendaDTO()
+ {
+ Id = Id,
+ Label = Label,
+ Description = Description,
+ Type = Type,
+ DateAdded = DateAdded,
+ DateFrom = DateFrom,
+ DateTo = DateTo,
+ Website = Website,
+ ResourceId = ResourceId,
+ Resource = Resource?.ToDTO(),
+ Address = Address != null ? new EventAddressDTO
+ {
+ Address = Address.Address,
+ StreetNumber = Address.StreetNumber,
+ StreetName = Address.StreetName,
+ City = Address.City,
+ State = Address.State,
+ PostCode = Address.PostCode,
+ Country = Address.Country,
+ Geometry = Address.Geometry != null ? new GeometryDTO
+ {
+ Type = Address.Geometry.GeometryType,
+ Coordinates = Address.Geometry.Coordinates,
+ } : null,
+ PolyColor = Address.PolyColor,
+ Zoom = Address.Zoom
+ } : null,
+ Phone = Phone,
+ Email = Email,
+ SectionAgendaId = SectionAgendaId
+ };
+ }
+ public EventAgenda FromDTO(EventAgendaDTO dto)
+ {
+ return new EventAgenda
+ {
+ Id = dto.Id,
+ Label = dto.Label,
+ Description = dto.Description,
+ Type = dto.Type,
+ DateAdded = dto.DateAdded,
+ DateFrom = dto.DateFrom,
+ DateTo = dto.DateTo,
+ Website = dto.Website,
+ ResourceId = dto.ResourceId,
+ //Resource = dto.Resource != null ? Resource.From(dto.Resource) : null,
+ Address = dto.Address != null ? new EventAddress
+ {
+ Address = dto.Address.Address,
+ StreetNumber = dto.Address.StreetNumber,
+ StreetName = dto.Address.StreetName,
+ City = dto.Address.City,
+ State = dto.Address.State,
+ PostCode = dto.Address.PostCode,
+ Country = dto.Address.Country,
+ Geometry = dto.Address.Geometry!= null ? dto.Address.Geometry.FromDto() : null,
+ PolyColor = dto.Address.PolyColor,
+ Zoom = dto.Address.Zoom
+ } : null,
+ Phone = dto.Phone,
+ Email = dto.Email,
+ SectionAgendaId = dto.SectionAgendaId
+ };
+ }
+
+ }
public class EventAddress
{
public string Address { get; set; }
diff --git a/ManagerService/Data/SubSection/SectionAgenda.cs b/ManagerService/Data/SubSection/SectionAgenda.cs
index fbeab6d..2826492 100644
--- a/ManagerService/Data/SubSection/SectionAgenda.cs
+++ b/ManagerService/Data/SubSection/SectionAgenda.cs
@@ -48,7 +48,8 @@ namespace ManagerService.Data.SubSection
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
resourceIds = AgendaResourceIds,
- agendaMapProvider = AgendaMapProvider
+ agendaMapProvider = AgendaMapProvider,
+ events = EventAgendas.Select(e => e.ToDTO()).ToList(),
};
}
}
diff --git a/ManagerService/Data/SubSection/SectionEvent.cs b/ManagerService/Data/SubSection/SectionEvent.cs
index 5cae162..258c3a3 100644
--- a/ManagerService/Data/SubSection/SectionEvent.cs
+++ b/ManagerService/Data/SubSection/SectionEvent.cs
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
namespace ManagerService.Data.SubSection
@@ -30,6 +31,33 @@ namespace ManagerService.Data.SubSection
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public List MapAnnotations { get; set; }
+
+ public ProgrammeBlockDTO ToDTO()
+ {
+ return new ProgrammeBlockDTO
+ {
+ Id = this.Id,
+ Title = this.Title,
+ Description = this.Description,
+ StartTime = this.StartTime,
+ EndTime = this.EndTime,
+ MapAnnotations = this.MapAnnotations?.Select(ma => ma.ToDTO()).ToList()
+ };
+ }
+
+ public ProgrammeBlock FromDTO(ProgrammeBlockDTO dto)
+ {
+ return new ProgrammeBlock
+ {
+ Id = dto.Id,
+ Title = dto.Title,
+ Description = dto.Description,
+ StartTime = dto.StartTime,
+ EndTime = dto.EndTime,
+ //MapAnnotations = dto.MapAnnotations?.Select(ma => new MapAnnotation.FromDTO(ma)).ToList() // Other method
+ };
+ }
+
}
public class MapAnnotation
@@ -46,6 +74,39 @@ namespace ManagerService.Data.SubSection
public string Icon { get; set; } // icon material if point
public string IconResourceId { get; set; } // Icon resource id
public Resource IconResource { get; set; } // Icon resource
+
+ public MapAnnotationDTO ToDTO()
+ {
+ return new MapAnnotationDTO
+ {
+ Id = Id,
+ Type = Type,
+ Label = Label,
+ GeometryType = GeometryType,
+ Geometry = Geometry,
+ PolyColor = PolyColor,
+ Icon = Icon,
+ IconResourceId = IconResourceId,
+ IconResource = IconResource?.ToDTO()
+ };
+ }
+
+ public MapAnnotation FromDTO(MapAnnotationDTO dto)
+ {
+ return new MapAnnotation
+ {
+ Id = dto.Id,
+ Type = dto.Type,
+ Label = dto.Label,
+ GeometryType = dto.GeometryType,
+ Geometry = dto.Geometry,
+ PolyColor = dto.PolyColor,
+ Icon = dto.Icon,
+ IconResourceId = dto.IconResourceId,
+ //IconResource = dto.IconResource?.ToModel()
+ };
+ }
+
}
public enum GeometryType
diff --git a/ManagerService/Data/SubSection/SectionMap.cs b/ManagerService/Data/SubSection/SectionMap.cs
index cc3896e..862cfc9 100644
--- a/ManagerService/Data/SubSection/SectionMap.cs
+++ b/ManagerService/Data/SubSection/SectionMap.cs
@@ -1,10 +1,12 @@
using Manager.DTOs;
using ManagerService.DTOs;
+using ManagerService.Helpers;
using NetTopologySuite.Geometries;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
+using System.Net;
namespace ManagerService.Data.SubSection
{
@@ -117,6 +119,34 @@ namespace ManagerService.Data.SubSection
[ForeignKey(nameof(SectionEventId))]
public SectionEvent? SectionEvent { get; set; }
+
+ public GeoPointDTO ToDTO()
+ {
+ return new GeoPointDTO
+ {
+ id = Id,
+ title = Title,
+ description = Description,
+ contents = Contents,
+ categorieId = CategorieId,
+ geometry = Geometry != null ? new GeometryDTO
+ {
+ Type = Geometry.GeometryType,
+ Coordinates = Geometry.Coordinates,
+ } : null,
+ polyColor = PolyColor,
+ imageResourceId = ImageResourceId,
+ imageUrl = ImageUrl,
+ schedules = Schedules,
+ prices = Prices,
+ phone = Phone,
+ email = Email,
+ site = Site,
+ sectionMapId = SectionMapId,
+ sectionEventId = SectionEventId
+ };
+ }
+
}
public class GuidedPath // Parcours
@@ -152,6 +182,45 @@ namespace ManagerService.Data.SubSection
public int Order { get; set; }
public List Steps { get; set; } = new();
+
+ public GuidedPathDTO ToDTO()
+ {
+ return new GuidedPathDTO
+ {
+ Id = Id,
+ InstanceId = InstanceId,
+ Title = Title,
+ Description = Description,
+ SectionMapId = SectionMapId,
+ SectionEventId = SectionEventId,
+ IsLinear = IsLinear,
+ RequireSuccessToAdvance = RequireSuccessToAdvance,
+ HideNextStepsUntilComplete = HideNextStepsUntilComplete,
+ Order = Order,
+ Steps = Steps?.Select(s => s.ToDTO()).ToList()
+ };
+ }
+
+ public GuidedPath FromDTO(GuidedPathDTO dto)
+ {
+ if (dto == null) return null;
+
+ return new GuidedPath
+ {
+ Id = dto.Id,
+ InstanceId = dto.InstanceId,
+ Title = dto.Title ?? new List(),
+ Description = dto.Description ?? new List(),
+ SectionMapId = dto.SectionMapId,
+ SectionEventId = dto.SectionEventId,
+ IsLinear = dto.IsLinear,
+ RequireSuccessToAdvance = dto.RequireSuccessToAdvance,
+ HideNextStepsUntilComplete = dto.HideNextStepsUntilComplete,
+ Order = dto.Order,
+ //Steps = dto.Steps?.Select(s => s.FromDTO()).ToList() ?? new List() // Other method
+ };
+ }
+
}
public class GuidedStep // Étape d’un parcours
@@ -202,9 +271,57 @@ namespace ManagerService.Data.SubSection
// Option : message ou action à effectuer si timer expire (ex: afficher aide, fin du jeu...)
[Column(TypeName = "jsonb")]
public List TimerExpiredMessage { get; set; }
+
+ public GuidedStepDTO ToDTO()
+ {
+ return new GuidedStepDTO
+ {
+ Id = Id,
+ GuidedPathId = GuidedPathId,
+ Order = Order,
+ Title = Title,
+ Description = Description,
+ Geometry = Geometry,
+ ZoneRadiusMeters = ZoneRadiusMeters,
+ ImageUrl = ImageUrl,
+ TriggerGeoPointId = TriggerGeoPointId,
+ TriggerGeoPoint = TriggerGeoPoint.ToDTO(),
+ IsHiddenInitially = IsHiddenInitially,
+ IsStepTimer = IsStepTimer,
+ IsStepLocked = IsStepLocked,
+ TimerSeconds = TimerSeconds,
+ TimerExpiredMessage = TimerExpiredMessage,
+ QuizQuestions = QuizQuestions
+ };
+ }
+
+ public GuidedStep FromDTO(GuidedStepDTO dto)
+ {
+ if (dto == null) return null;
+
+ return new GuidedStep
+ {
+ Id = dto.Id,
+ GuidedPathId = dto.GuidedPathId,
+ Title = dto.Title ?? new List(),
+ Description = dto.Description ?? new List(),
+ Geometry = dto.Geometry,
+ ZoneRadiusMeters = dto.ZoneRadiusMeters,
+ ImageUrl = dto.ImageUrl,
+ TriggerGeoPointId = dto.TriggerGeoPointId,
+ IsHiddenInitially = dto.IsHiddenInitially,
+ IsStepTimer = dto.IsStepTimer,
+ IsStepLocked = dto.IsStepLocked,
+ TimerSeconds = dto.TimerSeconds,
+ TimerExpiredMessage = dto.TimerExpiredMessage ?? new List(),
+ Order = dto.Order,
+ QuizQuestions = dto.QuizQuestions
+ };
+ }
+
}
-
+
// SectionMap "normal" comme avant => Via geopoints. Si il y a des guidedPath lié à la sectionMap alors il y a un parcours lié à la sectionMap, tu peux aussi avoir des geopoints classique mis là + des parcours. et aussi lier un guidedstep à un geopoint (pour le trigger et aussi pour "afficher plus")
diff --git a/ManagerService/Services/SectionFactory.cs b/ManagerService/Services/SectionFactory.cs
index 05cac34..2f14057 100644
--- a/ManagerService/Services/SectionFactory.cs
+++ b/ManagerService/Services/SectionFactory.cs
@@ -2,10 +2,8 @@
using ManagerService.Data;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
-using MongoDB.Bson;
using Newtonsoft.Json;
using System;
-using System.Linq;
using System.Text.Json;
namespace ManagerService.Services
@@ -16,6 +14,7 @@ namespace ManagerService.Services
{
AgendaDTO agendaDTO = new AgendaDTO();
ArticleDTO articleDTO = new ArticleDTO();
+ SectionEventDTO sectionEventDTO = new SectionEventDTO();
MapDTO mapDTO = new MapDTO();
MenuDTO menuDTO = new MenuDTO();
PdfDTO pdfDTO = new PdfDTO();
@@ -34,6 +33,9 @@ namespace ManagerService.Services
case SectionType.Article:
articleDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
break;
+ case SectionType.Event:
+ sectionEventDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
+ break;
case SectionType.Map:
mapDTO = JsonConvert.DeserializeObject(jsonElement.ToString());
break;
@@ -86,7 +88,8 @@ namespace ManagerService.Services
MeterZoneGPS = dto.meterZoneGPS,
Type = dto.type,
AgendaResourceIds = agendaDTO.resourceIds,
- AgendaMapProvider = agendaDTO.agendaMapProvider
+ AgendaMapProvider = agendaDTO.agendaMapProvider,
+ //EventAgendas = // TODO specific
},
SectionType.Article => new SectionArticle
{
@@ -114,6 +117,31 @@ namespace ManagerService.Services
ArticleIsReadAudioAuto = articleDTO.isReadAudioAuto,
ArticleContents = articleDTO.contents
},
+ SectionType.Event => new SectionEvent
+ {
+ Id = dto.id,
+ DateCreation = dto.dateCreation.Value,
+ ConfigurationId = dto.configurationId,
+ InstanceId = dto.instanceId,
+ Label = dto.label,
+ Title = dto.title,
+ Description = dto.description,
+ Order = dto.order.Value,
+ ImageId = dto.imageId,
+ ImageSource = dto.imageSource,
+ IsSubSection = dto.isSubSection,
+ ParentId = dto.parentId,
+ IsBeacon = dto.isBeacon,
+ BeaconId = dto.beaconId,
+ Latitude = dto.latitude,
+ Longitude = dto.longitude,
+ MeterZoneGPS = dto.meterZoneGPS,
+ Type = dto.type,
+ StartDate = sectionEventDTO.StartDate,
+ EndDate = sectionEventDTO.EndDate,
+ ParcoursIds = sectionEventDTO.ParcoursIds,
+ //Programmes = // TODO specific
+ },
SectionType.Map => new SectionMap
{
Id = dto.id,
@@ -360,7 +388,8 @@ namespace ManagerService.Services
meterZoneGPS = agenda.MeterZoneGPS,
type = agenda.Type,
resourceIds = agenda.AgendaResourceIds,
- agendaMapProvider = agenda.AgendaMapProvider
+ agendaMapProvider = agenda.AgendaMapProvider,
+ // events => TODO specific
},
SectionArticle article => new ArticleDTO
{
@@ -388,6 +417,31 @@ namespace ManagerService.Services
isReadAudioAuto = article.ArticleIsReadAudioAuto,
contents = article.ArticleContents
},
+ SectionEvent sectionEvent => new SectionEventDTO
+ {
+ id = sectionEvent.Id,
+ dateCreation = sectionEvent.DateCreation,
+ configurationId = sectionEvent.ConfigurationId,
+ instanceId = sectionEvent.InstanceId,
+ label = sectionEvent.Label,
+ title = sectionEvent.Title,
+ description = sectionEvent.Description,
+ order = sectionEvent.Order,
+ imageId = sectionEvent.ImageId,
+ imageSource = sectionEvent.ImageSource,
+ isSubSection = sectionEvent.IsSubSection,
+ parentId = sectionEvent.ParentId,
+ isBeacon = sectionEvent.IsBeacon,
+ beaconId = sectionEvent.BeaconId,
+ latitude = sectionEvent.Latitude,
+ longitude = sectionEvent.Longitude,
+ meterZoneGPS = sectionEvent.MeterZoneGPS,
+ type = sectionEvent.Type,
+ StartDate = sectionEvent.StartDate,
+ EndDate = sectionEvent.EndDate,
+ ParcoursIds = sectionEvent.ParcoursIds,
+ // Programme TODO specific
+ },
SectionMap map => new MapDTO
{
id = map.Id,