From 37c667cd46393f10124266dd3ce4012615c87031 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Fri, 28 May 2021 19:50:26 +0200 Subject: [PATCH] Add imagesource to sectionDTO + delete sectionIds for configuration + add order to section --- Manager.Interfaces/DTO/ConfigurationDTO.cs | 1 - Manager.Interfaces/DTO/SectionDTO.cs | 2 ++ Manager.Interfaces/Models/Configuration.cs | 1 - Manager.Interfaces/Models/Section.cs | 9 +++++++++ ManagerService/Controllers/ConfigurationController.cs | 4 +--- ManagerService/Controllers/SectionController.cs | 3 +++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Manager.Interfaces/DTO/ConfigurationDTO.cs b/Manager.Interfaces/DTO/ConfigurationDTO.cs index 14b767a..710a749 100644 --- a/Manager.Interfaces/DTO/ConfigurationDTO.cs +++ b/Manager.Interfaces/DTO/ConfigurationDTO.cs @@ -8,7 +8,6 @@ namespace Manager.Interfaces.DTO { public string Id { get; set; } public string Label { get; set; } - public List SectionIds { get; set; } public string PrimaryColor { get; set; } 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 ! diff --git a/Manager.Interfaces/DTO/SectionDTO.cs b/Manager.Interfaces/DTO/SectionDTO.cs index 09e88a2..c54409b 100644 --- a/Manager.Interfaces/DTO/SectionDTO.cs +++ b/Manager.Interfaces/DTO/SectionDTO.cs @@ -12,11 +12,13 @@ namespace Manager.Interfaces.DTO public List Title { get; set; } public List Description { get; set; } public string ImageId { get; set; } // == ResourceId + public string ImageSource { get; set; } // == Image url public string ConfigurationId { get; set; } public bool IsSubSection { get; set; } // true if part of menu type public string ParentId { get; set; } // only if it's an subsection public SectionType Type { get; set; } // !! If IsSubSection == true => Type can't not be menu ! public string Data { get; set; } // == Include section type info public DateTime DateCreation { get; set; } // == Include section type info + public int Order { get; set; } // Order to show } } diff --git a/Manager.Interfaces/Models/Configuration.cs b/Manager.Interfaces/Models/Configuration.cs index 2c1bac9..b1412cb 100644 --- a/Manager.Interfaces/Models/Configuration.cs +++ b/Manager.Interfaces/Models/Configuration.cs @@ -43,7 +43,6 @@ namespace Manager.Interfaces.Models DateCreation = DateCreation, PrimaryColor = PrimaryColor, Languages = Languages, - SectionIds = SectionIds, // Maybe get direct from db SecondaryColor = SecondaryColor }; } diff --git a/Manager.Interfaces/Models/Section.cs b/Manager.Interfaces/Models/Section.cs index 2c91e8a..a0c9912 100644 --- a/Manager.Interfaces/Models/Section.cs +++ b/Manager.Interfaces/Models/Section.cs @@ -28,6 +28,9 @@ namespace Manager.Interfaces.Models [BsonElement("Description")] public List Description { get; set; } + [BsonElement("Order")] + public int Order { get; set; } + [BsonElement("ConfigurationId")] [BsonRequired] public string ConfigurationId { get; set; } // Parent id @@ -36,6 +39,10 @@ namespace Manager.Interfaces.Models [BsonRequired] public string ImageId { get; set; } + [BsonElement("ImageSource")] + [BsonRequired] + public string ImageSource { get; set; } + [BsonElement("Type")] [BsonRequired] public SectionType Type { get; set; } @@ -62,8 +69,10 @@ namespace Manager.Interfaces.Models Label = Label, Title = Title.OrderBy(t => t.Language).ToList(), Description = Description.OrderBy(d => d.Language).ToList(), + Order = Order, Type = Type, ImageId = ImageId, + ImageSource = ImageSource, ConfigurationId = ConfigurationId, IsSubSection = IsSubSection, ParentId = ParentId, diff --git a/ManagerService/Controllers/ConfigurationController.cs b/ManagerService/Controllers/ConfigurationController.cs index 8637426..33a281f 100644 --- a/ManagerService/Controllers/ConfigurationController.cs +++ b/ManagerService/Controllers/ConfigurationController.cs @@ -99,8 +99,7 @@ namespace ManagerService.Controllers configuration.Label = newConfiguration.Label; configuration.PrimaryColor = newConfiguration.PrimaryColor; configuration.SecondaryColor = newConfiguration.SecondaryColor; - configuration.SectionIds = newConfiguration.SectionIds; - configuration.Languages = newConfiguration.Languages; + configuration.Languages = new List { "FR", "NL", "EN", "DE" }; // by default all languages configuration.DateCreation = DateTime.Now; Configuration configurationCreated = _configurationService.Create(configuration); @@ -148,7 +147,6 @@ namespace ManagerService.Controllers configuration.PrimaryColor = updatedConfiguration.PrimaryColor; configuration.SecondaryColor = updatedConfiguration.SecondaryColor; configuration.Languages = updatedConfiguration.Languages; - configuration.SectionIds = updatedConfiguration.SectionIds; Configuration configurationModified = _configurationService.Update(updatedConfiguration.Id, configuration); diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index e5d9531..bf8fa76 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -224,6 +224,7 @@ namespace ManagerService.Controllers Section section = new Section(); section.Label = newSection.Label; section.ImageId = newSection.ImageId; + section.ImageSource = newSection.ImageSource; section.ConfigurationId = newSection.ConfigurationId; section.DateCreation = DateTime.Now; section.IsSubSection = newSection.IsSubSection; @@ -231,6 +232,7 @@ namespace ManagerService.Controllers section.Type = newSection.Type; section.Title = new List(); section.Description = new List(); + section.Order = _sectionService.GetAllFromConfiguration(newSection.ConfigurationId).Count; // Preparation List languages = new List { "FR", "NL", "EN", "DE" };//_configurationService.GetById(newSection.ConfigurationId).Languages; @@ -436,6 +438,7 @@ namespace ManagerService.Controllers section.Description = updatedSection.Description; section.Type = updatedSection.Type; section.ImageId = updatedSection.ImageId; + section.ImageSource = updatedSection.ImageSource; section.ConfigurationId = updatedSection.ConfigurationId; section.IsSubSection = updatedSection.IsSubSection; section.ParentId = updatedSection.ParentId;