Update article to handle multiple audioIds
This commit is contained in:
parent
85ca1368a2
commit
fc9d38c3c1
@ -7,12 +7,10 @@ namespace Manager.Interfaces.DTO
|
||||
{
|
||||
public class ArticleDTO
|
||||
{
|
||||
//public List<TranslationDTO> title { get; set; }
|
||||
//public List<TranslationDTO> description { get; set; }
|
||||
public List<TranslationDTO> content { get; set; }
|
||||
public string qrCode { get; set; } // MyVisit - QR code identifier int ? String ?
|
||||
public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise
|
||||
public string audioId { get; set; } // MyVisit - Audio Identifier
|
||||
public List<TranslationDTO> audioIds { get; set; }
|
||||
public bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise
|
||||
public List<ImageDTO> images { get; set; } // Will check if ok or if we need need type of image (simpler)
|
||||
}
|
||||
|
||||
@ -46,6 +46,26 @@ namespace ManagerService.Controllers
|
||||
{
|
||||
List<Section> sections = _sectionService.GetAll(instanceId);
|
||||
|
||||
|
||||
/* CLEAN ARTICLE AUDIO - Init new field AudioIds */
|
||||
|
||||
/*foreach (var article in sections.Where(s => s.Type == SectionType.Article))
|
||||
{
|
||||
try
|
||||
{
|
||||
ArticleDTO articleDTO = JsonConvert.DeserializeObject<ArticleDTO>(article.Data);
|
||||
List<string> languages = _configuration.GetSection("SupportedLanguages").Get<List<string>>();
|
||||
articleDTO.audioIds = LanguageInit.Init("Audio", languages, true);
|
||||
article.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON
|
||||
|
||||
Section sectionModified = _sectionService.Update(article.Id, article);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
return new OkObjectResult(sections.Select(r => r.ToDTO()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -361,6 +381,7 @@ namespace ManagerService.Controllers
|
||||
ArticleDTO articleDTO = new ArticleDTO();
|
||||
articleDTO.images = new List<ImageDTO>();
|
||||
articleDTO.content = contentArticle;
|
||||
articleDTO.audioIds = LanguageInit.Init("Audio", languages, true);
|
||||
|
||||
section.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON
|
||||
break;
|
||||
|
||||
@ -11,13 +11,14 @@ namespace Manager.Helpers
|
||||
{
|
||||
public class LanguageInit
|
||||
{
|
||||
public static List<TranslationDTO> Init(string label, List<string> languages)
|
||||
public static List<TranslationDTO> Init(string label, List<string> languages, bool toNull = false)
|
||||
{
|
||||
List<TranslationDTO> translations = new List<TranslationDTO>();
|
||||
|
||||
foreach (var language in languages)
|
||||
{
|
||||
translations.Add(new TranslationDTO() { language = language.ToUpper(), value = $"{language} - {label}" });
|
||||
var value = toNull ? null : $"{language} - {label}";
|
||||
translations.Add(new TranslationDTO() { language = language.ToUpper(), value = value });
|
||||
}
|
||||
return translations;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user