From 29ca277cf491b9aba5330615fb662c55a2b8175b Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Fri, 21 May 2021 22:42:59 +0200 Subject: [PATCH] Add resourceId to icon (Map) and slider --- Manager.Interfaces/DTO/SubSection/MapDTO.cs | 17 +++- .../DTO/SubSection/SliderDTO.cs | 2 + Manager.Interfaces/Models/SubSection/Map.cs | 78 ------------------- .../Models/SubSection/Slider.cs | 48 ------------ .../Controllers/SectionController.cs | 6 +- 5 files changed, 16 insertions(+), 135 deletions(-) delete mode 100644 Manager.Interfaces/Models/SubSection/Map.cs delete mode 100644 Manager.Interfaces/Models/SubSection/Slider.cs diff --git a/Manager.Interfaces/DTO/SubSection/MapDTO.cs b/Manager.Interfaces/DTO/SubSection/MapDTO.cs index 1e4ab34..51ae44f 100644 --- a/Manager.Interfaces/DTO/SubSection/MapDTO.cs +++ b/Manager.Interfaces/DTO/SubSection/MapDTO.cs @@ -10,7 +10,8 @@ namespace Manager.Interfaces.DTO public int Zoom { get; set; } // Default = 18 public MapType MapType { get; set; } // Default = Hybrid public List Points { get; set; } - public string Icon { get; set; } // url to resource id (local) or on internet + public string IconResourceId { get; set; } + public string IconSource { get; set; } // url to resource id (local) or on internet } public class GeoPointDTO @@ -18,10 +19,18 @@ namespace Manager.Interfaces.DTO public int Id { get; set; } public List Title { get; set; } public List Description { get; set; } - public string Image { get; set; } // url to resource id (local) or on internet - public string ImageType { get; set; } // url or resource - public List Text { get; set; } + public string ImageResourceId { get; set; } + public string ImageSource { get; set; } // url to resource id (local) or on internet public string Latitude { get; set; } public string Longitude { get; set; } } + + public enum MapType + { + none, + normal, + satellite, + terrain, + hybrid + } } diff --git a/Manager.Interfaces/DTO/SubSection/SliderDTO.cs b/Manager.Interfaces/DTO/SubSection/SliderDTO.cs index 4d7df0a..c4f44e1 100644 --- a/Manager.Interfaces/DTO/SubSection/SliderDTO.cs +++ b/Manager.Interfaces/DTO/SubSection/SliderDTO.cs @@ -13,6 +13,8 @@ namespace Manager.Interfaces.DTO public class ImageDTO { public List Title { get; set; } public List Description { get; set; } + public string ResourceId { get; set; } public string Source { get; set; } // url to resource id (local) or on internet + public int Order { get; set; } // Order to show } } diff --git a/Manager.Interfaces/Models/SubSection/Map.cs b/Manager.Interfaces/Models/SubSection/Map.cs deleted file mode 100644 index 1d7b1f3..0000000 --- a/Manager.Interfaces/Models/SubSection/Map.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Manager.Interfaces.DTO; -using MongoDB.Bson.Serialization.Attributes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - - -namespace Manager.Interfaces.Models -{ - /// - /// Section Information - MAP - /// - public class Map : Section - { - [BsonElement("Map")] - [BsonRequired] - public MapType MapType { get; set; } = MapType.hybrid; - - [BsonElement("Zoom")] - public int Zoom { get; set; } = 18; - - [BsonElement("Points")] - public List Points { get; set; } - - [BsonElement("Icon")] - public string Icon { get; set; } // url to resource id (local) or on internet - - public MapDTO ToDetailDTO() - { - return new MapDTO() - { - /*Id = Id, - Label = Label, - Type = Type, - ImageId = ImageId,*/ - MapType = MapType, - Zoom = Zoom, - Points = Points.Select(p => p.ToDTO()).ToList(), - Icon = Icon - }; - } - } - - public class GeoPoint - { - public int Id { get; set; } - public List Title { get; set; } - public List Description { get; set; } - public string Image { get; set; } // url to resource id (local) or on internet - public List Text { get; set; } - public string Latitude { get; set; } - public string Longitude { get; set; } - - public GeoPointDTO ToDTO() - { - return new GeoPointDTO() - { - Id = Id, - Title = Title, - Description = Description, - Image = Image, - Text = Text, - Latitude = Latitude, - Longitude = Longitude - }; - } - } - - public enum MapType - { - none, - normal, - satellite, - terrain, - hybrid - } -} diff --git a/Manager.Interfaces/Models/SubSection/Slider.cs b/Manager.Interfaces/Models/SubSection/Slider.cs deleted file mode 100644 index 0e9ebce..0000000 --- a/Manager.Interfaces/Models/SubSection/Slider.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Manager.Interfaces.DTO; -using MongoDB.Bson.Serialization.Attributes; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - - -namespace Manager.Interfaces.Models -{ - /// - /// Section Information - Slider - /// - public class Slider : Section - { - [BsonElement("Images")] - public List Images { get; set; } - - public SliderDTO ToDetailDTO() - { - return new SliderDTO() - { - /*Id = Id, - Label = Label, - Type = Type, - ImageId = ImageId,*/ - Images = Images.Select(p => p.ToDTO()).ToList(), - }; - } - } - - public class Image - { - public List Title { get; set; } - public List Description { get; set; } - public string Source { get; set; } // url to resource id (local) or on internet - - public ImageDTO ToDTO() - { - return new ImageDTO() - { - Title = Title, - Description = Description, - Source = Source - }; - } - } -} diff --git a/ManagerService/Controllers/SectionController.cs b/ManagerService/Controllers/SectionController.cs index ee25bbd..13407cc 100644 --- a/ManagerService/Controllers/SectionController.cs +++ b/ManagerService/Controllers/SectionController.cs @@ -272,7 +272,6 @@ namespace ManagerService.Controllers switch (newSection.Type) { case SectionType.Map: mapDTO = new MapDTO(); - mapDTO.Icon = ""; mapDTO.MapType = MapType.hybrid; mapDTO.Zoom = 18; @@ -281,11 +280,8 @@ namespace ManagerService.Controllers Id = 0, Title = section.Title, Description = section.Description, - Image = "", // TODO sample - ImageType = "url", // TODO Latitude = "50.416639", Longitude= "4.879169", - Text= section.Description } }; @@ -296,7 +292,7 @@ namespace ManagerService.Controllers ImageDTO imageDTO = new ImageDTO(); imageDTO.Title = section.Title; imageDTO.Description = section.Description; - imageDTO.Source = ""; + imageDTO.Source = null; sliderDTO.Images = new List(); sliderDTO.Images.Add(imageDTO);