Update section info
This commit is contained in:
parent
1a1d7ccd9e
commit
9e54ba1886
@ -11,6 +11,7 @@ namespace Manager.Interfaces.DTO
|
|||||||
public List<string> SectionIds { get; set; }
|
public List<string> SectionIds { get; set; }
|
||||||
public string PrimaryColor { get; set; }
|
public string PrimaryColor { get; set; }
|
||||||
public string SecondaryColor { get; set; }
|
public string SecondaryColor { get; set; }
|
||||||
|
public List<string> Languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application !
|
||||||
public DateTime DateCreation { get; set; }
|
public DateTime DateCreation { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,10 +9,12 @@ namespace Manager.Interfaces.DTO
|
|||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Label { get; set; } // Dictionary<string, object> with all languages
|
public string Label { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
public string Description { get; set; } // Dictionary<string, object> with all languages
|
||||||
public string ImageId { get; set; } // == RessourceId
|
public string ImageId { get; set; } // == RessourceId
|
||||||
public string Data { get; set; } // == RessourceId
|
|
||||||
public bool IsSubSection { get; set; } // true if part of menu type
|
public bool IsSubSection { get; set; } // true if part of menu type
|
||||||
public string ParentId { get; set; } // only if it's an subsection
|
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 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
using System;
|
using Manager.Interfaces.Models;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Manager.Interfaces.DTO.SubSection
|
namespace Manager.Interfaces.DTO
|
||||||
{
|
{
|
||||||
public class Map
|
public class MapDTO : SectionDTO
|
||||||
{
|
{
|
||||||
public int Zoom { get; set; } // Default = 18
|
public int Zoom { get; set; } // Default = 18
|
||||||
public MapType Type { get; set; } // Default = Hybrid
|
public MapType MapType { get; set; } // Default = Hybrid
|
||||||
public List<GeoPoint> Points { get; set; }
|
public List<GeoPointDTO> Points { get; set; }
|
||||||
public string Icon { get; set; } // url to ressource id (local) or on internet
|
public string Icon { get; set; } // url to ressource id (local) or on internet
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GeoPoint
|
public class GeoPointDTO
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public string Title { get; set; } // Dictionary<string, object> with all languages
|
||||||
@ -22,12 +23,4 @@ namespace Manager.Interfaces.DTO.SubSection
|
|||||||
public string Latitude { get; set; }
|
public string Latitude { get; set; }
|
||||||
public string Longitude { get; set; }
|
public string Longitude { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MapType {
|
|
||||||
none,
|
|
||||||
normal,
|
|
||||||
satellite,
|
|
||||||
terrain,
|
|
||||||
hybrid
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Manager.Interfaces.DTO.SubSection
|
|
||||||
{
|
|
||||||
public class Menu
|
|
||||||
{
|
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
|
||||||
public List<SectionDTO> Sections { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
12
Manager.Interfaces/DTO/SubSection/MenuDTO.cs
Normal file
12
Manager.Interfaces/DTO/SubSection/MenuDTO.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Manager.Interfaces.DTO
|
||||||
|
{
|
||||||
|
public class MenuDTO : SectionDTO
|
||||||
|
{
|
||||||
|
//public string Title { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
public List<SectionDTO> Sections { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,15 +2,14 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Manager.Interfaces.DTO.SubSection
|
namespace Manager.Interfaces.DTO
|
||||||
{
|
{
|
||||||
public class Slider
|
public class SliderDTO : SectionDTO
|
||||||
{
|
{
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public List<ImageDTO> Images { get; set; }
|
||||||
public List<Image> Images { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Image {
|
public class ImageDTO {
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
public string Title { get; set; } // Dictionary<string, object> with all languages
|
||||||
public string Description { get; set; } // Dictionary<string, object> with all languages
|
public string Description { get; set; } // Dictionary<string, object> with all languages
|
||||||
public string Source { get; set; } // url to ressource id (local) or on internet
|
public string Source { get; set; } // url to ressource id (local) or on internet
|
||||||
@ -2,11 +2,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Manager.Interfaces.DTO.SubSection
|
namespace Manager.Interfaces.DTO
|
||||||
{
|
{
|
||||||
public class Video
|
public class VideoDTO : SectionDTO
|
||||||
{
|
{
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
//public string Title { get; set; } // Dictionary<string, object> with all languages
|
||||||
public string Source { get; set; } // url to ressource id (local) or on internet
|
public string Source { get; set; } // url to ressource id (local) or on internet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,11 +2,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Manager.Interfaces.DTO.SubSection
|
namespace Manager.Interfaces.DTO
|
||||||
{
|
{
|
||||||
public class Web
|
public class WebDTO : SectionDTO
|
||||||
{
|
{
|
||||||
public string Title { get; set; } // Dictionary<string, object> with all languages
|
//public string Title { get; set; } // Dictionary<string, object> with all languages
|
||||||
public string Source { get; set; } // url to ressource id (local) or on internet
|
public string Source { get; set; } // url to ressource id (local) or on internet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,6 +20,9 @@ namespace Manager.Interfaces.Models
|
|||||||
[BsonRequired]
|
[BsonRequired]
|
||||||
public string Label { get; set; } // Dictionary<string, object> with all languages
|
public string Label { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
|
||||||
|
[BsonElement("Description")]
|
||||||
|
public string Description { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
|
||||||
[BsonElement("ImageId")]
|
[BsonElement("ImageId")]
|
||||||
[BsonRequired]
|
[BsonRequired]
|
||||||
public string ImageId { get; set; }
|
public string ImageId { get; set; }
|
||||||
@ -35,12 +38,13 @@ namespace Manager.Interfaces.Models
|
|||||||
[BsonElement("ParentId")]
|
[BsonElement("ParentId")]
|
||||||
public string ParentId { get; set; } // only if it's an subsection
|
public string ParentId { get; set; } // only if it's an subsection
|
||||||
|
|
||||||
[BsonElement("Data")]
|
|
||||||
public string Data { get; set; } // Json encapsulated info
|
|
||||||
|
|
||||||
[BsonElement("DateCreation")]
|
[BsonElement("DateCreation")]
|
||||||
public DateTime DateCreation { get; set; }
|
public DateTime DateCreation { get; set; }
|
||||||
|
|
||||||
|
[BsonElement("Data")]
|
||||||
|
[BsonRequired]
|
||||||
|
public string Data { get; set; } // Json encapsulated section info
|
||||||
|
|
||||||
public SectionDTO ToDTO()
|
public SectionDTO ToDTO()
|
||||||
{
|
{
|
||||||
return new SectionDTO()
|
return new SectionDTO()
|
||||||
|
|||||||
78
Manager.Interfaces/Models/SubSection/Map.cs
Normal file
78
Manager.Interfaces/Models/SubSection/Map.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Section Information - MAP
|
||||||
|
/// </summary>
|
||||||
|
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<GeoPoint> Points { get; set; }
|
||||||
|
|
||||||
|
[BsonElement("Icon")]
|
||||||
|
public string Icon { get; set; } // url to ressource 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 string Title { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
public string Description { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
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 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
|
||||||
|
}
|
||||||
|
}
|
||||||
48
Manager.Interfaces/Models/SubSection/Slider.cs
Normal file
48
Manager.Interfaces/Models/SubSection/Slider.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Section Information - Slider
|
||||||
|
/// </summary>
|
||||||
|
public class Slider : Section
|
||||||
|
{
|
||||||
|
[BsonElement("Images")]
|
||||||
|
public List<Image> 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 string Title { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
public string Description { get; set; } // Dictionary<string, object> with all languages
|
||||||
|
public string Source { get; set; } // url to ressource id (local) or on internet
|
||||||
|
|
||||||
|
public ImageDTO ToDTO()
|
||||||
|
{
|
||||||
|
return new ImageDTO()
|
||||||
|
{
|
||||||
|
Title = Title,
|
||||||
|
Description = Description,
|
||||||
|
Source = Source
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,8 +14,7 @@ using NSwag.Annotations;
|
|||||||
namespace ManagerService.Controllers
|
namespace ManagerService.Controllers
|
||||||
{
|
{
|
||||||
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
||||||
[Route("[controller]")]
|
[ApiController, Route("api/[controller]")]
|
||||||
[ApiController]
|
|
||||||
[OpenApiTag("Display", Description = "Display management")]
|
[OpenApiTag("Display", Description = "Display management")]
|
||||||
public class DisplayController : ControllerBase
|
public class DisplayController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -101,6 +100,7 @@ namespace ManagerService.Controllers
|
|||||||
display.PrimaryColor = newDisplay.PrimaryColor;
|
display.PrimaryColor = newDisplay.PrimaryColor;
|
||||||
display.SecondaryColor = newDisplay.SecondaryColor;
|
display.SecondaryColor = newDisplay.SecondaryColor;
|
||||||
display.SectionIds = newDisplay.SectionIds;
|
display.SectionIds = newDisplay.SectionIds;
|
||||||
|
display.Languages = newDisplay.Languages;
|
||||||
display.DateCreation = DateTime.Now;
|
display.DateCreation = DateTime.Now;
|
||||||
|
|
||||||
Display displayCreated = _displayService.Create(display);
|
Display displayCreated = _displayService.Create(display);
|
||||||
@ -147,6 +147,7 @@ namespace ManagerService.Controllers
|
|||||||
display.Label = updatedDisplay.Label;
|
display.Label = updatedDisplay.Label;
|
||||||
display.PrimaryColor = updatedDisplay.PrimaryColor;
|
display.PrimaryColor = updatedDisplay.PrimaryColor;
|
||||||
display.SecondaryColor = updatedDisplay.SecondaryColor;
|
display.SecondaryColor = updatedDisplay.SecondaryColor;
|
||||||
|
display.Languages = updatedDisplay.Languages;
|
||||||
display.SectionIds = updatedDisplay.SectionIds;
|
display.SectionIds = updatedDisplay.SectionIds;
|
||||||
|
|
||||||
Display displayModified = _displayService.Update(updatedDisplay.Id, display);
|
Display displayModified = _displayService.Update(updatedDisplay.Id, display);
|
||||||
|
|||||||
@ -17,8 +17,7 @@ using NSwag.Annotations;
|
|||||||
namespace ManagerService.Controllers
|
namespace ManagerService.Controllers
|
||||||
{
|
{
|
||||||
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
||||||
[Route("[controller]")]
|
[ApiController, Route("api/[controller]")]
|
||||||
[ApiController]
|
|
||||||
[OpenApiTag("Ressource", Description = "Ressource management")]
|
[OpenApiTag("Ressource", Description = "Ressource management")]
|
||||||
public class RessourceController : ControllerBase
|
public class RessourceController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -119,6 +118,8 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO upload !
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new ressource
|
/// Create a new ressource
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,21 +1,19 @@
|
|||||||
using System;
|
using Manager.Interfaces.DTO;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Manager.Interfaces.DTO;
|
|
||||||
using Manager.Interfaces.Models;
|
using Manager.Interfaces.Models;
|
||||||
using Manager.Services;
|
using Manager.Services;
|
||||||
using ManagerService.Service.Services;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NSwag.Annotations;
|
using NSwag.Annotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace ManagerService.Controllers
|
namespace ManagerService.Controllers
|
||||||
{
|
{
|
||||||
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
||||||
[Route("[controller]")]
|
[ApiController, Route("api/[controller]")]
|
||||||
[ApiController]
|
|
||||||
[OpenApiTag("Section", Description = "Section management")]
|
[OpenApiTag("Section", Description = "Section management")]
|
||||||
public class SectionController : ControllerBase
|
public class SectionController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -52,7 +50,7 @@ namespace ManagerService.Controllers
|
|||||||
/// Get a list of all subsection (summary) of a specific section
|
/// Get a list of all subsection (summary) of a specific section
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">section id</param>
|
/// <param name="id">section id</param>
|
||||||
[ProducesResponseType(typeof(List<SectionDTO>), 200)]
|
[ProducesResponseType(typeof(List<object>), 200)]
|
||||||
[ProducesResponseType(typeof(string), 500)]
|
[ProducesResponseType(typeof(string), 500)]
|
||||||
[HttpGet("{id}/subsections")]
|
[HttpGet("{id}/subsections")]
|
||||||
public ObjectResult GetAllSectionSubSections(string id)
|
public ObjectResult GetAllSectionSubSections(string id)
|
||||||
@ -75,7 +73,7 @@ namespace ManagerService.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">section id</param>
|
/// <param name="id">section id</param>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(typeof(SectionDTO), 200)]
|
[ProducesResponseType(typeof(object), 200)]
|
||||||
[ProducesResponseType(typeof(string), 404)]
|
[ProducesResponseType(typeof(string), 404)]
|
||||||
[ProducesResponseType(typeof(string), 500)]
|
[ProducesResponseType(typeof(string), 500)]
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
@ -88,7 +86,38 @@ namespace ManagerService.Controllers
|
|||||||
if (section == null)
|
if (section == null)
|
||||||
throw new KeyNotFoundException("This section was not found");
|
throw new KeyNotFoundException("This section was not found");
|
||||||
|
|
||||||
|
switch (section.Type) {
|
||||||
|
case SectionType.Map:
|
||||||
|
MapDTO mapDTO = JsonConvert.DeserializeObject<MapDTO>(section.Data);
|
||||||
|
mapDTO.Id = section.Id;
|
||||||
|
mapDTO.Label = section.Label;
|
||||||
|
mapDTO.Description = section.Description;
|
||||||
|
mapDTO.Type = section.Type;
|
||||||
|
mapDTO.ImageId = section.ImageId;
|
||||||
|
mapDTO.IsSubSection = section.IsSubSection;
|
||||||
|
mapDTO.DateCreation = section.DateCreation;
|
||||||
|
mapDTO.Data = section.Data;
|
||||||
|
return new OkObjectResult(mapDTO);
|
||||||
|
case SectionType.Slider:
|
||||||
|
SliderDTO sliderDTO = JsonConvert.DeserializeObject<SliderDTO>(section.Data);
|
||||||
|
sliderDTO.Id = section.Id;
|
||||||
|
sliderDTO.Label = section.Label;
|
||||||
|
sliderDTO.Description = section.Description;
|
||||||
|
sliderDTO.Type = section.Type;
|
||||||
|
sliderDTO.ImageId = section.ImageId;
|
||||||
|
sliderDTO.IsSubSection = section.IsSubSection;
|
||||||
|
sliderDTO.DateCreation = section.DateCreation;
|
||||||
|
sliderDTO.Data = section.Data;
|
||||||
return new OkObjectResult(section.ToDTO());
|
return new OkObjectResult(section.ToDTO());
|
||||||
|
case SectionType.Menu:
|
||||||
|
return new OkObjectResult(section.ToDTO());
|
||||||
|
case SectionType.Web:
|
||||||
|
return new OkObjectResult(section.ToDTO());
|
||||||
|
case SectionType.Video:
|
||||||
|
return new OkObjectResult(section.ToDTO());
|
||||||
|
default:
|
||||||
|
return new OkObjectResult(section.ToDTO());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (KeyNotFoundException ex)
|
catch (KeyNotFoundException ex)
|
||||||
{
|
{
|
||||||
@ -108,7 +137,7 @@ namespace ManagerService.Controllers
|
|||||||
[ProducesResponseType(typeof(string), 400)]
|
[ProducesResponseType(typeof(string), 400)]
|
||||||
[ProducesResponseType(typeof(string), 409)]
|
[ProducesResponseType(typeof(string), 409)]
|
||||||
[ProducesResponseType(typeof(string), 500)]
|
[ProducesResponseType(typeof(string), 500)]
|
||||||
[HttpPost]
|
[HttpPost()]
|
||||||
public ObjectResult Create([FromBody] SectionDTO newSection)
|
public ObjectResult Create([FromBody] SectionDTO newSection)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -120,11 +149,26 @@ namespace ManagerService.Controllers
|
|||||||
Section section = new Section();
|
Section section = new Section();
|
||||||
section.Label = newSection.Label;
|
section.Label = newSection.Label;
|
||||||
section.ImageId = newSection.ImageId;
|
section.ImageId = newSection.ImageId;
|
||||||
section.IsSubSection = newSection.IsSubSection;
|
|
||||||
section.ParentId = newSection.ParentId;
|
|
||||||
section.Type = newSection.Type;
|
|
||||||
section.Data = newSection.Data;
|
|
||||||
section.DateCreation = DateTime.Now;
|
section.DateCreation = DateTime.Now;
|
||||||
|
section.IsSubSection = false;
|
||||||
|
section.ParentId = null;
|
||||||
|
section.Type = newSection.Type;
|
||||||
|
|
||||||
|
section.Data = newSection.Data; // Include all info from specific section as JSON
|
||||||
|
|
||||||
|
/*section.MapType = newSectionMap.MapType;
|
||||||
|
section.Zoom = newSectionMap.Zoom;
|
||||||
|
section.Icon = newSectionMap.Icon;
|
||||||
|
section.Points = newSectionMap.Points.Select(p =>
|
||||||
|
new GeoPoint() {
|
||||||
|
Id = p.Id,
|
||||||
|
Title = p.Title,
|
||||||
|
Description = p.Description,
|
||||||
|
Image = p.Image,
|
||||||
|
Text = p.Text,
|
||||||
|
Latitude = p.Latitude,
|
||||||
|
Longitude = p.Longitude
|
||||||
|
}).ToList();*/
|
||||||
|
|
||||||
Section sectionCreated = _sectionService.Create(section);
|
Section sectionCreated = _sectionService.Create(section);
|
||||||
|
|
||||||
@ -144,6 +188,57 @@ namespace ManagerService.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*/// <summary>
|
||||||
|
/// Create a new section - slider
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newSection">New section info - slider</param>
|
||||||
|
[ProducesResponseType(typeof(SliderDTO), 200)]
|
||||||
|
[ProducesResponseType(typeof(string), 400)]
|
||||||
|
[ProducesResponseType(typeof(string), 409)]
|
||||||
|
[ProducesResponseType(typeof(string), 500)]
|
||||||
|
[HttpPost("Slider")]
|
||||||
|
public ObjectResult CreateSlider([FromBody] SliderDTO newSectionSlider)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (newSectionSlider == null)
|
||||||
|
throw new ArgumentNullException("Section param is null");
|
||||||
|
|
||||||
|
// Todo add some verification ?
|
||||||
|
Slider sliderSection = new Slider();
|
||||||
|
sliderSection.Label = newSectionSlider.Label;
|
||||||
|
sliderSection.ImageId = newSectionSlider.ImageId;
|
||||||
|
sliderSection.DateCreation = DateTime.Now;
|
||||||
|
|
||||||
|
sliderSection.IsSubSection = false;
|
||||||
|
sliderSection.ParentId = null;
|
||||||
|
sliderSection.Type = SectionType.Slider;
|
||||||
|
|
||||||
|
sliderSection.Images = newSectionSlider.Images.Select(p =>
|
||||||
|
new Image()
|
||||||
|
{
|
||||||
|
Title = p.Title,
|
||||||
|
Description = p.Description,
|
||||||
|
Source = p.Source,
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
Slider sectionCreated = _sectionService.CreateSlider(sliderSection);
|
||||||
|
|
||||||
|
return new OkObjectResult(sectionCreated.ToDTO());
|
||||||
|
}
|
||||||
|
catch (ArgumentNullException ex)
|
||||||
|
{
|
||||||
|
return new BadRequestObjectResult(ex.Message) { };
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
return new ConflictObjectResult(ex.Message) { };
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new ObjectResult(ex.Message) { StatusCode = 500 };
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update a section
|
/// Update a section
|
||||||
@ -172,7 +267,6 @@ namespace ManagerService.Controllers
|
|||||||
section.IsSubSection = updatedSection.IsSubSection;
|
section.IsSubSection = updatedSection.IsSubSection;
|
||||||
section.ParentId = updatedSection.ParentId;
|
section.ParentId = updatedSection.ParentId;
|
||||||
section.Type = updatedSection.Type;
|
section.Type = updatedSection.Type;
|
||||||
section.Data = updatedSection.Data;
|
|
||||||
|
|
||||||
Section sectionModified = _sectionService.Update(updatedSection.Id, section);
|
Section sectionModified = _sectionService.Update(updatedSection.Id, section);
|
||||||
|
|
||||||
|
|||||||
@ -14,8 +14,7 @@ using NSwag.Annotations;
|
|||||||
namespace ManagerService.Controllers
|
namespace ManagerService.Controllers
|
||||||
{
|
{
|
||||||
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
[Authorize] // TODO Add ROLES (Roles = "Admin")
|
||||||
[Route("[controller]")]
|
[ApiController, Route("api/[controller]")]
|
||||||
[ApiController]
|
|
||||||
[OpenApiTag("User", Description = "User management")]
|
[OpenApiTag("User", Description = "User management")]
|
||||||
public class UserController : ControllerBase
|
public class UserController : ControllerBase
|
||||||
{
|
{
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.10.0" />
|
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.10.0" />
|
||||||
<PackageReference Include="MongoDB.Driver" Version="2.12.1" />
|
<PackageReference Include="MongoDB.Driver" Version="2.12.1" />
|
||||||
<PackageReference Include="NSwag.AspNetCore" Version="13.10.8" />
|
<PackageReference Include="NSwag.AspNetCore" Version="13.10.8" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.10.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.10.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -98,10 +98,12 @@ namespace ManagerService
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddScoped<TokensService>();
|
|
||||||
services.AddScoped(typeof(ProfileLogic));
|
services.AddScoped(typeof(ProfileLogic));
|
||||||
|
services.AddScoped<TokensService>();
|
||||||
services.AddScoped<UserDatabaseService>();
|
services.AddScoped<UserDatabaseService>();
|
||||||
|
services.AddScoped<SectionDatabaseService>();
|
||||||
|
services.AddScoped<DisplayDatabaseService>();
|
||||||
|
services.AddScoped<RessourceDatabaseService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
@ -159,8 +161,8 @@ namespace ManagerService
|
|||||||
config.PostProcess = document =>
|
config.PostProcess = document =>
|
||||||
{
|
{
|
||||||
document.Info.Title = "Manager Service";
|
document.Info.Title = "Manager Service";
|
||||||
document.Info.Description = "API description";
|
document.Info.Description = "API Manager Service";
|
||||||
document.Info.Version = "Version Pre-Alpha";
|
document.Info.Version = "Version Alpha";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user