From 55a612fd0c11dd66d9bde3f8c7e464f92aaf0a79 Mon Sep 17 00:00:00 2001 From: Fransolet Thomas Date: Sat, 11 Jun 2022 20:58:43 +0200 Subject: [PATCH] Add new subsection ArticleDTO + add offline and mobile option --- Manager.Framework/Manager.Framework.csproj | 2 +- Manager.Interfaces/DTO/ConfigurationDTO.cs | 4 +++ .../DTO/SubSection/ArticleDTO.cs | 19 ++++++++++++++ Manager.Interfaces/Manager.Interfaces.csproj | 2 +- Manager.Interfaces/Models/Configuration.cs | 12 ++++++++- Manager.Interfaces/Models/Section.cs | 3 ++- .../Controllers/ConfigurationController.cs | 26 +++++++++++++++++++ .../Controllers/ResourceController.cs | 11 ++++++++ .../Controllers/SectionController.cs | 10 +++++++ ManagerService/ManagerService.csproj | 2 +- 10 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 Manager.Interfaces/DTO/SubSection/ArticleDTO.cs diff --git a/Manager.Framework/Manager.Framework.csproj b/Manager.Framework/Manager.Framework.csproj index 2e573fe..92f880b 100644 --- a/Manager.Framework/Manager.Framework.csproj +++ b/Manager.Framework/Manager.Framework.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 diff --git a/Manager.Interfaces/DTO/ConfigurationDTO.cs b/Manager.Interfaces/DTO/ConfigurationDTO.cs index d162daa..214dd35 100644 --- a/Manager.Interfaces/DTO/ConfigurationDTO.cs +++ b/Manager.Interfaces/DTO/ConfigurationDTO.cs @@ -12,5 +12,9 @@ namespace Manager.Interfaces.DTO public string secondaryColor { get; set; } public List languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application ! public DateTime dateCreation { get; set; } + public bool isMobile { get; set; } // MyVisit - True if for mobile (MyVisit) + public bool isOffline { get; set; } // MyVisit - True if MyVisit is full offline + /*public string latitude { get; set; } // MyVisit - latitude of visit ? (MyVisit) + public string longitude { get; set; } // MyVisit - True if for mobile (MyVisit)*/ } } diff --git a/Manager.Interfaces/DTO/SubSection/ArticleDTO.cs b/Manager.Interfaces/DTO/SubSection/ArticleDTO.cs new file mode 100644 index 0000000..dd3dd84 --- /dev/null +++ b/Manager.Interfaces/DTO/SubSection/ArticleDTO.cs @@ -0,0 +1,19 @@ +using Manager.Interfaces.Models; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Manager.Interfaces.DTO +{ + public class ArticleDTO + { + public List title { get; set; } + public List description { get; set; } + public List 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 bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise + public List images { get; set; } // Will check if ok or if we need need type of image (simpler) + } +} diff --git a/Manager.Interfaces/Manager.Interfaces.csproj b/Manager.Interfaces/Manager.Interfaces.csproj index f6da939..4382621 100644 --- a/Manager.Interfaces/Manager.Interfaces.csproj +++ b/Manager.Interfaces/Manager.Interfaces.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 diff --git a/Manager.Interfaces/Models/Configuration.cs b/Manager.Interfaces/Models/Configuration.cs index 28a8dc3..927dedb 100644 --- a/Manager.Interfaces/Models/Configuration.cs +++ b/Manager.Interfaces/Models/Configuration.cs @@ -31,6 +31,12 @@ namespace Manager.Interfaces.Models [BsonElement("DateCreation")] public DateTime DateCreation { get; set; } + [BsonElement("IsMobile")] + public bool IsMobile { get; set; } + + [BsonElement("IsOffline")] + public bool IsOffline { get; set; } + public ConfigurationDTO ToDTO() { return new ConfigurationDTO() @@ -40,7 +46,9 @@ namespace Manager.Interfaces.Models dateCreation = DateCreation, primaryColor = PrimaryColor, languages = Languages, - secondaryColor = SecondaryColor + secondaryColor = SecondaryColor, + isMobile = IsMobile, + isOffline = IsOffline }; } @@ -53,6 +61,8 @@ namespace Manager.Interfaces.Models primaryColor = PrimaryColor, languages = Languages, secondaryColor = SecondaryColor, + isMobile = IsMobile, + isOffline = IsOffline, sections = sections, resources = resources }; diff --git a/Manager.Interfaces/Models/Section.cs b/Manager.Interfaces/Models/Section.cs index 739430e..5e7fd98 100644 --- a/Manager.Interfaces/Models/Section.cs +++ b/Manager.Interfaces/Models/Section.cs @@ -89,6 +89,7 @@ namespace Manager.Interfaces.Models Video, Web, Menu, - Quizz + Quizz, + Article } } diff --git a/ManagerService/Controllers/ConfigurationController.cs b/ManagerService/Controllers/ConfigurationController.cs index 7dba07b..37b21ef 100644 --- a/ManagerService/Controllers/ConfigurationController.cs +++ b/ManagerService/Controllers/ConfigurationController.cs @@ -111,6 +111,8 @@ namespace ManagerService.Controllers configuration.SecondaryColor = newConfiguration.secondaryColor; configuration.Languages = new List { "FR", "NL", "EN", "DE" }; // by default all languages configuration.DateCreation = DateTime.Now; + configuration.IsMobile = newConfiguration.isMobile; + configuration.IsOffline = newConfiguration.isOffline; Configuration configurationCreated = _configurationService.Create(configuration); @@ -157,6 +159,8 @@ namespace ManagerService.Controllers configuration.PrimaryColor = updatedConfiguration.primaryColor; configuration.SecondaryColor = updatedConfiguration.secondaryColor; configuration.Languages = updatedConfiguration.languages; + configuration.IsMobile = updatedConfiguration.isMobile; + configuration.IsOffline = updatedConfiguration.isOffline; Configuration configurationModified = _configurationService.Update(updatedConfiguration.id, configuration); @@ -326,6 +330,16 @@ namespace ManagerService.Controllers } } break; + case SectionType.Article: + ArticleDTO articleDTO = JsonConvert.DeserializeObject(section.data); + foreach (var image in articleDTO.images) + { + if (image.resourceId != null) + { + addResourceToList(resourceDTOs, image.resourceId); + } + } + break; case SectionType.Menu: case SectionType.Web: case SectionType.Video: @@ -388,6 +402,8 @@ namespace ManagerService.Controllers configuration.PrimaryColor = exportConfiguration.primaryColor; configuration.SecondaryColor = exportConfiguration.secondaryColor; configuration.Languages = exportConfiguration.languages; + configuration.IsMobile = exportConfiguration.isMobile; + configuration.IsOffline = exportConfiguration.isOffline; _configurationService.Create(configuration); @@ -484,6 +500,16 @@ namespace ManagerService.Controllers } } break; + case SectionType.Article: + ArticleDTO articleDTO = JsonConvert.DeserializeObject(section.data); + foreach (var image in articleDTO.images) + { + if (image.resourceId != null) + { + createResource(exportConfiguration.resources.Where(r => r.id == image.resourceId).FirstOrDefault()); + } + } + break; case SectionType.Menu: case SectionType.Web: case SectionType.Video: diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs index ada6ba9..0e5fb96 100644 --- a/ManagerService/Controllers/ResourceController.cs +++ b/ManagerService/Controllers/ResourceController.cs @@ -357,6 +357,17 @@ namespace ManagerService.Controllers } section.Data = JsonConvert.SerializeObject(quizzDTO); break; + case SectionType.Article: + ArticleDTO articleDTO = JsonConvert.DeserializeObject(section.Data); + List imagesArticleToKeep = new List(); + foreach (var image in articleDTO.images) + { + if (image.resourceId != id) + imagesArticleToKeep.Add(image); + } + articleDTO.images = imagesArticleToKeep; + section.Data = JsonConvert.SerializeObject(articleDTO); + break; } _sectionService.Update(section.Id, section); diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index c3ca01b..f8cc193 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -621,5 +621,15 @@ namespace ManagerService.Controllers { return new ObjectResult("QuizzDTO") { StatusCode = 200 }; } + + /// + /// Useless, just to generate dto code + /// + [ProducesResponseType(typeof(ArticleDTO), 200)] + [HttpGet("ArticleDTO")] + public ObjectResult GetArticleDTO() + { + return new ObjectResult("ArticleDTO") { StatusCode = 200 }; + } } } diff --git a/ManagerService/ManagerService.csproj b/ManagerService/ManagerService.csproj index 5140a69..60117dd 100644 --- a/ManagerService/ManagerService.csproj +++ b/ManagerService/ManagerService.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0