Add TranslationDTO for titles and descriptions
This commit is contained in:
parent
7a640f9d54
commit
f9b3344a77
@ -9,8 +9,8 @@ namespace Manager.Interfaces.DTO
|
|||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Label { get; set; } // use in manager
|
public string Label { get; set; } // use in manager
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Title { get; set; }
|
||||||
public string Description { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Description { get; set; }
|
||||||
public string ImageId { get; set; } // == RessourceId
|
public string ImageId { get; set; } // == RessourceId
|
||||||
public string ConfigurationId { get; set; }
|
public string ConfigurationId { get; set; }
|
||||||
public bool IsSubSection { get; set; } // true if part of menu type
|
public bool IsSubSection { get; set; } // true if part of menu type
|
||||||
|
|||||||
@ -16,11 +16,11 @@ namespace Manager.Interfaces.DTO
|
|||||||
public class GeoPointDTO
|
public class GeoPointDTO
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Title { get; set; }
|
||||||
public string Description { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Description { get; set; }
|
||||||
public string Image { get; set; } // url to ressource id (local) or on internet
|
public string Image { get; set; } // url to ressource id (local) or on internet
|
||||||
public string ImageType { get; set; } // url or ressource
|
public string ImageType { get; set; } // url or ressource
|
||||||
public string Text { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Text { get; set; }
|
||||||
public string Latitude { get; set; }
|
public string Latitude { get; set; }
|
||||||
public string Longitude { get; set; }
|
public string Longitude { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,8 +10,8 @@ namespace Manager.Interfaces.DTO
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ImageDTO {
|
public class ImageDTO {
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Title { get; set; }
|
||||||
public string Description { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Description { get; set; }
|
||||||
public string Source { get; set; } // url to ressource id (local) or on internet
|
public string Source { get; set; } // url to ressource id (local) or on internet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
Manager.Interfaces/DTO/TranslationDTO.cs
Normal file
12
Manager.Interfaces/DTO/TranslationDTO.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Manager.Interfaces.DTO
|
||||||
|
{
|
||||||
|
public class TranslationDTO
|
||||||
|
{
|
||||||
|
public string Language { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
using MongoDB.Bson.Serialization.Attributes;
|
using MongoDB.Bson.Serialization.Attributes;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
@ -22,10 +23,10 @@ namespace Manager.Interfaces.Models
|
|||||||
|
|
||||||
[BsonElement("Title")]
|
[BsonElement("Title")]
|
||||||
[BsonRequired]
|
[BsonRequired]
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Title { get; set; }
|
||||||
|
|
||||||
[BsonElement("Description")]
|
[BsonElement("Description")]
|
||||||
public string Description { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Description { get; set; }
|
||||||
|
|
||||||
[BsonElement("ConfigurationId")]
|
[BsonElement("ConfigurationId")]
|
||||||
[BsonRequired]
|
[BsonRequired]
|
||||||
@ -59,8 +60,8 @@ namespace Manager.Interfaces.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
Label = Label,
|
Label = Label,
|
||||||
Title = Title,
|
Title = Title.OrderBy(t => t.Language).ToList(),
|
||||||
Description = Description,
|
Description = Description.OrderBy(d => d.Language).ToList(),
|
||||||
Type = Type,
|
Type = Type,
|
||||||
ImageId = ImageId,
|
ImageId = ImageId,
|
||||||
ConfigurationId = ConfigurationId,
|
ConfigurationId = ConfigurationId,
|
||||||
|
|||||||
@ -45,10 +45,10 @@ namespace Manager.Interfaces.Models
|
|||||||
public class GeoPoint
|
public class GeoPoint
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Title { get; set; }
|
||||||
public string Description { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Description { get; set; }
|
||||||
public string Image { get; set; } // url to ressource id (local) or on internet
|
public string Image { get; set; } // url to ressource id (local) or on internet
|
||||||
public string Text { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Text { get; set; }
|
||||||
public string Latitude { get; set; }
|
public string Latitude { get; set; }
|
||||||
public string Longitude { get; set; }
|
public string Longitude { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -31,8 +31,8 @@ namespace Manager.Interfaces.Models
|
|||||||
|
|
||||||
public class Image
|
public class Image
|
||||||
{
|
{
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Title { get; set; }
|
||||||
public string Description { get; set; } // Dictionary<string, object> with all languages
|
public List<TranslationDTO> Description { get; set; }
|
||||||
public string Source { get; set; } // url to ressource id (local) or on internet
|
public string Source { get; set; } // url to ressource id (local) or on internet
|
||||||
|
|
||||||
public ImageDTO ToDTO()
|
public ImageDTO ToDTO()
|
||||||
|
|||||||
@ -229,10 +229,9 @@ namespace ManagerService.Controllers
|
|||||||
section.IsSubSection = false;
|
section.IsSubSection = false;
|
||||||
section.ParentId = null;
|
section.ParentId = null;
|
||||||
section.Type = newSection.Type;
|
section.Type = newSection.Type;
|
||||||
|
section.Title = new List<TranslationDTO>();
|
||||||
|
section.Description = new List<TranslationDTO>();
|
||||||
// Preparation
|
// Preparation
|
||||||
Dictionary<string, object> titles = new Dictionary<string, object>();
|
|
||||||
Dictionary<string, object> descriptions = new Dictionary<string, object>();
|
|
||||||
List<string> languages = _configurationService.GetById(newSection.ConfigurationId).Languages;
|
List<string> languages = _configurationService.GetById(newSection.ConfigurationId).Languages;
|
||||||
|
|
||||||
var mapDTO = new MapDTO(); // For menu dto
|
var mapDTO = new MapDTO(); // For menu dto
|
||||||
@ -240,29 +239,35 @@ namespace ManagerService.Controllers
|
|||||||
|
|
||||||
foreach (var language in languages)
|
foreach (var language in languages)
|
||||||
{
|
{
|
||||||
|
TranslationDTO title = new TranslationDTO();
|
||||||
|
TranslationDTO description = new TranslationDTO();
|
||||||
|
title.Language = language.ToUpper();
|
||||||
|
description.Language = language.ToUpper();
|
||||||
switch (language.ToUpper())
|
switch (language.ToUpper())
|
||||||
{
|
{
|
||||||
case "FR":
|
case "FR":
|
||||||
titles.Add(language, "Titre en français");
|
title.Value = "Titre en français";
|
||||||
descriptions.Add(language, "Description en français");
|
description.Value = "Description en français";
|
||||||
break;
|
break;
|
||||||
case "EN":
|
case "EN":
|
||||||
titles.Add(language, "Title in english");
|
title.Value = "Title in english";
|
||||||
descriptions.Add(language, "Description en anglais");
|
description.Value = "Description en anglais";
|
||||||
break;
|
break;
|
||||||
case "NL":
|
case "NL":
|
||||||
titles.Add(language, "Titre in dutch");
|
title.Value = "Titre in dutch";
|
||||||
descriptions.Add(language, "Description en néerlandais");
|
description.Value = "Description en néerlandais";
|
||||||
break;
|
break;
|
||||||
case "DE":
|
case "DE":
|
||||||
titles.Add(language, "Titre en allemand");
|
title.Value = "Titre en allemand";
|
||||||
descriptions.Add(language, "Description en allemand");
|
description.Value = "Description en allemand";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
section.Title.Add(title);
|
||||||
|
section.Description.Add(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
section.Title = JsonConvert.SerializeObject(titles);
|
section.Title = section.Title.OrderBy(t => t.Language).ToList();
|
||||||
section.Description = JsonConvert.SerializeObject(descriptions);
|
section.Description = section.Description.OrderBy(d => d.Language).ToList();
|
||||||
|
|
||||||
switch (newSection.Type) {
|
switch (newSection.Type) {
|
||||||
case SectionType.Map:
|
case SectionType.Map:
|
||||||
@ -274,13 +279,13 @@ namespace ManagerService.Controllers
|
|||||||
mapDTO.Points = new List<GeoPointDTO>() {
|
mapDTO.Points = new List<GeoPointDTO>() {
|
||||||
new GeoPointDTO() {
|
new GeoPointDTO() {
|
||||||
Id = 0,
|
Id = 0,
|
||||||
Title = JsonConvert.SerializeObject(titles),
|
Title = section.Title,
|
||||||
Description = JsonConvert.SerializeObject(descriptions),
|
Description = section.Description,
|
||||||
Image = "", // TODO sample
|
Image = "", // TODO sample
|
||||||
ImageType = "url", // TODO
|
ImageType = "url", // TODO
|
||||||
Latitude = "50.416639",
|
Latitude = "50.416639",
|
||||||
Longitude= "4.879169",
|
Longitude= "4.879169",
|
||||||
Text= "Musée de la fraise texte"
|
Text= section.Description
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -289,8 +294,8 @@ namespace ManagerService.Controllers
|
|||||||
case SectionType.Slider:
|
case SectionType.Slider:
|
||||||
sliderDTO = new SliderDTO();
|
sliderDTO = new SliderDTO();
|
||||||
ImageDTO imageDTO = new ImageDTO();
|
ImageDTO imageDTO = new ImageDTO();
|
||||||
imageDTO.Title = JsonConvert.SerializeObject(titles);
|
imageDTO.Title = section.Title;
|
||||||
imageDTO.Description = JsonConvert.SerializeObject(descriptions);
|
imageDTO.Description = section.Description;
|
||||||
imageDTO.Source = "";
|
imageDTO.Source = "";
|
||||||
sliderDTO.Images = new List<ImageDTO>();
|
sliderDTO.Images = new List<ImageDTO>();
|
||||||
sliderDTO.Images.Add(imageDTO);
|
sliderDTO.Images.Add(imageDTO);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user