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