diff --git a/Manager.Interfaces/DTO/SubSection/MapDTO.cs b/Manager.Interfaces/DTO/SubSection/MapDTO.cs index 25a1af6..0490e6b 100644 --- a/Manager.Interfaces/DTO/SubSection/MapDTO.cs +++ b/Manager.Interfaces/DTO/SubSection/MapDTO.cs @@ -5,7 +5,7 @@ using System.Text; namespace Manager.Interfaces.DTO { - public class MapDTO : SectionDTO + public class MapDTO { public int Zoom { get; set; } // Default = 18 public MapType MapType { get; set; } // Default = Hybrid @@ -16,9 +16,10 @@ namespace Manager.Interfaces.DTO public class GeoPointDTO { public int Id { get; set; } - public string Title { get; set; } // Dictionary with all languages - public string Description { get; set; } // Dictionary with all languages + public Dictionary Title { get; set; } // Dictionary with all languages + public Dictionary Description { get; set; } // Dictionary with all languages public string Image { get; set; } // url to ressource id (local) or on internet + public string ImageType { get; set; } // url or ressource public string Text { get; set; } // Dictionary with all languages public string Latitude { get; set; } public string Longitude { get; set; } diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index f7be695..ed766d0 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -112,7 +112,7 @@ namespace ManagerService.Controllers /// /// section id [AllowAnonymous] - [ProducesResponseType(typeof(object), 200)] + [ProducesResponseType(typeof(SectionDTO), 200)] [ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 500)] [HttpGet("{id}")] @@ -125,7 +125,8 @@ namespace ManagerService.Controllers if (section == null) throw new KeyNotFoundException("This section was not found"); - switch (section.Type) { + return new OkObjectResult(section); // TO TEST + /*switch (section.Type) { case SectionType.Map: MapDTO mapDTO = JsonConvert.DeserializeObject(section.Data); mapDTO.Id = section.Id; @@ -156,7 +157,7 @@ namespace ManagerService.Controllers return new OkObjectResult(section.ToDTO()); default: return new OkObjectResult(section.ToDTO()); - } + }*/ } catch (KeyNotFoundException ex) { @@ -200,7 +201,66 @@ namespace ManagerService.Controllers section.ParentId = null; section.Type = newSection.Type; - section.Data = newSection.Data; // Include all info from specific section as JSON + + switch (newSection.Type) { + case SectionType.Map: + MapDTO mapDTO = new MapDTO(); + mapDTO.Icon = ""; + mapDTO.MapType = MapType.hybrid; + mapDTO.Zoom = 18; + List languages = _configurationService.GetById(newSection.ConfigurationId).Languages; + Dictionary titles = new Dictionary(); + Dictionary descriptions = new Dictionary(); + + foreach (var language in languages) { + switch (language.ToUpper()) { + case "FR": + titles.Add(language, "Titre en français"); + descriptions.Add(language, "Description en français"); + break; + case "EN": + titles.Add(language, "Title in english"); + descriptions.Add(language, "Description en anglais"); + break; + case "NL": + titles.Add(language, "Titre in dutch"); + descriptions.Add(language, "Description en néerlandais"); + break; + case "DE": + titles.Add(language, "Titre en allemand"); + descriptions.Add(language, "Description en allemand"); + break; + } + } + + mapDTO.Points = new List() { + new GeoPointDTO() { + Id = 0, + Title = titles, + Description = descriptions, + Image = "", // TODO sample + ImageType = "url", // TODO + Latitude = "50.416639", + Longitude= "4.879169", + Text= "Musée de la fraise texte" + } + }; + + section.Data = JsonConvert.SerializeObject(mapDTO); ; // Include all info from specific section as JSON + break; + case SectionType.Slider: + section.Data = newSection.Data; // Include all info from specific section as JSON + break; + case SectionType.Video: + section.Data = newSection.Data; // Include all info from specific section as JSON + break; + case SectionType.Web: + section.Data = newSection.Data; // Include all info from specific section as JSON + break; + case SectionType.Menu: + section.Data = newSection.Data; // Include all info from specific section as JSON + break; + } /*section.MapType = newSectionMap.MapType; section.Zoom = newSectionMap.Zoom;