Create => create sample for each type (MAP in commit WIP)

This commit is contained in:
Thomas Fransolet 2021-05-01 01:46:17 +02:00
parent 9d0503f96b
commit d162b2f15d
2 changed files with 68 additions and 7 deletions

View File

@ -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<string, object> with all languages
public string Description { get; set; } // Dictionary<string, object> with all languages
public Dictionary<String, object> Title { get; set; } // Dictionary<string, object> with all languages
public Dictionary<String, object> Description { get; set; } // Dictionary<string, object> 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<string, object> with all languages
public string Latitude { get; set; }
public string Longitude { get; set; }

View File

@ -112,7 +112,7 @@ namespace ManagerService.Controllers
/// </summary>
/// <param name="id">section id</param>
[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<MapDTO>(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<string> languages = _configurationService.GetById(newSection.ConfigurationId).Languages;
Dictionary<string, object> titles = new Dictionary<string, object>();
Dictionary<string, object> descriptions = new Dictionary<string, object>();
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<GeoPointDTO>() {
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;