Updated DB (wip)

This commit is contained in:
Thomas Fransolet 2025-03-19 08:57:29 +01:00
parent 20c35b2c8d
commit 11cfeab210
74 changed files with 3858 additions and 249 deletions

View File

@ -9,7 +9,9 @@ using Manager.Helpers;
using Manager.Interfaces.Models;
using Manager.Services;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using ManagerService.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
@ -34,6 +36,7 @@ namespace ManagerService.Controllers
private DeviceDatabaseService _deviceService;*/
private readonly ILogger<ConfigurationController> _logger;
private readonly IConfiguration _configuration;
IHexIdGeneratorService idService = new HexIdGeneratorService();
public ConfigurationController(IConfiguration configuration, ILogger<ConfigurationController> logger, MyInfoMateDbContext myInfoMateDbContext)
{
@ -129,11 +132,14 @@ namespace ManagerService.Controllers
try
{
var weatherSections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && s.Type == SectionType.Weather && !s.IsSubSection).ToList(); // TODO TEST
//var weatherSections = _myInfoMateDbContext.Sections.Where(s => s.ConfigurationId == id && s.Type == SectionType.Weather && !s.IsSubSection).ToList(); // TODO TEST
var weatherSections = _myInfoMateDbContext.Sections.OfType<SectionWeather>()
.Where(s => s.ConfigurationId == id && !s.IsSubSection)
.ToList();
foreach (var weatherSection in weatherSections)
{
WeatherDTO weatherDTO = JsonConvert.DeserializeObject<WeatherDTO>(weatherSection.Data);
WeatherDTO weatherDTO = weatherSection.ToDTO();//JsonConvert.DeserializeObject<WeatherDTO>(weatherSection.Data);
if (weatherDTO.city != null && weatherDTO.city.Length >= 2 &&
(weatherDTO.updatedDate == null || weatherDTO.updatedDate.Value.AddHours(3) < DateTimeOffset.Now)) // Update all 4 hours
{
@ -168,7 +174,7 @@ namespace ManagerService.Controllers
weatherDTO.updatedDate = DateTimeOffset.Now;
weatherDTO.result = callResponseBody;
weatherSection.Data = JsonConvert.SerializeObject(weatherDTO); // TODO update
//weatherSection.Data = JsonConvert.SerializeObject(weatherDTO); // TODO update
_myInfoMateDbContext.SaveChanges();
//_sectionService.Update(weatherSection.Id, weatherSection);
@ -245,14 +251,18 @@ namespace ManagerService.Controllers
//configuration.Languages = new List<string> { "FR", "NL", "EN", "DE" }; // by default all languages
configuration.Title = LanguageInit.Init("Title", configuration.Languages);
configuration.DateCreation = DateTime.Now;
configuration.DateCreation = DateTime.Now.ToUniversalTime();
configuration.IsMobile = newConfiguration.isMobile;
configuration.IsTablet = newConfiguration.isTablet;
configuration.IsOffline = newConfiguration.isOffline;
configuration.Id = idService.GenerateHexId();
_myInfoMateDbContext.Configurations.Add(configuration);
//Configuration configurationCreated = _configurationService.Create(configuration);
_myInfoMateDbContext.SaveChanges();
return new OkObjectResult(configuration.ToDTO(new List<string>())); // Empty list
}
catch (ArgumentNullException ex)
@ -437,7 +447,7 @@ namespace ManagerService.Controllers
addResourceToList(resourceDTOs, section.imageId);
}
switch (section.type) {
/*switch (section.type) {
case SectionType.Map:
MapDTO mapDTO = JsonConvert.DeserializeObject<MapDTO>(section.data);
if (mapDTO.iconResourceId != null)
@ -594,7 +604,7 @@ namespace ManagerService.Controllers
case SectionType.Weather:
default:
break;
}
}*/
}
ExportConfigurationDTO toDownload = configuration.ToExportDTO(sectionDTOs, resourceDTOs);
string jsonString = JsonConvert.SerializeObject(toDownload);
@ -699,7 +709,7 @@ namespace ManagerService.Controllers
newSection.ConfigurationId = section.configurationId;
newSection.IsSubSection = section.isSubSection;
newSection.ParentId = section.parentId;
newSection.Data = section.data;
//newSection.Data = section.data;
newSection.DateCreation = section.dateCreation;
newSection.IsBeacon = section.isBeacon;
newSection.BeaconId = section.beaconId;
@ -715,7 +725,7 @@ namespace ManagerService.Controllers
_myInfoMateDbContext.Sections.Add(newSection);
//_sectionService.Create(newSection);
switch (section.type)
/*switch (section.type)
{
case SectionType.Map:
MapDTO mapDTO = JsonConvert.DeserializeObject<MapDTO>(section.data);
@ -759,7 +769,7 @@ namespace ManagerService.Controllers
}
break;
case SectionType.Quizz:
QuizzDTO quizzDTO = JsonConvert.DeserializeObject<QuizzDTO>(section.data);
QuizDTO quizzDTO = JsonConvert.DeserializeObject<QuizDTO>(section.data);
foreach (var question in quizzDTO.questions)
{
if (question.label != null)
@ -841,7 +851,7 @@ namespace ManagerService.Controllers
case SectionType.Weather:
default:
break;
}
}*/
}
return new ObjectResult("The configuration has been successfully imported") { StatusCode = 202 };

View File

@ -40,7 +40,7 @@ namespace ManagerService.Controllers
{
try
{
List<Device> devices = _deviceService.GetAll(instanceId);
List<OldDevice> devices = _deviceService.GetAll(instanceId);
return new OkObjectResult(devices.Select(d => d.ToDTO()));
}
@ -64,7 +64,7 @@ namespace ManagerService.Controllers
{
try
{
Device device = _deviceService.GetById(id);
OldDevice device = _deviceService.GetById(id);
if (device == null)
throw new KeyNotFoundException("This device was not found");
@ -104,7 +104,7 @@ namespace ManagerService.Controllers
if (configuration == null)
throw new KeyNotFoundException("Configuration does not exist");
Device device = new Device();
OldDevice device = new OldDevice();
if (_deviceService.IsExistIdentifier(newDevice.identifier))
{
// Update info
@ -129,7 +129,7 @@ namespace ManagerService.Controllers
device.BatteryLevel = newDevice.batteryLevel;
device.LastBatteryLevel = newDevice.lastBatteryLevel;
Device deviceCreated = _deviceService.IsExistIdentifier(newDevice.identifier) ? _deviceService.Update(device.Id, device) : _deviceService.Create(device);
OldDevice deviceCreated = _deviceService.IsExistIdentifier(newDevice.identifier) ? _deviceService.Update(device.Id, device) : _deviceService.Create(device);
return new OkObjectResult(deviceCreated.ToDTO());
}
@ -168,7 +168,7 @@ namespace ManagerService.Controllers
if (updatedDevice == null)
throw new ArgumentNullException("Device param is null");
Device device = _deviceService.GetById(updatedDevice.id);
OldDevice device = _deviceService.GetById(updatedDevice.id);
if (device == null)
throw new KeyNotFoundException("Device does not exist");
@ -185,7 +185,7 @@ namespace ManagerService.Controllers
device.BatteryLevel = updatedDevice.batteryLevel;
device.LastBatteryLevel = updatedDevice.lastBatteryLevel;
Device deviceModified = _deviceService.Update(updatedDevice.id, device);
OldDevice deviceModified = _deviceService.Update(updatedDevice.id, device);
return new OkObjectResult(deviceModified.ToDTO());
}
@ -219,7 +219,7 @@ namespace ManagerService.Controllers
if (deviceIn == null)
throw new ArgumentNullException("Device param is null");
Device device = _deviceService.GetById(deviceIn.id);
OldDevice device = _deviceService.GetById(deviceIn.id);
if (device == null)
throw new KeyNotFoundException("Device does not exist");
@ -235,7 +235,7 @@ namespace ManagerService.Controllers
device.Configuration = configuration.Label;
device.ConfigurationId = deviceIn.configurationId;
Device deviceModified = _deviceService.Update(device.Id, device);
OldDevice deviceModified = _deviceService.Update(device.Id, device);
MqttClientService.PublishMessage($"player/{device.Id}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));

View File

@ -17,17 +17,20 @@ namespace ManagerService.Controllers
[OpenApiTag("Instance", Description = "Instance management")]
public class InstanceController : ControllerBase
{
private readonly MyInfoMateDbContext _myInfoMateDbContext;
private InstanceDatabaseService _instanceService;
private UserDatabaseService _userService;
private readonly ILogger<InstanceController> _logger;
private readonly ProfileLogic _profileLogic;
public InstanceController(ILogger<InstanceController> logger, InstanceDatabaseService instanceService, UserDatabaseService userService, ProfileLogic profileLogic)
public InstanceController(ILogger<InstanceController> logger, InstanceDatabaseService instanceService, UserDatabaseService userService, ProfileLogic profileLogic, MyInfoMateDbContext myInfoMateDbContext)
{
_logger = logger;
_instanceService = instanceService;
_userService = userService;
_profileLogic = profileLogic;
_myInfoMateDbContext = myInfoMateDbContext;
}
/// <summary>
@ -40,7 +43,9 @@ namespace ManagerService.Controllers
{
try
{
List<Instance> instances = _instanceService.GetAll();
//List<OldInstance> instances = _instanceService.GetAll();
List<Instance> instances = _myInfoMateDbContext.Instances.ToList();
return new OkObjectResult(instances);
}
@ -63,7 +68,9 @@ namespace ManagerService.Controllers
{
try
{
Instance instance = _instanceService.GetById(id);
Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == id);
//OldInstance instance = _instanceService.GetById(id);
if (instance == null)
throw new KeyNotFoundException("This instance was not found");
@ -99,14 +106,18 @@ namespace ManagerService.Controllers
newInstance.DateCreation = DateTime.Now;
List<Instance> instances = _instanceService.GetAll();
/*List<OldInstance> instances = _instanceService.GetAll();
Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == id);*/
if (instances.Select(i => i.Name).Contains(newInstance.Name))
if (_myInfoMateDbContext.Instances.Any(i => i.Name == newInstance.Name))
throw new InvalidOperationException("This name is already used");
Instance instanceCreated = _instanceService.Create(newInstance);
//OldInstance instanceCreated = _instanceService.Create(newInstance);
_myInfoMateDbContext.Instances.Add(newInstance);
_myInfoMateDbContext.SaveChanges();
return new OkObjectResult(instanceCreated.ToDTO());
return new OkObjectResult(newInstance.ToDTO());
}
catch (ArgumentNullException ex)
{
@ -139,14 +150,17 @@ namespace ManagerService.Controllers
if (updatedInstance == null)
throw new ArgumentNullException("instance param is null");
Instance instance = _instanceService.GetById(updatedInstance.Id);
Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == updatedInstance.Id);
//OldInstance instance = _instanceService.GetById(updatedInstance.Id);
if (instance == null)
throw new KeyNotFoundException("instance does not exist");
Instance instanceModified = _instanceService.Update(updatedInstance.Id, instance);
instance = updatedInstance;
//OldInstance instanceModified = _instanceService.Update(updatedInstance.Id, instance);
_myInfoMateDbContext.SaveChanges();
return new OkObjectResult(instanceModified.ToDTO());
return new OkObjectResult(instance.ToDTO());
}
catch (ArgumentNullException ex)
{
@ -175,7 +189,7 @@ namespace ManagerService.Controllers
{
try
{
Instance instance = _instanceService.GetByPinCode(pinCode);
OldInstance instance = _instanceService.GetByPinCode(pinCode);
if (instance == null)
throw new KeyNotFoundException("Instance was not found");
@ -209,10 +223,10 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("instance param is null");
Instance instance = _instanceService.GetById(id);
OldInstance instance = _instanceService.GetById(id);
// Delete all user in instance
List<User> users = _userService.GetByInstanceId(instance.Id);
List<OldUser> users = _userService.GetByInstanceId(instance.Id);
foreach(var user in users)
{

View File

@ -50,7 +50,7 @@ namespace ManagerService.Controllers
{
if (instanceId == null)
throw new ArgumentNullException("InstanceId needed");
List<Resource> resources = new List<Resource>();
List<OldResource> resources = new List<OldResource>();
if (types.Count > 0)
{
resources = _resourceService.GetAllByType(instanceId, types);
@ -89,7 +89,7 @@ namespace ManagerService.Controllers
{
try
{
Resource resource = _resourceService.GetById(id);
OldResource resource = _resourceService.GetById(id);
if (resource == null)
throw new KeyNotFoundException("This resource was not found");
@ -149,7 +149,7 @@ namespace ManagerService.Controllers
{
try
{
Resource resource = _resourceService.GetById(id);
OldResource resource = _resourceService.GetById(id);
if (resource == null)
throw new KeyNotFoundException("This resource was not found");
@ -219,7 +219,7 @@ namespace ManagerService.Controllers
throw new ArgumentNullException("One of resource params is null");
var resourceType = (ResourceType)Enum.Parse(typeof(ResourceType), type);
List<Resource> resources = new List<Resource>();
List<OldResource> resources = new List<OldResource>();
foreach (var file in Request.Form.Files)
{
@ -250,12 +250,12 @@ namespace ManagerService.Controllers
throw new FileLoadException(message: "Fichier inexistant ou trop volumineux (max 4Mb)");
}
// Todo add some verification ?
Resource resource = new Resource();
OldResource resource = new OldResource();
resource.Label = label;
resource.Type = resourceType;
resource.DateCreation = DateTime.Now;
resource.InstanceId = instanceId;
Resource resourceCreated = _resourceService.Create(resource);
OldResource resourceCreated = _resourceService.Create(resource);
resources.Add(resourceCreated);
}
}
@ -296,7 +296,7 @@ namespace ManagerService.Controllers
throw new ArgumentNullException("Resource param is null");
// Todo add some verification ?
Resource resource = new Resource();
OldResource resource = new OldResource();
resource.InstanceId = newResource.instanceId;
resource.Label = newResource.label;
resource.Type = newResource.type;
@ -305,7 +305,7 @@ namespace ManagerService.Controllers
//resource.Data = newResource.data;
resource.InstanceId = newResource.instanceId;
Resource resourceCreated = _resourceService.Create(resource);
OldResource resourceCreated = _resourceService.Create(resource);
return new OkObjectResult(resourceCreated.ToDTO()); // WITHOUT DATA
}
@ -340,7 +340,7 @@ namespace ManagerService.Controllers
if (updatedResource == null)
throw new ArgumentNullException("Resource param is null");
Resource resource = _resourceService.GetById(updatedResource.id);
OldResource resource = _resourceService.GetById(updatedResource.id);
if (resource == null)
throw new KeyNotFoundException("Resource does not exist");
@ -352,7 +352,7 @@ namespace ManagerService.Controllers
resource.Url = updatedResource.url;
//resource.Data = updatedResource.data; // NOT ALLOWED
Resource resourceModified = _resourceService.Update(updatedResource.id, resource);
OldResource resourceModified = _resourceService.Update(updatedResource.id, resource);
return new OkObjectResult(resourceModified.ToDTO());
}
@ -428,8 +428,9 @@ namespace ManagerService.Controllers
foreach (var categorie in mapDTO.categories)
{
categorie.iconUrl = categorie.iconResourceId == id ? null : categorie.iconUrl;
categorie.iconResourceId = categorie.iconResourceId == id ? null : categorie.iconResourceId;
// TODO
/*categorie.iconUrl = categorie.iconResourceId == id ? null : categorie.iconUrl;
categorie.iconResourceId = categorie.iconResourceId == id ? null : categorie.iconResourceId;*/
}
section.Data = JsonConvert.SerializeObject(mapDTO);
break;
@ -444,14 +445,16 @@ namespace ManagerService.Controllers
sliderDTO.contents = contentsToKeep;
section.Data = JsonConvert.SerializeObject(sliderDTO);
break;
case SectionType.Quizz:
QuizzDTO quizzDTO = JsonConvert.DeserializeObject<QuizzDTO>(section.Data);
// TODO
/*case SectionType.Quizz:
QuizDTO quizzDTO = JsonConvert.DeserializeObject<QuizDTO>(section.Data);
foreach (var question in quizzDTO.questions)
{
if (question.label != null)
{
foreach (var questionLabel in question.label)
{
questionLabel.resourceUrl = questionLabel.resourceId == id ? null : questionLabel.resourceUrl;
questionLabel.resourceId = questionLabel.resourceId == id ? null : questionLabel.resourceId;
}
@ -517,7 +520,7 @@ namespace ManagerService.Controllers
}
}
section.Data = JsonConvert.SerializeObject(quizzDTO);
break;
break;*/
case SectionType.Article:
ArticleDTO articleDTO = JsonConvert.DeserializeObject<ArticleDTO>(section.Data);
List<ContentDTO> contentsArticleToKeep = new List<ContentDTO>();

View File

@ -2,6 +2,7 @@
using Manager.Helpers;
using Manager.Services;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -45,7 +46,7 @@ namespace ManagerService.Controllers
{
try
{
List<Section> sections = _sectionService.GetAll(instanceId);
List<OldSection> sections = _sectionService.GetAll(instanceId);
/* CLEAN ARTICLE AUDIO - Init new field AudioIds */
@ -93,7 +94,7 @@ namespace ManagerService.Controllers
if (_configurationService.IsExist(id))
{
List<Section> sections = _sectionService.GetAllFromConfiguration(id);
List<OldSection> sections = _sectionService.GetAllFromConfiguration(id);
return new OkObjectResult(sections.Select(r => r.ToDTO()));
}
@ -154,7 +155,7 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("Param is null");
List<Section> sections = _sectionService.GetAllSubSection(id);
List<OldSection> sections = _sectionService.GetAllSubSection(id);
return new OkObjectResult(sections.Select(r => r.ToDTO()));
}
@ -182,7 +183,7 @@ namespace ManagerService.Controllers
{
try
{
Section section = _sectionService.GetById(id);
OldSection section = _sectionService.GetById(id);
if (section == null)
throw new KeyNotFoundException("This section was not found");
@ -244,7 +245,7 @@ namespace ManagerService.Controllers
{
try
{
List<Section> sections = _sectionService.GetAll(instanceId);
List<OldSection> sections = _sectionService.GetAll(instanceId);
sections = sections.Where(s => s.IsBeacon && s.BeaconId != null).ToList();
@ -364,23 +365,23 @@ namespace ManagerService.Controllers
mapDTO.points = new List<GeoPointDTO>();
mapDTO.categories = new List<CategorieDTO>();
section.Data = JsonConvert.SerializeObject(mapDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(mapDTO); // Include all info from specific section as JSON
break;
case SectionType.Slider:
sliderDTO = new SliderDTO();
sliderDTO.contents = new List<ContentDTO>();
section.Data = JsonConvert.SerializeObject(sliderDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(sliderDTO); // Include all info from specific section as JSON
break;
case SectionType.Video:
VideoDTO videoDTO = new VideoDTO();
videoDTO.source = "";
section.Data = JsonConvert.SerializeObject(videoDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(videoDTO); // Include all info from specific section as JSON
break;
case SectionType.Web:
WebDTO webDTO = new WebDTO();
webDTO.source = "";
section.Data = JsonConvert.SerializeObject(webDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(webDTO); // Include all info from specific section as JSON
break;
case SectionType.Menu:
MenuDTO menuDTO = new MenuDTO();
@ -409,12 +410,12 @@ namespace ManagerService.Controllers
/*menuDTO.Sections.Add(section0DTO);
menuDTO.Sections.Add(section1DTO);*/
section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(menuDTO); // Include all info from specific section as JSON
break;
case SectionType.Quizz:
QuizzDTO quizzDTO = new QuizzDTO();
QuizDTO quizzDTO = new QuizDTO();
quizzDTO.questions = new List<QuestionDTO>();
section.Data = JsonConvert.SerializeObject(quizzDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(quizzDTO); // Include all info from specific section as JSON
break;
case SectionType.Article:
ArticleDTO articleDTO = new ArticleDTO();
@ -422,27 +423,28 @@ namespace ManagerService.Controllers
articleDTO.content = contentArticle.Select(c => c.ToDTO()).ToList(); // TODO check
articleDTO.audioIds = LanguageInit.Init("Audio", languages, true).Select(c => c.ToDTO()).ToList(); // TODO check
section.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(articleDTO); // Include all info from specific section as JSON
break;
case SectionType.PDF:
PdfDTO pdfDTO = new PdfDTO();
section.Data = JsonConvert.SerializeObject(pdfDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(pdfDTO); // Include all info from specific section as JSON
break;
case SectionType.Puzzle:
PuzzleDTO puzzleDTO = new PuzzleDTO();
section.Data = JsonConvert.SerializeObject(puzzleDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(puzzleDTO); // Include all info from specific section as JSON
break;
case SectionType.Agenda:
AgendaDTO agendaDTO = new AgendaDTO();
section.Data = JsonConvert.SerializeObject(agendaDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(agendaDTO); // Include all info from specific section as JSON
break;
case SectionType.Weather:
WeatherDTO weatherDTO = new WeatherDTO();
section.Data = JsonConvert.SerializeObject(weatherDTO); // Include all info from specific section as JSON
//section.Data = JsonConvert.SerializeObject(weatherDTO); // Include all info from specific section as JSON
break;
}
Section sectionCreated = _sectionService.Create(section);
// TODO
OldSection sectionCreated = new OldSection();//_sectionService.Create(section);
return new OkObjectResult(sectionCreated.ToDTO());
}
@ -528,13 +530,13 @@ namespace ManagerService.Controllers
if (updatedSection == null)
throw new ArgumentNullException("Section param is null");
Section section = _sectionService.GetById(updatedSection.id);
OldSection section = _sectionService.GetById(updatedSection.id);
if (section == null)
throw new KeyNotFoundException("Section does not exist");
// Todo add some verification ?
section.InstanceId = updatedSection.instanceId;
/*section.InstanceId = updatedSection.instanceId;
section.Label = updatedSection.label;
section.Title = updatedSection.title.Select(t => new Translation().FromDTO(t)).ToList(); // TODO CHECK
section.Description = updatedSection.description.Select(t => new Translation().FromDTO(t)).ToList();// TODO CHECK
@ -551,7 +553,9 @@ namespace ManagerService.Controllers
section.Longitude = updatedSection.longitude;
section.MeterZoneGPS = updatedSection.meterZoneGPS;
Section sectionModified = _sectionService.Update(updatedSection.id, section);
Section sectionModified = _sectionService.Update(updatedSection.id, section);*/
// todo
Section sectionModified = new Section();
MqttClientService.PublishMessage($"config/{sectionModified.ConfigurationId}", JsonConvert.SerializeObject(new PlayerMessageDTO() { configChanged = true }));
@ -595,7 +599,7 @@ namespace ManagerService.Controllers
foreach (var updatedSection in updatedSectionsOrder)
{
Section section = _sectionService.GetById(updatedSection.id);
OldSection section = _sectionService.GetById(updatedSection.id);
section.Order = updatedSection.order.GetValueOrDefault();
_sectionService.Update(section.Id, section);
@ -723,11 +727,11 @@ namespace ManagerService.Controllers
/// <summary>
/// Useless, just to generate dto code
/// </summary>
[ProducesResponseType(typeof(QuizzDTO), 200)]
[HttpGet("QuizzDTO")]
public ObjectResult GetQuizzDTO()
[ProducesResponseType(typeof(QuizDTO), 200)]
[HttpGet("QuizDTO")]
public ObjectResult GetQuizDTO()
{
return new ObjectResult("QuizzDTO") { StatusCode = 200 };
return new ObjectResult("QuizDTO") { StatusCode = 200 };
}
/// <summary>

View File

@ -41,7 +41,7 @@ namespace ManagerService.Controllers
{
try
{
List<User> users = _userService.GetAll();
List<OldUser> users = _userService.GetAll();
return new OkObjectResult(users);
}
@ -64,7 +64,7 @@ namespace ManagerService.Controllers
{
try
{
User user = _userService.GetById(id);
OldUser user = _userService.GetById(id);
if (user == null)
throw new KeyNotFoundException("This user was not found");
@ -91,7 +91,7 @@ namespace ManagerService.Controllers
[ProducesResponseType(typeof(string), 409)]
[ProducesResponseType(typeof(string), 500)]
[HttpPost]
public ObjectResult CreateUser([FromBody] User newUser)
public ObjectResult CreateUser([FromBody] OldUser newUser)
{
try
{
@ -104,14 +104,14 @@ namespace ManagerService.Controllers
newUser.Token = _tokenService.GenerateToken(newUser.Email).ToString();
newUser.DateCreation = DateTime.Now;
List<User> users = _userService.GetAll();
List<OldUser> users = _userService.GetAll();
if (users.Select(u => u.Email).Contains(newUser.Email))
throw new InvalidOperationException("This Email is already used");
newUser.Password = _profileLogic.HashPassword(newUser.Password);
User userCreated = _userService.Create(newUser);
OldUser userCreated = _userService.Create(newUser);
return new OkObjectResult(userCreated.ToDTO());
}
@ -139,19 +139,19 @@ namespace ManagerService.Controllers
[ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)]
[HttpPut]
public ObjectResult UpdateUser([FromBody] User updatedUser)
public ObjectResult UpdateUser([FromBody] OldUser updatedUser)
{
try
{
if (updatedUser == null)
throw new ArgumentNullException("User param is null");
User user = _userService.GetById(updatedUser.Id);
OldUser user = _userService.GetById(updatedUser.Id);
if (user == null)
throw new KeyNotFoundException("User does not exist");
User userModified = _userService.Update(updatedUser.Id, updatedUser);
OldUser userModified = _userService.Update(updatedUser.Id, updatedUser);
return new OkObjectResult(userModified.ToDTO());
}
@ -186,7 +186,7 @@ namespace ManagerService.Controllers
if (id == null)
throw new ArgumentNullException("User param is null");
User user = _userService.GetById(id);
OldUser user = _userService.GetById(id);
if (user == null)
throw new KeyNotFoundException("User does not exist");

View File

@ -0,0 +1,29 @@
using ManagerService.Data;
using System;
using System.Collections.Generic;
namespace ManagerService.DTOs
{
public class OldSectionDTO
{
public string id { get; set; }
public string label { get; set; } // use in manager
public List<TranslationDTO> title { get; set; }
public List<TranslationDTO> 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
public string instanceId { get; set; }
public string latitude { get; set; } // MyVisit - Use to launch automatic content when current location is near
public string longitude { get; set; } // MyVisit - Use to launch automatic content when current location is near
public int? meterZoneGPS { get; set; } // MyVisit - Nbr of meters of the zone to launch content
public bool isBeacon { get; set; } // MyVisit - True if section use beacon, false otherwise
public int? beaconId { get; set; } // MyVisit - Beacon' identifier
}
}

View File

@ -0,0 +1,14 @@

using ManagerService.Data;
namespace ManagerService.DTOs
{
public class OldTranslationAndResourceDTO
{
public string language { get; set; }
public string value { get; set; }
public string resourceId { get; set; } // question image, audio or video
public ResourceType? resourceType { get; set; }
public string resourceUrl { get; set; } // url to firebase storage or on internet
}
}

View File

@ -0,0 +1,11 @@

using System.Collections.Generic;
namespace ManagerService.DTOs
{
public class OrderedTranslationAndResourceDTO
{
public List<TranslationAndResourceDTO> translationAndResourceDTOs { get; set; }
public int order { get; set; }
}
}

View File

@ -16,7 +16,6 @@ namespace ManagerService.DTOs
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
public string instanceId { get; set; }

View File

@ -0,0 +1,17 @@
namespace ManagerService.DTOs
{
public enum SectionType
{
Map,
Slider,
Video,
Web,
Menu,
Quizz,
Article,
PDF,
Puzzle,
Agenda,
Weather
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Manager.DTOs
{
public class AgendaDTO
public class AgendaDTO : SectionDTO
{
public List<TranslationDTO> resourceIds { get; set; } // All json files for all languages
public MapProvider? mapProvider { get; set; } // Default = Google

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Manager.DTOs
{
public class ArticleDTO
public class ArticleDTO : SectionDTO
{
public List<TranslationDTO> content { get; set; }
public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace Manager.DTOs
{
public class MapDTO
public class MapDTO : SectionDTO
{
public int zoom { get; set; } // Default = 18
public MapTypeApp? mapType { get; set; } // Default = Hybrid for Google
@ -15,8 +15,8 @@ namespace Manager.DTOs
public string iconResourceId { get; set; }
public string iconSource { get; set; } // url to firebase storage or on internet
public List<CategorieDTO> categories { get; set; }
public string latitude { get; set; } // Center on
public string longitude { get; set; } // Center on
public string centerLatitude { get; set; } // Center on
public string centerLongitude { get; set; } // Center on
}
public class GeoPointDTO
@ -40,11 +40,10 @@ namespace Manager.DTOs
public class CategorieDTO
{
public int? id { get; set; }
public int id { get; set; }
public List<TranslationDTO> label { get; set; }
public string icon { get; set; } // icon material
public string iconResourceId { get; set; } // icon point geo
public string iconUrl { get; set; } // url to firebase storage or on internet
public ResourceDTO resourceDTO { get; set; } // Icon
public int? order { get; set; } // Order to show
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Manager.DTOs
{
public class MenuDTO
public class MenuDTO : SectionDTO
{
//public string Title { get; set; } // Dictionary<string, object> with all languages
public List<SectionDTO> sections { get; set; }

View File

@ -0,0 +1,11 @@
using ManagerService.DTOs;
using System.Collections.Generic;
namespace Manager.DTOs
{
public class OldAgendaDTO
{
public List<TranslationDTO> resourceIds { get; set; } // All json files for all languages
public MapProvider? mapProvider { get; set; } // Default = Google
}
}

View File

@ -0,0 +1,14 @@
using ManagerService.DTOs;
using System.Collections.Generic;
namespace Manager.DTOs
{
public class OldArticleDTO
{
public List<TranslationDTO> content { get; set; }
public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise
public List<TranslationDTO> audioIds { get; set; }
public bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise
public List<ContentDTO> contents { get; set; }
}
}

View File

@ -0,0 +1,58 @@
using Manager.Interfaces.Models;
using ManagerService.Data;
using ManagerService.DTOs;
using System.Collections.Generic;
namespace Manager.DTOs
{
public class OldMapDTO
{
public int zoom { get; set; } // Default = 18
public MapTypeApp? mapType { get; set; } // Default = Hybrid for Google
public MapTypeMapBox? mapTypeMapbox { get; set; } // Default = standard for MapBox
public MapProvider? mapProvider { get; set; } // Default = Google
public List<OldGeoPointDTO> points { get; set; }
public string iconResourceId { get; set; }
public string iconSource { get; set; } // url to firebase storage or on internet
public List<OldCategorieDTO> categories { get; set; }
public string latitude { get; set; } // Center on
public string longitude { get; set; } // Center on
}
public class OldGeoPointDTO
{
public int? id { get; set; }
public List<TranslationDTO> title { get; set; }
public List<TranslationDTO> description { get; set; }
public List<OldContentGeoPoint> contents { get; set; }
public OldCategorieDTO categorie { get; set; } // TO DELETE IN FUTURE
public int? categorieId { get; set; }
public string latitude { get; set; }
public string longitude { get; set; }
public string imageResourceId { get; set; }
public string imageUrl { get; set; }
public List<TranslationDTO> schedules { get; set; }
public List<TranslationDTO> prices { get; set; }
public List<TranslationDTO> phone { get; set; }
public List<TranslationDTO> email { get; set; }
public List<TranslationDTO> site { get; set; }
}
public class OldCategorieDTO
{
public int? id { get; set; }
public List<TranslationDTO> label { get; set; }
public string icon { get; set; } // icon material
public string iconResourceId { get; set; } // icon point geo
public string iconUrl { get; set; } // url to firebase storage or on internet
public int? order { get; set; } // Order to show
}
public class OldContentGeoPoint
{
public string resourceId { get; set; }
public ResourceType resourceType { get; set; }
public string resourceUrl { get; set; } // url to firebase storage or on internet
public string resourceName { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using ManagerService.DTOs;
using System.Collections.Generic;
namespace Manager.DTOs
{
public class OldMenuDTO
{
//public string Title { get; set; } // Dictionary<string, object> with all languages
public List<OldSectionDTO> sections { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using ManagerService.DTOs;
using System.Collections.Generic;
namespace Manager.DTOs
{
public class OldPdfDTO
{
public List<OldPDFFileDTO> pdfs { get; set; }
}
public class OldPDFFileDTO
{
public List<TranslationAndResourceDTO> pdfFilesAndTitles { get; set; }
public int? order { get; set; } // Order to show
}
}

View File

@ -0,0 +1,14 @@
using ManagerService.DTOs;
using System.Collections.Generic;
namespace Manager.DTOs
{
public class OldPuzzleDTO
{
public List<TranslationAndResourceDTO> messageDebut { get; set; }
public List<TranslationAndResourceDTO> messageFin { get; set; }
public ContentDTO image { get; set; } // But only image is possible
public int rows { get; set; } = 3;
public int cols { get; set; } = 3;
}
}

View File

@ -0,0 +1,37 @@
using ManagerService.DTOs;
using System.Collections.Generic;
using System.Security.AccessControl;
namespace Manager.DTOs
{
public class OldQuizzDTO
{
public List<OldQuestionDTO> questions { get; set; }
public OldLevelDTO bad_level { get; set; }
public OldLevelDTO medium_level { get; set; }
public OldLevelDTO good_level { get; set; }
public OldLevelDTO great_level { get; set; }
}
public class OldQuestionDTO
{
public List<TranslationAndResourceDTO> label { get; set; }
public List<OldResponseDTO> responses { get; set; }
public string imageBackgroundResourceId { get; set; } // question image background
public ResourceType? imageBackgroundResourceType { get; set; }
public string imageBackgroundResourceUrl { get; set; } // url to firebase storage or on internet
public int order { get; set; } // Order to show
}
public class OldResponseDTO
{
public List<TranslationAndResourceDTO> label { get; set; }
public bool isGood { get; set; }
public int order { get; set; } // Order to show
}
public class OldLevelDTO
{
public List<TranslationAndResourceDTO> label { get; set; }
}
}

View File

@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace Manager.DTOs
{
public class OldSliderDTO
{
public List<ContentDTO> contents { get; set; }
}
}

View File

@ -0,0 +1,8 @@
namespace Manager.DTOs
{
public class OldVideoDTO
{
//public string Title { get; set; } // Dictionary<string, object> with all languages
public string source { get; set; } // url to resource id (local) or on internet
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Manager.DTOs
{
public class OldWeatherDTO
{
public string city { get; set; } // Weather City
public DateTimeOffset? updatedDate { get; set; } // Weather date update (to only refresh)
public string result { get; set; } // Weather result
}
}

View File

@ -0,0 +1,8 @@
namespace Manager.DTOs
{
public class OldWebDTO
{
//public string Title { get; set; } // Dictionary<string, object> with all languages
public string source { get; set; } // url to resource id (local) or on internet
}
}

View File

@ -3,14 +3,8 @@ using System.Collections.Generic;
namespace Manager.DTOs
{
public class PdfDTO
public class PdfDTO : SectionDTO
{
public List<PDFFileDTO> pdfs { get; set; }
}
public class PDFFileDTO
{
public List<TranslationAndResourceDTO> pdfFilesAndTitles { get; set; }
public int? order { get; set; } // Order to show
public List<OrderedTranslationAndResourceDTO> pdfs { get; set; }
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Manager.DTOs
{
public class PuzzleDTO
public class PuzzleDTO : SectionDTO
{
public List<TranslationAndResourceDTO> messageDebut { get; set; }
public List<TranslationAndResourceDTO> messageFin { get; set; }

View File

@ -4,7 +4,7 @@ using System.Security.AccessControl;
namespace Manager.DTOs
{
public class QuizzDTO
public class QuizDTO : SectionDTO
{
public List<QuestionDTO> questions { get; set; }
public LevelDTO bad_level { get; set; }

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Manager.DTOs
{
public class SliderDTO
public class SliderDTO : SectionDTO
{
public List<ContentDTO> contents { get; set; }
}
@ -13,9 +13,8 @@ namespace Manager.DTOs
{
public List<TranslationDTO> title { get; set; }
public List<TranslationDTO> description { get; set; }
public string resourceId { get; set; }
public string resourceUrl { get; set; } // url to firebase storage or on internet
public int order { get; set; } // Order to show
public ResourceType resourceType { get; set; }
public string resourceId { get; set; }
public ResourceDTO resource { get; set; }
}
}

View File

@ -1,6 +1,8 @@
namespace Manager.DTOs
using ManagerService.DTOs;
namespace Manager.DTOs
{
public class VideoDTO
public class VideoDTO : SectionDTO
{
//public string Title { get; set; } // Dictionary<string, object> with all languages
public string source { get; set; } // url to resource id (local) or on internet

View File

@ -1,8 +1,9 @@
using System;
using ManagerService.DTOs;
using System;
namespace Manager.DTOs
{
public class WeatherDTO
public class WeatherDTO : SectionDTO
{
public string city { get; set; } // Weather City
public DateTimeOffset? updatedDate { get; set; } // Weather date update (to only refresh)

View File

@ -1,6 +1,8 @@
namespace Manager.DTOs
using ManagerService.DTOs;
namespace Manager.DTOs
{
public class WebDTO
public class WebDTO : SectionDTO
{
//public string Title { get; set; } // Dictionary<string, object> with all languages
public string source { get; set; } // url to resource id (local) or on internet

View File

@ -7,8 +7,7 @@ namespace ManagerService.DTOs
{
public string language { get; set; }
public string value { get; set; }
public string resourceId { get; set; } // question image, audio or video
public ResourceType? resourceType { get; set; }
public string resourceUrl { get; set; } // url to firebase storage or on internet
public string resourceId { get; set; }
public ResourceDTO resource { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using ManagerService.DTOs;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;

View File

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using ManagerService.Data.SubSection;
using Microsoft.EntityFrameworkCore;
namespace ManagerService.Data
{
@ -20,6 +21,21 @@ namespace ManagerService.Data
.Property(s => s.Title)
.HasColumnType("jsonb");
modelBuilder.Entity<Section>()
.HasDiscriminator<string>("Discriminator")
.HasValue<Section>("Base")
.HasValue<SectionAgenda>("Agenda")
.HasValue<SectionArticle>("Article")
.HasValue<SectionMap>("Map")
.HasValue<SectionMenu>("Menu")
.HasValue<SectionPdf>("PDF")
.HasValue<SectionPuzzle>("Puzzle")
.HasValue<SectionQuiz>("Quiz")
.HasValue<SectionSlider>("Slider")
.HasValue<SectionVideo>("Video")
.HasValue<SectionWeather>("Weather")
.HasValue<SectionWeb>("Web");
modelBuilder.Entity<Section>()
.Property(s => s.Title)
.HasColumnType("jsonb");

View File

@ -0,0 +1,147 @@
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
namespace ManagerService.Data
{
/// <summary>
/// Configuration Information
/// </summary>
public class OldConfiguration
{
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Label")]
[BsonRequired]
public string Label { get; set; }
[BsonElement("Title")]
[BsonRequired]
public List<TranslationDTO> Title { get; set; }
[BsonElement("ImageId")]
public string ImageId { get; set; }
[BsonElement("ImageSource")]
public string ImageSource { get; set; }
[BsonElement("PrimaryColor")]
public string PrimaryColor { get; set; }
[BsonElement("SecondaryColor")]
public string SecondaryColor { get; set; }
[BsonElement("Languages")]
public List<string> Languages { get; set; } // fr, en, de, nl => Sélection dans une liste déjà établie dans l'application !
[BsonElement("DateCreation")]
public DateTime DateCreation { get; set; }
[BsonElement("IsMobile")]
public bool IsMobile { get; set; }
[BsonElement("IsTablet")]
public bool IsTablet { get; set; }
[BsonElement("IsOffline")]
public bool IsOffline { get; set; }
[BsonElement("InstanceId")]
[BsonRequired]
public string InstanceId { get; set; }
[BsonElement("LoaderImageId")]
public string LoaderImageId { get; set; }
[BsonElement("LoaderImageUrl")]
public string LoaderImageUrl { get; set; }
[BsonElement("WeatherCity")]
public string WeatherCity { get; set; }
[BsonElement("WeatherUpdatedDate")]
public DateTimeOffset? WeatherUpdatedDate { get; set; }
[BsonElement("WeatherResult")]
public string WeatherResult { get; set; }
[BsonElement("IsDate")]
public bool IsDate { get; set; }
[BsonElement("IsHour")]
public bool IsHour { get; set; }
[BsonElement("IsSectionImageBackground")]
public bool IsSectionImageBackground { get; set; }
[BsonElement("RoundedValue")]
public int? RoundedValue { get; set; }
[BsonElement("ScreenPercentageSectionsMainPage")]
public int? ScreenPercentageSectionsMainPage { get; set; }
public ConfigurationDTO ToDTO(List<string> sectionIds)
{
return new ConfigurationDTO()
{
id = Id,
label = Label,
title = Title,
imageId = ImageId,
imageSource = ImageSource,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
weatherUpdatedDate = WeatherUpdatedDate,
weatherResult = WeatherResult,
dateCreation = DateCreation,
primaryColor = PrimaryColor,
languages = Languages,
secondaryColor = SecondaryColor,
isMobile = IsMobile,
isTablet = IsTablet,
isOffline = IsOffline,
instanceId = InstanceId,
isDate = IsDate,
isHour = IsHour,
isSectionImageBackground = IsSectionImageBackground,
roundedValue = RoundedValue,
screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
sectionIds = sectionIds
};
}
public ExportConfigurationDTO ToExportDTO(List<SectionDTO> sections, List<ResourceDTO> resources) {
return new ExportConfigurationDTO()
{
id = Id,
label = Label,
title= Title,
imageId = ImageId,
imageSource = ImageSource,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
dateCreation = DateCreation,
primaryColor = PrimaryColor,
languages = Languages,
secondaryColor = SecondaryColor,
isMobile = IsMobile,
isTablet = IsTablet,
isOffline = IsOffline,
sections = sections,
resources = resources,
instanceId = InstanceId,
isDate = IsDate,
isSectionImageBackground = IsSectionImageBackground,
roundedValue = RoundedValue,
screenPercentageSectionsMainPage = ScreenPercentageSectionsMainPage,
sectionIds = sections.Select(s => s.id).ToList()
};
}
}
}

View File

@ -0,0 +1,107 @@
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.ComponentModel.DataAnnotations;
namespace ManagerService.Data
{
/// <summary>
/// Device Information (Tablet)
/// </summary>
public class OldDevice
{
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Identifier")]
public string Identifier { get; set; }
[BsonElement("Name")]
public string Name { get; set; }
[BsonElement("IpAddressWLAN")]
[BsonRequired]
public string IpAddressWLAN { get; set; }
[BsonElement("IpAddressETH")]
[BsonRequired]
[Required]
public string IpAddressETH { get; set; }
[BsonElement("Configuration")]
public string Configuration { get; set; }
[BsonElement("ConfigurationId")]
[BsonRequired]
public string ConfigurationId { get; set; }
[BsonElement("Connected")]
[BsonRequired]
public bool Connected { get; set; }
[BsonElement("DateCreation")]
public DateTime DateCreation { get; set; }
[BsonElement("DateUpdate")]
public DateTime DateUpdate { get; set; }
// BatteryLevel in case of powered devices
[BsonElement("BatteryLevel")]
public string BatteryLevel { get; set; }
[BsonElement("LastBatteryLevel")]
public DateTime LastBatteryLevel { get; set; }
// ConnectionLevel wifi strength level
[BsonElement("ConnectionLevel")]
public string ConnectionLevel { get; set; }
[BsonElement("LastConnectionLevel")]
public DateTime LastConnectionLevel { get; set; }
[BsonElement("InstanceId")]
[BsonRequired]
public string InstanceId { get; set; }
public DeviceDTO ToDTO()
{
return new DeviceDTO()
{
id = Id,
identifier = Identifier,
name = Name,
ipAddressWLAN = IpAddressWLAN,
ipAddressETH = IpAddressETH,
connected = Connected,
configuration = Configuration,
configurationId = ConfigurationId,
dateUpdate = DateUpdate,
dateCreation = DateCreation,
instanceId = InstanceId
};
}
public DeviceDetailDTO ToDetailDTO()
{
return new DeviceDetailDTO()
{
id = Id,
identifier = Identifier,
name = Name,
ipAddressWLAN = IpAddressWLAN,
ipAddressETH = IpAddressETH,
connected = Connected,
configuration = Configuration,
configurationId = ConfigurationId,
connectionLevel = ConnectionLevel,
lastConnectionLevel = LastConnectionLevel,
batteryLevel = BatteryLevel,
lastBatteryLevel = LastBatteryLevel,
dateUpdate = DateUpdate,
dateCreation = DateCreation,
instanceId = InstanceId
};
}
}
}

View File

@ -0,0 +1,39 @@
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.ComponentModel.DataAnnotations;
namespace ManagerService.Data
{
/// <summary>
/// Instance Information
/// </summary>
public class OldInstance
{
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Name")]
[BsonRequired]
public string Name { get; set; } // UNIQUE !..
[BsonElement("DateCreation")]
public DateTime DateCreation { get; set; }
[BsonElement("PinCode")]
public int? PinCode { get; set; }
public InstanceDTO ToDTO()
{
return new InstanceDTO()
{
id = Id,
name = Name,
dateCreation = DateCreation,
pinCode = PinCode
};
}
}
}

View File

@ -0,0 +1,48 @@
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.ComponentModel.DataAnnotations;
namespace ManagerService.Data
{
/// <summary>
/// Resource Information
/// </summary>
public class OldResource
{
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Type")]
[BsonRequired]
public ResourceType Type { get; set; }
[BsonElement("Label")]
[BsonRequired]
public string Label { get; set; }
[BsonElement("DateCreation")]
public DateTime DateCreation { get; set; }
[BsonElement("InstanceId")]
[BsonRequired]
public string InstanceId { get; set; }
[BsonElement("URL")]
public string Url { get; set; } // Firebase url
public ResourceDTO ToDTO()
{
return new ResourceDTO()
{
id = Id,
label = Label,
type = Type,
url = Url,
dateCreation = DateCreation,
instanceId = InstanceId
};
}
}
}

View File

@ -0,0 +1,110 @@
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data
{
/// <summary>
/// Section Information
/// </summary>
public class OldSection
{
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Label")]
[BsonRequired]
public string Label { get; set; } // Use in manager
[BsonElement("Title")]
[BsonRequired]
public List<TranslationDTO> Title { get; set; }
[BsonElement("Description")]
public List<TranslationDTO> Description { get; set; }
[BsonElement("Order")]
public int Order { get; set; }
[BsonElement("ConfigurationId")]
[BsonRequired]
public string ConfigurationId { get; set; } // Parent id
[BsonElement("ImageId")]
[BsonRequired]
public string ImageId { get; set; }
[BsonElement("ImageSource")]
[BsonRequired]
public string ImageSource { get; set; }
[BsonElement("Type")]
[BsonRequired]
public SectionType Type { get; set; }
[BsonElement("IsSubSection")]
[BsonRequired]
public bool IsSubSection { get; set; }
[BsonElement("ParentId")]
public string ParentId { get; set; } // only if it's an subsection
[BsonElement("DateCreation")]
public DateTime DateCreation { get; set; }
[BsonElement("Data")]
[BsonRequired]
public string Data { get; set; } // Json encapsulated section info
[BsonElement("InstanceId")]
[BsonRequired]
public string InstanceId { get; set; }
[BsonElement("IsBeacon")]
public bool IsBeacon { get; set; }
[BsonElement("BeaconId")]
public int? BeaconId { get; set; }
[BsonElement("Latitude")]
public string Latitude { get; set; }
[BsonElement("Longitude")]
public string Longitude { get; set; }
[BsonElement("MeterZoneGPS")]
public int? MeterZoneGPS { get; set; }
public SectionDTO ToDTO()
{
return new SectionDTO()
{
id = Id,
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,
//data = Data,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
};
}
}
}

View File

@ -0,0 +1,56 @@
using ManagerService.DTOs;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.ComponentModel.DataAnnotations;
namespace ManagerService.Data
{
/// <summary>
/// User Information
/// </summary>
public class OldUser
{
[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
public string Id { get; set; }
[BsonElement("Email")]
[BsonRequired]
public string Email { get; set; } // UNIQUE !..
[BsonElement("Password")]
[BsonRequired]
public string Password { get; set; }
[BsonElement("FirstName")]
[BsonRequired]
public string FirstName { get; set; }
[BsonElement("LastName")]
[BsonRequired]
public string LastName { get; set; }
[BsonElement("Token")]
[BsonRequired]
public string Token { get; set; }
[BsonElement("DateCreation")]
public DateTime DateCreation { get; set; }
[BsonElement("InstanceId")]
[BsonRequired]
public string InstanceId { get; set; }
public UserDetailDTO ToDTO()
{
return new UserDetailDTO()
{
id = Id,
email = Email,
firstName = FirstName,
lastName = LastName,
};
}
}
}

View File

@ -1,4 +1,5 @@
using ManagerService.DTOs;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -15,82 +16,50 @@ namespace ManagerService.Data
{
[Key]
[Required]
/*[BsonId]
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]*/
public string Id { get; set; }
//[BsonElement("Label")]
//[BsonRequired]
[Required]
public string Label { get; set; } // Use in manager
//[BsonElement("Title")]
//[BsonRequired]
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> Title { get; set; }
//[BsonElement("Description")]
[Column(TypeName = "jsonb")]
public List<Translation> Description { get; set; }
//[BsonElement("Order")]
public int Order { get; set; }
//[BsonElement("ConfigurationId")]
//[BsonRequired]
[Required]
public string ConfigurationId { get; set; } // Parent id
//[BsonElement("ImageId")]
//[BsonRequired]
[Required]
public string ImageId { get; set; }
//[BsonElement("ImageSource")]
//[BsonRequired]
[Required]
public string ImageSource { get; set; }
//[BsonElement("Type")]
//[BsonRequired]
[Required]
public SectionType Type { get; set; }
//[BsonElement("IsSubSection")]
//[BsonRequired]
[Required]
public bool IsSubSection { get; set; }
//[BsonElement("ParentId")]
public string ParentId { get; set; } // only if it's an subsection
//[BsonElement("DateCreation")]
public DateTime DateCreation { get; set; }
//[BsonElement("Data")]
//[BsonRequired]
[Required]
public string Data { get; set; } // Json encapsulated section info
//[BsonElement("InstanceId")]
//[BsonRequired]
[Required]
public string InstanceId { get; set; }
//[BsonElement("IsBeacon")]
public bool IsBeacon { get; set; }
//[BsonElement("BeaconId")]
public int? BeaconId { get; set; }
//[BsonElement("Latitude")]
public string Latitude { get; set; }
//[BsonElement("Longitude")]
public string Longitude { get; set; }
//[BsonElement("MeterZoneGPS")]
public int? MeterZoneGPS { get; set; }
public SectionDTO ToDTO()
@ -108,7 +77,6 @@ namespace ManagerService.Data
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
data = Data,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
@ -119,19 +87,4 @@ namespace ManagerService.Data
};
}
}
public enum SectionType
{
Map,
Slider,
Video,
Web,
Menu,
Quizz,
Article,
PDF,
Puzzle,
Agenda,
Weather
}
}

View File

@ -0,0 +1,56 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Categorie
/// </summary>
public class Categorie
{
[Key]
[Required]
public int Id { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> Label { get; set; }
public string Icon { get; set; } // icon material
public string ResourceId { get; set; }
public Resource Resource { get; set; } // icon
public int? Order { get; set; } // Order to show
public CategorieDTO ToDTO()
{
return new CategorieDTO()
{
id = Id,
label = Label.OrderBy(l => l.Language).Select(l => l.ToDTO()).ToList(),
icon = Icon,
order = Order,
resourceDTO = Resource.ToDTO()
};
}
public Categorie FromDTO(CategorieDTO categorieDTO)
{
return new Categorie()
{
Id = categorieDTO.id,
// TODO
/*Label = categorieDTO.label,
*/
};
}
}
}

View File

@ -0,0 +1,56 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Content
/// </summary>
public class Content
{
[Key]
[Required]
public int Id { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> Title { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> Description { get; set; }
public string ResourceId { get; set; }
public Resource Resource { get; set; }
public int Order { get; set; } // Order to show
public ContentDTO ToDTO()
{
return new ContentDTO()
{
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
resourceId = ResourceId,
resource = Resource.ToDTO()
};
}
public Content FromDTO(ContentDTO contentDTO)
{
return new Content()
{
Title = contentDTO.title.Select(t => new Translation().FromDTO(t)).ToList(),
Description = contentDTO.description.Select(t => new Translation().FromDTO(t)).ToList(),
Order = contentDTO.order,
ResourceId = contentDTO.resourceId
};
}
}
}

View File

@ -0,0 +1,44 @@
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Ordered translationAndResource
/// </summary>
public class OrderedTranslationAndResource
{
[Key]
[Required]
public int Id { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> TranslationAndResources { get; set; }
public int Order { get; set; } // Order to show
public OrderedTranslationAndResourceDTO ToDTO()
{
return new OrderedTranslationAndResourceDTO()
{
translationAndResourceDTOs = TranslationAndResources.Select(tar => tar.ToDTO()).ToList(),
order = Order
};
}
public OrderedTranslationAndResource FromDTO(OrderedTranslationAndResourceDTO orderedTranslationAndResourceDTO)
{
return new OrderedTranslationAndResource()
{
TranslationAndResources = orderedTranslationAndResourceDTO.translationAndResourceDTOs.Select(tar => new TranslationAndResource().FromDTO(tar)).ToList(),
Order = orderedTranslationAndResourceDTO.order
};
}
}
}

View File

@ -0,0 +1,52 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Quiz question
/// </summary>
public class QuizQuestion
{
[Key]
[Required]
public int Id { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResourceDTO> Label { get; set; }
public string ResourceId { get; set; } // Background image id
public Resource Resource { get; set; } // Background image
public int Order { get; set; } // Order to show
[Required]
[Column(TypeName = "jsonb")]
public List<ResponseDTO> Responses { get; set; } // TODO check
// TODO
/*public TranslationDTO ToDTO()
{
return new TranslationDTO()
{
language = Language,
value = Value
};
}
public Translation FromDTO(TranslationDTO translationDTO)
{
return new Translation()
{
Language = translationDTO.language,
Value = translationDTO.value
};
}*/
}
}

View File

@ -0,0 +1,50 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section agenda
/// </summary>
public class SectionAgenda : Section
{
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> resourceIds { get; set; } // All json files for all languages
public MapProvider? mapProvider { get; set; } // Default = Google
public AgendaDTO ToDTO()
{
return new AgendaDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
resourceIds = resourceIds.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
mapProvider = mapProvider
};
}
}
}

View File

@ -0,0 +1,62 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section article
/// </summary>
public class SectionArticle: Section
{
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> content { get; set; }
public bool isContentTop { get; set; } // MyVisit - True if content is displayed at top, false otherwise
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> audioIds { get; set; }
public bool isReadAudioAuto { get; set; } // MyVisit - True for audio play when open the article / false otherwise
[Required]
public List<Content> contents { get; set; }
public ArticleDTO ToDTO()
{
return new ArticleDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
content = content.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
isContentTop = isContentTop,
audioIds = audioIds.Select(a=> a.ToDTO()).ToList(),
isReadAudioAuto = isReadAudioAuto,
contents = contents.Select(c => c.ToDTO()).ToList(),
};
}
}
}

View File

@ -0,0 +1,112 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section map
/// </summary>
public class SectionMap : Section
{
public int Zoom { get; set; } // Default = 18
public MapTypeApp? MapType { get; set; } // Default = Hybrid for Google
public MapTypeMapBox? MapTypeMapbox { get; set; } // Default = standard for MapBox
public MapProvider? MapProvider { get; set; } // Default = Google
public List<GeoPoint> Points { get; set; }
public string ResourceId { get; set; }
public Resource Resource { get; set; } // Icon
public List<Categorie> Categories { get; set; }
public string CenterLatitude { get; set; } // Center on
public string CenterLongitude { get; set; } // Center on
public MapDTO ToDTO()
{
return new MapDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
zoom = Zoom,
mapType = MapType,
mapTypeMapbox = MapTypeMapbox,
mapProvider = MapProvider,
//points = Points.Select(p => p.ToDTO()).ToList(), // TODO
iconResourceId = ResourceId,
categories = Categories.Select(c => c.ToDTO()).ToList(),
centerLatitude = CenterLatitude,
centerLongitude = CenterLongitude
};
}
}
public class GeoPoint
{
[Required]
public int? Id { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> Title { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<Translation> Description { get; set; }
//TODO
[Required]
[Column(TypeName = "jsonb")]
public List<Resource> Contents { get; set; } // Contentsgeopoint
public int? CategorieId { get; set; }
public string Latitude { get; set; }
public string Longitude { get; set; }
public string ImageResourceId { get; set; }
public string ImageUrl { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Schedules { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Prices { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Phone { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Email { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Site { get; set; }
}
}

View File

@ -0,0 +1,46 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section menu
/// </summary>
public class SectionMenu : Section
{
[Required]
public List<Section> Sections { get; set; } // All json files for all languages
public MenuDTO ToDTO()
{
return new MenuDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
sections = Sections.Select(s => s.ToDTO()).ToList()
};
}
}
}

View File

@ -0,0 +1,43 @@
using Manager.DTOs;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section Pdf
/// </summary>
public class SectionPdf : Section
{
[Required]
public List<OrderedTranslationAndResource> orderedTranslationAndResources { get; set; } // All json files for all languages
public PdfDTO ToDTO()
{
return new PdfDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
pdfs = orderedTranslationAndResources.Select(otar => otar.ToDTO()).ToList()
};
}
}
}

View File

@ -0,0 +1,65 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section puzzle
/// </summary>
public class SectionPuzzle : Section
{
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> MessageDebut { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> MessageFin { get; set; }
public string ContentId { get; set; } // But only image is possible
public Content Content { get; set; } // But only image is possible
[Required]
public int Rows { get; set; } = 3;
[Required]
public int Cols { get; set; } = 3;
public PuzzleDTO ToDTO()
{
return new PuzzleDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
messageDebut = MessageDebut.Select(md => md.ToDTO()).ToList(),
messageFin = MessageFin.Select(mf => mf.ToDTO()).ToList(),
image = Content.ToDTO(),
rows = Rows,
cols = Cols
};
}
}
}

View File

@ -0,0 +1,64 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section quiz
/// </summary>
public class SectionQuiz : Section
{
[Required]
public List<QuizQuestion> Questions { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> BadLevel { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> MediumLevel { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> GoodLevel { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationAndResource> GreatLevel { get; set; }
public QuizDTO ToDTO()
{
return new QuizDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
//questions = Questions.Select(q => q.tod)
// TODO
};
}
}
}

View File

@ -0,0 +1,46 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section slider
/// </summary>
public class SectionSlider : Section
{
[Required]
public List<Content> Contents { get; set; } // TODO check
public SliderDTO ToDTO()
{
return new SliderDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
contents = Contents.Select(c => c.ToDTO()).ToList(),
};
}
}
}

View File

@ -0,0 +1,41 @@
using Manager.DTOs;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section video
/// </summary>
public class SectionVideo : Section
{
[Required]
public string Source { get; set; } // url to resource id (local) or on internet
public VideoDTO ToDTO()
{
return new VideoDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
source = Source
};
}
}
}

View File

@ -0,0 +1,51 @@
using Manager.DTOs;
using ManagerService.DTOs;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section weather
/// </summary>
public class SectionWeather : Section
{
public string City { get; set; } // Weather City
public DateTimeOffset? UpdatedDate { get; set; } // Weather date update (to only refresh)
public string Result { get; set; } // Weather result
public WeatherDTO ToDTO()
{
return new WeatherDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
city = City,
updatedDate = UpdatedDate,
result = Result,
};
}
}
}

View File

@ -0,0 +1,42 @@
using Manager.DTOs;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Section web
/// </summary>
public class SectionWeb : Section
{
[Required]
public string Source { get; set; } // url to resource id (local) or on internet
public WebDTO ToDTO()
{
return new WebDTO()
{
id = Id,
label = Label,
title = Title.OrderBy(t => t.Language).Select(l => l.ToDTO()).ToList(),
description = Description.OrderBy(d => d.Language).Select(l => l.ToDTO()).ToList(),
order = Order,
type = Type,
imageId = ImageId,
imageSource = ImageSource,
configurationId = ConfigurationId,
isSubSection = IsSubSection,
parentId = ParentId,
dateCreation = DateCreation,
instanceId = InstanceId,
isBeacon = IsBeacon,
beaconId = BeaconId,
latitude = Latitude,
longitude = Longitude,
meterZoneGPS = MeterZoneGPS,
source = Source
};
}
}
}

View File

@ -2,7 +2,7 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace ManagerService.Data
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Translation
@ -11,7 +11,7 @@ namespace ManagerService.Data
{
[Key]
[Required]
public int Id { get; set; }
public int Id { get; set; }
[Required]
public string Language { get; set; }
@ -36,11 +36,5 @@ namespace ManagerService.Data
Value = translationDTO.value
};
}
public enum TranslationType
{
Title,
Description
}
}
}

View File

@ -0,0 +1,47 @@
using ManagerService.DTOs;
using System;
using System.ComponentModel.DataAnnotations;
namespace ManagerService.Data.SubSection
{
/// <summary>
/// Translation
/// </summary>
public class TranslationAndResource
{
[Key]
[Required]
public int Id { get; set; }
[Required]
public string Language { get; set; }
public string Value { get; set; }
public string ResourceId { get; set; }
public Resource Resource { get; set; }
public TranslationAndResourceDTO ToDTO()
{
return new TranslationAndResourceDTO()
{
language = Language,
value = Value,
resourceId = ResourceId,
resource = Resource.ToDTO()
};
}
public TranslationAndResource FromDTO(TranslationAndResourceDTO translationAndResourceDTO)
{
return new TranslationAndResource()
{
Language = translationAndResourceDTO.language,
Value = translationAndResourceDTO.value,
ResourceId = translationAndResourceDTO.resourceId
};
}
}
}

View File

@ -1,5 +1,5 @@
using System.Collections.Generic;
using ManagerService.Data;
using ManagerService.Data.SubSection;
namespace Manager.Helpers
{

View File

@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;

View File

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable

View File

@ -0,0 +1,825 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Manager.DTOs;
using ManagerService.DTOs;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ManagerService.Migrations
{
[DbContext(typeof(MyInfoMateDbContext))]
[Migration("20250319073520_UpdateDB")]
partial class UpdateDB
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ManagerService.Data.Configuration", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTime>("DateCreation")
.HasColumnType("timestamp with time zone");
b.Property<string>("ImageId")
.HasColumnType("text");
b.Property<string>("ImageSource")
.HasColumnType("text");
b.Property<string>("InstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsDate")
.HasColumnType("boolean");
b.Property<bool>("IsHour")
.HasColumnType("boolean");
b.Property<bool>("IsMobile")
.HasColumnType("boolean");
b.Property<bool>("IsOffline")
.HasColumnType("boolean");
b.Property<bool>("IsSectionImageBackground")
.HasColumnType("boolean");
b.Property<bool>("IsTablet")
.HasColumnType("boolean");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("Languages")
.HasColumnType("text[]");
b.Property<string>("LoaderImageId")
.HasColumnType("text");
b.Property<string>("LoaderImageUrl")
.HasColumnType("text");
b.Property<string>("PrimaryColor")
.HasColumnType("text");
b.Property<int?>("RoundedValue")
.HasColumnType("integer");
b.Property<int?>("ScreenPercentageSectionsMainPage")
.HasColumnType("integer");
b.Property<string>("SecondaryColor")
.HasColumnType("text");
b.Property<List<Translation>>("Title")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("WeatherCity")
.HasColumnType("text");
b.Property<string>("WeatherResult")
.HasColumnType("text");
b.Property<DateTimeOffset?>("WeatherUpdatedDate")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("Configurations");
});
modelBuilder.Entity("ManagerService.Data.Device", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<string>("BatteryLevel")
.HasColumnType("text");
b.Property<string>("Configuration")
.HasColumnType("text");
b.Property<string>("ConfigurationId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("Connected")
.HasColumnType("boolean");
b.Property<string>("ConnectionLevel")
.HasColumnType("text");
b.Property<DateTime>("DateCreation")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateUpdate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Identifier")
.HasColumnType("text");
b.Property<string>("InstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("IpAddressETH")
.IsRequired()
.HasColumnType("text");
b.Property<string>("IpAddressWLAN")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("LastBatteryLevel")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("LastConnectionLevel")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Devices");
});
modelBuilder.Entity("ManagerService.Data.Instance", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTime>("DateCreation")
.HasColumnType("timestamp with time zone");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("PinCode")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Instances");
});
modelBuilder.Entity("ManagerService.Data.Resource", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTime>("DateCreation")
.HasColumnType("timestamp with time zone");
b.Property<string>("InstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Type")
.HasColumnType("integer");
b.Property<string>("Url")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Resources");
});
modelBuilder.Entity("ManagerService.Data.Section", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int?>("BeaconId")
.HasColumnType("integer");
b.Property<string>("ConfigurationId")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreation")
.HasColumnType("timestamp with time zone");
b.Property<List<Translation>>("Description")
.HasColumnType("jsonb");
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("character varying(8)");
b.Property<string>("ImageId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("ImageSource")
.IsRequired()
.HasColumnType("text");
b.Property<string>("InstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsBeacon")
.HasColumnType("boolean");
b.Property<bool>("IsSubSection")
.HasColumnType("boolean");
b.Property<string>("Label")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Latitude")
.HasColumnType("text");
b.Property<string>("Longitude")
.HasColumnType("text");
b.Property<int?>("MeterZoneGPS")
.HasColumnType("integer");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("ParentId")
.HasColumnType("text");
b.Property<string>("SectionMenuId")
.HasColumnType("text");
b.Property<List<Translation>>("Title")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("Type")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SectionMenuId");
b.ToTable("Sections");
b.HasDiscriminator().HasValue("Base");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Icon")
.HasColumnType("text");
b.Property<List<Translation>>("Label")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int?>("Order")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<string>("SectionMapId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ResourceId");
b.HasIndex("SectionMapId");
b.ToTable("Categorie");
});
modelBuilder.Entity("ManagerService.Data.SubSection.Content", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<Translation>>("Description")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<string>("SectionArticleId")
.HasColumnType("text");
b.Property<string>("SectionSliderId")
.HasColumnType("text");
b.Property<List<Translation>>("Title")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("ResourceId");
b.HasIndex("SectionArticleId");
b.HasIndex("SectionSliderId");
b.ToTable("Content");
});
modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CategorieId")
.HasColumnType("integer");
b.Property<List<Resource>>("Contents")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<Translation>>("Description")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationDTO>>("Email")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("ImageResourceId")
.HasColumnType("text");
b.Property<string>("ImageUrl")
.HasColumnType("text");
b.Property<string>("Latitude")
.HasColumnType("text");
b.Property<string>("Longitude")
.HasColumnType("text");
b.Property<List<TranslationDTO>>("Phone")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationDTO>>("Prices")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationDTO>>("Schedules")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("SectionMapId")
.HasColumnType("text");
b.Property<List<TranslationDTO>>("Site")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<Translation>>("Title")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("SectionMapId");
b.ToTable("GeoPoint");
});
modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("SectionPdfId")
.HasColumnType("text");
b.Property<List<TranslationAndResource>>("TranslationAndResources")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("SectionPdfId");
b.ToTable("OrderedTranslationAndResource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<TranslationAndResourceDTO>>("Label")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<List<ResponseDTO>>("Responses")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("SectionQuizId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ResourceId");
b.HasIndex("SectionQuizId");
b.ToTable("QuizQuestion");
});
modelBuilder.Entity("ManagerService.Data.User", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
b.Property<DateTime>("DateCreation")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("FirstName")
.HasColumnType("text");
b.Property<string>("InstanceId")
.IsRequired()
.HasColumnType("text");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Token")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionAgenda", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<int?>("mapProvider")
.HasColumnType("integer");
b.Property<List<Translation>>("resourceIds")
.IsRequired()
.HasColumnType("jsonb");
b.HasDiscriminator().HasValue("Agenda");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<List<Translation>>("audioIds")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<Translation>>("content")
.IsRequired()
.HasColumnType("jsonb");
b.Property<bool>("isContentTop")
.HasColumnType("boolean");
b.Property<bool>("isReadAudioAuto")
.HasColumnType("boolean");
b.HasDiscriminator().HasValue("Article");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("CenterLatitude")
.HasColumnType("text");
b.Property<string>("CenterLongitude")
.HasColumnType("text");
b.Property<int?>("MapProvider")
.HasColumnType("integer");
b.Property<int?>("MapType")
.HasColumnType("integer");
b.Property<int?>("MapTypeMapbox")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<int>("Zoom")
.HasColumnType("integer");
b.HasIndex("ResourceId");
b.HasDiscriminator().HasValue("Map");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.HasDiscriminator().HasValue("Menu");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.HasDiscriminator().HasValue("PDF");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<int>("Cols")
.HasColumnType("integer");
b.Property<string>("ContentId")
.HasColumnType("text");
b.Property<int?>("ContentId1")
.HasColumnType("integer");
b.Property<List<TranslationAndResource>>("MessageDebut")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("MessageFin")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("Rows")
.HasColumnType("integer");
b.HasIndex("ContentId1");
b.HasDiscriminator().HasValue("Puzzle");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<List<TranslationAndResource>>("BadLevel")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("GoodLevel")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("GreatLevel")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("MediumLevel")
.IsRequired()
.HasColumnType("jsonb");
b.HasDiscriminator().HasValue("Quiz");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.HasDiscriminator().HasValue("Slider");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionVideo", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.HasDiscriminator().HasValue("Video");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeather", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("City")
.HasColumnType("text");
b.Property<string>("Result")
.HasColumnType("text");
b.Property<DateTimeOffset?>("UpdatedDate")
.HasColumnType("timestamp with time zone");
b.HasDiscriminator().HasValue("Weather");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeb", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.ToTable("Sections", t =>
{
t.Property("Source")
.HasColumnName("SectionWeb_Source");
});
b.HasDiscriminator().HasValue("Web");
});
modelBuilder.Entity("ManagerService.Data.Section", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionMenu", null)
.WithMany("Sections")
.HasForeignKey("SectionMenuId");
});
modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
.WithMany("Categories")
.HasForeignKey("SectionMapId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.Content", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionArticle", null)
.WithMany("contents")
.HasForeignKey("SectionArticleId");
b.HasOne("ManagerService.Data.SubSection.SectionSlider", null)
.WithMany("Contents")
.HasForeignKey("SectionSliderId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
.WithMany("Points")
.HasForeignKey("SectionMapId");
});
modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionPdf", null)
.WithMany("orderedTranslationAndResources")
.HasForeignKey("SectionPdfId");
});
modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionQuiz", null)
.WithMany("Questions")
.HasForeignKey("SectionQuizId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
{
b.HasOne("ManagerService.Data.SubSection.Content", "Content")
.WithMany()
.HasForeignKey("ContentId1");
b.Navigation("Content");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b =>
{
b.Navigation("contents");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
b.Navigation("Categories");
b.Navigation("Points");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b =>
{
b.Navigation("Sections");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b =>
{
b.Navigation("orderedTranslationAndResources");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
{
b.Navigation("Questions");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b =>
{
b.Navigation("Contents");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,596 @@
using System;
using System.Collections.Generic;
using Manager.DTOs;
using ManagerService.DTOs;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ManagerService.Migrations
{
/// <inheritdoc />
public partial class UpdateDB : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Data",
table: "Sections");
migrationBuilder.AddColumn<List<TranslationAndResource>>(
name: "BadLevel",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CenterLatitude",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CenterLongitude",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "City",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Cols",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ContentId",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ContentId1",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "Sections",
type: "character varying(8)",
maxLength: 8,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<List<TranslationAndResource>>(
name: "GoodLevel",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<List<TranslationAndResource>>(
name: "GreatLevel",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "MapProvider",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "MapType",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "MapTypeMapbox",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<List<TranslationAndResource>>(
name: "MediumLevel",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<List<TranslationAndResource>>(
name: "MessageDebut",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<List<TranslationAndResource>>(
name: "MessageFin",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ResourceId",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Result",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Rows",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SectionMenuId",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SectionWeb_Source",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Source",
table: "Sections",
type: "text",
nullable: true);
migrationBuilder.AddColumn<DateTimeOffset>(
name: "UpdatedDate",
table: "Sections",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Zoom",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<List<Translation>>(
name: "audioIds",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<List<Translation>>(
name: "content",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "isContentTop",
table: "Sections",
type: "boolean",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "isReadAudioAuto",
table: "Sections",
type: "boolean",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "mapProvider",
table: "Sections",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<List<Translation>>(
name: "resourceIds",
table: "Sections",
type: "jsonb",
nullable: true);
migrationBuilder.CreateTable(
name: "Categorie",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Label = table.Column<List<Translation>>(type: "jsonb", nullable: false),
Icon = table.Column<string>(type: "text", nullable: true),
ResourceId = table.Column<string>(type: "text", nullable: true),
Order = table.Column<int>(type: "integer", nullable: true),
SectionMapId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Categorie", x => x.Id);
table.ForeignKey(
name: "FK_Categorie_Resources_ResourceId",
column: x => x.ResourceId,
principalTable: "Resources",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Categorie_Sections_SectionMapId",
column: x => x.SectionMapId,
principalTable: "Sections",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Content",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column<List<Translation>>(type: "jsonb", nullable: false),
Description = table.Column<List<Translation>>(type: "jsonb", nullable: false),
ResourceId = table.Column<string>(type: "text", nullable: true),
Order = table.Column<int>(type: "integer", nullable: false),
SectionArticleId = table.Column<string>(type: "text", nullable: true),
SectionSliderId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Content", x => x.Id);
table.ForeignKey(
name: "FK_Content_Resources_ResourceId",
column: x => x.ResourceId,
principalTable: "Resources",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Content_Sections_SectionArticleId",
column: x => x.SectionArticleId,
principalTable: "Sections",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Content_Sections_SectionSliderId",
column: x => x.SectionSliderId,
principalTable: "Sections",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "GeoPoint",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column<List<Translation>>(type: "jsonb", nullable: false),
Description = table.Column<List<Translation>>(type: "jsonb", nullable: false),
Contents = table.Column<List<Resource>>(type: "jsonb", nullable: false),
CategorieId = table.Column<int>(type: "integer", nullable: true),
Latitude = table.Column<string>(type: "text", nullable: true),
Longitude = table.Column<string>(type: "text", nullable: true),
ImageResourceId = table.Column<string>(type: "text", nullable: true),
ImageUrl = table.Column<string>(type: "text", nullable: true),
Schedules = table.Column<List<TranslationDTO>>(type: "jsonb", nullable: false),
Prices = table.Column<List<TranslationDTO>>(type: "jsonb", nullable: false),
Phone = table.Column<List<TranslationDTO>>(type: "jsonb", nullable: false),
Email = table.Column<List<TranslationDTO>>(type: "jsonb", nullable: false),
Site = table.Column<List<TranslationDTO>>(type: "jsonb", nullable: false),
SectionMapId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_GeoPoint", x => x.Id);
table.ForeignKey(
name: "FK_GeoPoint_Sections_SectionMapId",
column: x => x.SectionMapId,
principalTable: "Sections",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "OrderedTranslationAndResource",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
TranslationAndResources = table.Column<List<TranslationAndResource>>(type: "jsonb", nullable: false),
Order = table.Column<int>(type: "integer", nullable: false),
SectionPdfId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderedTranslationAndResource", x => x.Id);
table.ForeignKey(
name: "FK_OrderedTranslationAndResource_Sections_SectionPdfId",
column: x => x.SectionPdfId,
principalTable: "Sections",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "QuizQuestion",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Label = table.Column<List<TranslationAndResourceDTO>>(type: "jsonb", nullable: false),
ResourceId = table.Column<string>(type: "text", nullable: true),
Order = table.Column<int>(type: "integer", nullable: false),
Responses = table.Column<List<ResponseDTO>>(type: "jsonb", nullable: false),
SectionQuizId = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_QuizQuestion", x => x.Id);
table.ForeignKey(
name: "FK_QuizQuestion_Resources_ResourceId",
column: x => x.ResourceId,
principalTable: "Resources",
principalColumn: "Id");
table.ForeignKey(
name: "FK_QuizQuestion_Sections_SectionQuizId",
column: x => x.SectionQuizId,
principalTable: "Sections",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Sections_ContentId1",
table: "Sections",
column: "ContentId1");
migrationBuilder.CreateIndex(
name: "IX_Sections_ResourceId",
table: "Sections",
column: "ResourceId");
migrationBuilder.CreateIndex(
name: "IX_Sections_SectionMenuId",
table: "Sections",
column: "SectionMenuId");
migrationBuilder.CreateIndex(
name: "IX_Categorie_ResourceId",
table: "Categorie",
column: "ResourceId");
migrationBuilder.CreateIndex(
name: "IX_Categorie_SectionMapId",
table: "Categorie",
column: "SectionMapId");
migrationBuilder.CreateIndex(
name: "IX_Content_ResourceId",
table: "Content",
column: "ResourceId");
migrationBuilder.CreateIndex(
name: "IX_Content_SectionArticleId",
table: "Content",
column: "SectionArticleId");
migrationBuilder.CreateIndex(
name: "IX_Content_SectionSliderId",
table: "Content",
column: "SectionSliderId");
migrationBuilder.CreateIndex(
name: "IX_GeoPoint_SectionMapId",
table: "GeoPoint",
column: "SectionMapId");
migrationBuilder.CreateIndex(
name: "IX_OrderedTranslationAndResource_SectionPdfId",
table: "OrderedTranslationAndResource",
column: "SectionPdfId");
migrationBuilder.CreateIndex(
name: "IX_QuizQuestion_ResourceId",
table: "QuizQuestion",
column: "ResourceId");
migrationBuilder.CreateIndex(
name: "IX_QuizQuestion_SectionQuizId",
table: "QuizQuestion",
column: "SectionQuizId");
migrationBuilder.AddForeignKey(
name: "FK_Sections_Content_ContentId1",
table: "Sections",
column: "ContentId1",
principalTable: "Content",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Sections_Resources_ResourceId",
table: "Sections",
column: "ResourceId",
principalTable: "Resources",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Sections_Sections_SectionMenuId",
table: "Sections",
column: "SectionMenuId",
principalTable: "Sections",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Sections_Content_ContentId1",
table: "Sections");
migrationBuilder.DropForeignKey(
name: "FK_Sections_Resources_ResourceId",
table: "Sections");
migrationBuilder.DropForeignKey(
name: "FK_Sections_Sections_SectionMenuId",
table: "Sections");
migrationBuilder.DropTable(
name: "Categorie");
migrationBuilder.DropTable(
name: "Content");
migrationBuilder.DropTable(
name: "GeoPoint");
migrationBuilder.DropTable(
name: "OrderedTranslationAndResource");
migrationBuilder.DropTable(
name: "QuizQuestion");
migrationBuilder.DropIndex(
name: "IX_Sections_ContentId1",
table: "Sections");
migrationBuilder.DropIndex(
name: "IX_Sections_ResourceId",
table: "Sections");
migrationBuilder.DropIndex(
name: "IX_Sections_SectionMenuId",
table: "Sections");
migrationBuilder.DropColumn(
name: "BadLevel",
table: "Sections");
migrationBuilder.DropColumn(
name: "CenterLatitude",
table: "Sections");
migrationBuilder.DropColumn(
name: "CenterLongitude",
table: "Sections");
migrationBuilder.DropColumn(
name: "City",
table: "Sections");
migrationBuilder.DropColumn(
name: "Cols",
table: "Sections");
migrationBuilder.DropColumn(
name: "ContentId",
table: "Sections");
migrationBuilder.DropColumn(
name: "ContentId1",
table: "Sections");
migrationBuilder.DropColumn(
name: "Discriminator",
table: "Sections");
migrationBuilder.DropColumn(
name: "GoodLevel",
table: "Sections");
migrationBuilder.DropColumn(
name: "GreatLevel",
table: "Sections");
migrationBuilder.DropColumn(
name: "MapProvider",
table: "Sections");
migrationBuilder.DropColumn(
name: "MapType",
table: "Sections");
migrationBuilder.DropColumn(
name: "MapTypeMapbox",
table: "Sections");
migrationBuilder.DropColumn(
name: "MediumLevel",
table: "Sections");
migrationBuilder.DropColumn(
name: "MessageDebut",
table: "Sections");
migrationBuilder.DropColumn(
name: "MessageFin",
table: "Sections");
migrationBuilder.DropColumn(
name: "ResourceId",
table: "Sections");
migrationBuilder.DropColumn(
name: "Result",
table: "Sections");
migrationBuilder.DropColumn(
name: "Rows",
table: "Sections");
migrationBuilder.DropColumn(
name: "SectionMenuId",
table: "Sections");
migrationBuilder.DropColumn(
name: "SectionWeb_Source",
table: "Sections");
migrationBuilder.DropColumn(
name: "Source",
table: "Sections");
migrationBuilder.DropColumn(
name: "UpdatedDate",
table: "Sections");
migrationBuilder.DropColumn(
name: "Zoom",
table: "Sections");
migrationBuilder.DropColumn(
name: "audioIds",
table: "Sections");
migrationBuilder.DropColumn(
name: "content",
table: "Sections");
migrationBuilder.DropColumn(
name: "isContentTop",
table: "Sections");
migrationBuilder.DropColumn(
name: "isReadAudioAuto",
table: "Sections");
migrationBuilder.DropColumn(
name: "mapProvider",
table: "Sections");
migrationBuilder.DropColumn(
name: "resourceIds",
table: "Sections");
migrationBuilder.AddColumn<string>(
name: "Data",
table: "Sections",
type: "text",
nullable: false,
defaultValue: "");
}
}
}

View File

@ -1,7 +1,10 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Manager.DTOs;
using ManagerService.DTOs;
using ManagerService.Data;
using ManagerService.Data.SubSection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@ -217,16 +220,17 @@ namespace ManagerService.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("DateCreation")
.HasColumnType("timestamp with time zone");
b.Property<List<Translation>>("Description")
.HasColumnType("jsonb");
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("character varying(8)");
b.Property<string>("ImageId")
.IsRequired()
.HasColumnType("text");
@ -264,6 +268,9 @@ namespace ManagerService.Migrations
b.Property<string>("ParentId")
.HasColumnType("text");
b.Property<string>("SectionMenuId")
.HasColumnType("text");
b.Property<List<Translation>>("Title")
.IsRequired()
.HasColumnType("jsonb");
@ -273,7 +280,209 @@ namespace ManagerService.Migrations
b.HasKey("Id");
b.HasIndex("SectionMenuId");
b.ToTable("Sections");
b.HasDiscriminator().HasValue("Base");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Icon")
.HasColumnType("text");
b.Property<List<Translation>>("Label")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int?>("Order")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<string>("SectionMapId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ResourceId");
b.HasIndex("SectionMapId");
b.ToTable("Categorie");
});
modelBuilder.Entity("ManagerService.Data.SubSection.Content", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<Translation>>("Description")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<string>("SectionArticleId")
.HasColumnType("text");
b.Property<string>("SectionSliderId")
.HasColumnType("text");
b.Property<List<Translation>>("Title")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("ResourceId");
b.HasIndex("SectionArticleId");
b.HasIndex("SectionSliderId");
b.ToTable("Content");
});
modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CategorieId")
.HasColumnType("integer");
b.Property<List<Resource>>("Contents")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<Translation>>("Description")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationDTO>>("Email")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("ImageResourceId")
.HasColumnType("text");
b.Property<string>("ImageUrl")
.HasColumnType("text");
b.Property<string>("Latitude")
.HasColumnType("text");
b.Property<string>("Longitude")
.HasColumnType("text");
b.Property<List<TranslationDTO>>("Phone")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationDTO>>("Prices")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationDTO>>("Schedules")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("SectionMapId")
.HasColumnType("text");
b.Property<List<TranslationDTO>>("Site")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<Translation>>("Title")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("SectionMapId");
b.ToTable("GeoPoint");
});
modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("SectionPdfId")
.HasColumnType("text");
b.Property<List<TranslationAndResource>>("TranslationAndResources")
.IsRequired()
.HasColumnType("jsonb");
b.HasKey("Id");
b.HasIndex("SectionPdfId");
b.ToTable("OrderedTranslationAndResource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<List<TranslationAndResourceDTO>>("Label")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("Order")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<List<ResponseDTO>>("Responses")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("SectionQuizId")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ResourceId");
b.HasIndex("SectionQuizId");
b.ToTable("QuizQuestion");
});
modelBuilder.Entity("ManagerService.Data.User", b =>
@ -311,6 +520,302 @@ namespace ManagerService.Migrations
b.ToTable("Users");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionAgenda", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<int?>("mapProvider")
.HasColumnType("integer");
b.Property<List<Translation>>("resourceIds")
.IsRequired()
.HasColumnType("jsonb");
b.HasDiscriminator().HasValue("Agenda");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<List<Translation>>("audioIds")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<Translation>>("content")
.IsRequired()
.HasColumnType("jsonb");
b.Property<bool>("isContentTop")
.HasColumnType("boolean");
b.Property<bool>("isReadAudioAuto")
.HasColumnType("boolean");
b.HasDiscriminator().HasValue("Article");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("CenterLatitude")
.HasColumnType("text");
b.Property<string>("CenterLongitude")
.HasColumnType("text");
b.Property<int?>("MapProvider")
.HasColumnType("integer");
b.Property<int?>("MapType")
.HasColumnType("integer");
b.Property<int?>("MapTypeMapbox")
.HasColumnType("integer");
b.Property<string>("ResourceId")
.HasColumnType("text");
b.Property<int>("Zoom")
.HasColumnType("integer");
b.HasIndex("ResourceId");
b.HasDiscriminator().HasValue("Map");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.HasDiscriminator().HasValue("Menu");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.HasDiscriminator().HasValue("PDF");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<int>("Cols")
.HasColumnType("integer");
b.Property<string>("ContentId")
.HasColumnType("text");
b.Property<int?>("ContentId1")
.HasColumnType("integer");
b.Property<List<TranslationAndResource>>("MessageDebut")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("MessageFin")
.IsRequired()
.HasColumnType("jsonb");
b.Property<int>("Rows")
.HasColumnType("integer");
b.HasIndex("ContentId1");
b.HasDiscriminator().HasValue("Puzzle");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<List<TranslationAndResource>>("BadLevel")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("GoodLevel")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("GreatLevel")
.IsRequired()
.HasColumnType("jsonb");
b.Property<List<TranslationAndResource>>("MediumLevel")
.IsRequired()
.HasColumnType("jsonb");
b.HasDiscriminator().HasValue("Quiz");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.HasDiscriminator().HasValue("Slider");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionVideo", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.HasDiscriminator().HasValue("Video");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeather", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("City")
.HasColumnType("text");
b.Property<string>("Result")
.HasColumnType("text");
b.Property<DateTimeOffset?>("UpdatedDate")
.HasColumnType("timestamp with time zone");
b.HasDiscriminator().HasValue("Weather");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeb", b =>
{
b.HasBaseType("ManagerService.Data.Section");
b.Property<string>("Source")
.IsRequired()
.HasColumnType("text");
b.ToTable("Sections", t =>
{
t.Property("Source")
.HasColumnName("SectionWeb_Source");
});
b.HasDiscriminator().HasValue("Web");
});
modelBuilder.Entity("ManagerService.Data.Section", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionMenu", null)
.WithMany("Sections")
.HasForeignKey("SectionMenuId");
});
modelBuilder.Entity("ManagerService.Data.SubSection.Categorie", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
.WithMany("Categories")
.HasForeignKey("SectionMapId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.Content", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionArticle", null)
.WithMany("contents")
.HasForeignKey("SectionArticleId");
b.HasOne("ManagerService.Data.SubSection.SectionSlider", null)
.WithMany("Contents")
.HasForeignKey("SectionSliderId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.GeoPoint", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionMap", null)
.WithMany("Points")
.HasForeignKey("SectionMapId");
});
modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b =>
{
b.HasOne("ManagerService.Data.SubSection.SectionPdf", null)
.WithMany("orderedTranslationAndResources")
.HasForeignKey("SectionPdfId");
});
modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.HasOne("ManagerService.Data.SubSection.SectionQuiz", null)
.WithMany("Questions")
.HasForeignKey("SectionQuizId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
b.HasOne("ManagerService.Data.Resource", "Resource")
.WithMany()
.HasForeignKey("ResourceId");
b.Navigation("Resource");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPuzzle", b =>
{
b.HasOne("ManagerService.Data.SubSection.Content", "Content")
.WithMany()
.HasForeignKey("ContentId1");
b.Navigation("Content");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b =>
{
b.Navigation("contents");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b =>
{
b.Navigation("Categories");
b.Navigation("Points");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionMenu", b =>
{
b.Navigation("Sections");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionPdf", b =>
{
b.Navigation("orderedTranslationAndResources");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b =>
{
b.Navigation("Questions");
});
modelBuilder.Entity("ManagerService.Data.SubSection.SectionSlider", b =>
{
b.Navigation("Contents");
});
#pragma warning restore 612, 618
}
}

View File

@ -11,36 +11,36 @@ namespace Manager.Services
{
public class ConfigurationDatabaseService
{
private readonly IMongoCollection<Configuration> _Configurations;
private readonly IMongoCollection<OldConfiguration> _Configurations;
public ConfigurationDatabaseService(IConfiguration config)
{
var client = new MongoClient(config.GetConnectionString("TabletDb"));
var database = client.GetDatabase("TabletDb");
_Configurations = database.GetCollection<Configuration>("Configurations");
_Configurations = database.GetCollection<OldConfiguration>("Configurations");
}
public List<Configuration> GetAll(string instanceId)
public List<OldConfiguration> GetAll(string instanceId)
{
return _Configurations.Find(d => d.InstanceId == instanceId).ToList();
}
public Configuration GetById(string id)
public OldConfiguration GetById(string id)
{
return _Configurations.Find<Configuration>(d => d.Id == id).FirstOrDefault();
return _Configurations.Find<OldConfiguration>(d => d.Id == id).FirstOrDefault();
}
public bool IsExist(string id)
{
return _Configurations.Find<Configuration>(d => d.Id == id).FirstOrDefault() != null ? true : false;
return _Configurations.Find<OldConfiguration>(d => d.Id == id).FirstOrDefault() != null ? true : false;
}
public Configuration Create(Configuration configuration)
public OldConfiguration Create(OldConfiguration configuration)
{
_Configurations.InsertOne(configuration);
return configuration;
}
public Configuration Update(string id, Configuration configurationIn)
public OldConfiguration Update(string id, OldConfiguration configurationIn)
{
_Configurations.ReplaceOne(d => d.Id == id, configurationIn);
return configurationIn;

View File

@ -11,67 +11,67 @@ namespace Manager.Services
{
public class DeviceDatabaseService
{
private readonly IMongoCollection<Device> _Devices;
private readonly IMongoCollection<OldDevice> _Devices;
public DeviceDatabaseService(IConfiguration config)
{
var client = new MongoClient(config.GetConnectionString("TabletDb"));
var database = client.GetDatabase("TabletDb");
_Devices = database.GetCollection<Device>("Devices");
_Devices = database.GetCollection<OldDevice>("Devices");
}
public List<Device> GetAll(string instanceId)
public List<OldDevice> GetAll(string instanceId)
{
return _Devices.Find(d => d.InstanceId == instanceId).ToList();
}
public List<Device> GetAllConnected()
public List<OldDevice> GetAllConnected()
{
return _Devices.Find(d => d.Connected).ToList();
}
public List<Device> GetAllWithConfig(string configId)
public List<OldDevice> GetAllWithConfig(string configId)
{
return _Devices.Find(d => d.ConfigurationId == configId).ToList();
}
public Device GetById(string id)
public OldDevice GetById(string id)
{
return _Devices.Find<Device>(d => d.Id == id).FirstOrDefault();
return _Devices.Find<OldDevice>(d => d.Id == id).FirstOrDefault();
}
public Device GetByIdentifier(string identifier)
public OldDevice GetByIdentifier(string identifier)
{
return _Devices.Find<Device>(d => d.Identifier == identifier).FirstOrDefault();
return _Devices.Find<OldDevice>(d => d.Identifier == identifier).FirstOrDefault();
}
public bool IsExistIdentifier(string identifier)
{
return _Devices.Find<Device>(d => d.Identifier == identifier).FirstOrDefault() != null ? true : false;
return _Devices.Find<OldDevice>(d => d.Identifier == identifier).FirstOrDefault() != null ? true : false;
}
public bool IsExistIpWLAN(string ip)
{
return _Devices.Find<Device>(d => d.IpAddressWLAN == ip).FirstOrDefault() != null ? true : false;
return _Devices.Find<OldDevice>(d => d.IpAddressWLAN == ip).FirstOrDefault() != null ? true : false;
}
public bool IsExistIpETH(string ip)
{
return _Devices.Find<Device>(d => d.IpAddressETH == ip).FirstOrDefault() != null ? true : false;
return _Devices.Find<OldDevice>(d => d.IpAddressETH == ip).FirstOrDefault() != null ? true : false;
}
public bool IsExist(string id)
{
return _Devices.Find<Device>(d => d.Id == id).FirstOrDefault() != null ? true : false;
return _Devices.Find<OldDevice>(d => d.Id == id).FirstOrDefault() != null ? true : false;
}
public Device Create(Device device)
public OldDevice Create(OldDevice device)
{
_Devices.InsertOne(device);
return device;
}
public Device Update(string id, Device deviceIn)
public OldDevice Update(string id, OldDevice deviceIn)
{
_Devices.ReplaceOne(d => d.Id == id, deviceIn);
return deviceIn;

View File

@ -0,0 +1,33 @@
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
namespace ManagerService.Services
{
public interface IHexIdGeneratorService
{
string GenerateHexId(); // Génère un ID hexadécimal unique
//string GenerateMongoObjectId(); // (Optionnel) Génère un vrai ObjectId MongoDB
}
public class HexIdGeneratorService : IHexIdGeneratorService
{
private readonly Random _random = new Random();
// Génération d'un ID hexadécimal basé sur des bytes aléatoires
public string GenerateHexId()
{
byte[] buffer = new byte[12]; // 12 bytes → 24 caractères hex
_random.NextBytes(buffer);
return string.Concat(buffer.Select(b => b.ToString("x2")));
}
// Génération d'un ObjectId MongoDB (facultatif)
/*public string GenerateMongoObjectId()
{
return ObjectId.GenerateNewId().ToString();
}*/
}
}

View File

@ -11,46 +11,46 @@ namespace Manager.Services
{
public class InstanceDatabaseService
{
private readonly IMongoCollection<Instance> _Instances;
private readonly IMongoCollection<OldInstance> _Instances;
public InstanceDatabaseService(IConfiguration config)
{
var client = new MongoClient(config.GetConnectionString("TabletDb"));
var database = client.GetDatabase("TabletDb");
_Instances = database.GetCollection<Instance>("Instances");
_Instances = database.GetCollection<OldInstance>("Instances");
}
public List<Instance> GetAll()
public List<OldInstance> GetAll()
{
return _Instances.Find(m => true).ToList();
}
public Instance GetByName(string name)
public OldInstance GetByName(string name)
{
return _Instances.Find<Instance>(i => i.Name == name).FirstOrDefault();
return _Instances.Find<OldInstance>(i => i.Name == name).FirstOrDefault();
}
public Instance GetById(string id)
public OldInstance GetById(string id)
{
return _Instances.Find<Instance>(i => i.Id == id).FirstOrDefault();
return _Instances.Find<OldInstance>(i => i.Id == id).FirstOrDefault();
}
public Instance GetByPinCode(int pinCode)
public OldInstance GetByPinCode(int pinCode)
{
return _Instances.Find<Instance>(c => c.PinCode == pinCode).FirstOrDefault();
return _Instances.Find<OldInstance>(c => c.PinCode == pinCode).FirstOrDefault();
}
public bool IsExist(string id)
{
return _Instances.Find<Instance>(i => i.Id == id).FirstOrDefault() != null ? true : false;
return _Instances.Find<OldInstance>(i => i.Id == id).FirstOrDefault() != null ? true : false;
}
public Instance Create(Instance instance)
public OldInstance Create(OldInstance instance)
{
_Instances.InsertOne(instance);
return instance;
}
public Instance Update(string id, Instance instanceIn)
public OldInstance Update(string id, OldInstance instanceIn)
{
_Instances.ReplaceOne(instance => instance.Id == id, instanceIn);
return instanceIn;

View File

@ -11,41 +11,41 @@ namespace Manager.Services
{
public class ResourceDatabaseService
{
private readonly IMongoCollection<Resource> _Resources;
private readonly IMongoCollection<OldResource> _Resources;
public ResourceDatabaseService(IConfiguration config)
{
var client = new MongoClient(config.GetConnectionString("TabletDb"));
var database = client.GetDatabase("TabletDb");
_Resources = database.GetCollection<Resource>("Resources");
_Resources = database.GetCollection<OldResource>("Resources");
}
public List<Resource> GetAll(string instanceId)
public List<OldResource> GetAll(string instanceId)
{
return _Resources.Find(r => r.InstanceId == instanceId).ToList();
}
public List<Resource> GetAllByType(string instanceId, List<ResourceType> types)
public List<OldResource> GetAllByType(string instanceId, List<ResourceType> types)
{
return _Resources.Find<Resource>(r => r.InstanceId == instanceId && types.Contains(r.Type)).ToList();
return _Resources.Find<OldResource>(r => r.InstanceId == instanceId && types.Contains(r.Type)).ToList();
}
public Resource GetById(string id)
public OldResource GetById(string id)
{
return _Resources.Find<Resource>(r => r.Id == id).FirstOrDefault();
return _Resources.Find<OldResource>(r => r.Id == id).FirstOrDefault();
}
public bool IsExist(string id)
{
return _Resources.Find<Resource>(r => r.Id == id).FirstOrDefault() != null ? true : false;
return _Resources.Find<OldResource>(r => r.Id == id).FirstOrDefault() != null ? true : false;
}
public Resource Create(Resource resource)
public OldResource Create(OldResource resource)
{
_Resources.InsertOne(resource);
return resource;
}
public Resource Update(string id, Resource resourceIn)
public OldResource Update(string id, OldResource resourceIn)
{
_Resources.ReplaceOne(r => r.Id == id, resourceIn);
return resourceIn;

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using Manager.Interfaces.Models;
using ManagerService.Data;
using ManagerService.DTOs;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
@ -11,26 +12,26 @@ namespace Manager.Services
{
public class SectionDatabaseService
{
private readonly IMongoCollection<Section> _Sections;
private readonly IMongoCollection<OldSection> _Sections;
public SectionDatabaseService(IConfiguration config)
{
var client = new MongoClient(config.GetConnectionString("TabletDb"));
var database = client.GetDatabase("TabletDb");
_Sections = database.GetCollection<Section>("Sections");
_Sections = database.GetCollection<OldSection>("Sections");
}
public List<Section> GetAll(string instanceId)
public List<OldSection> GetAll(string instanceId)
{
return _Sections.Find(s => !s.IsSubSection && s.InstanceId == instanceId).ToList();
}
public List<Section> GetAllFromConfiguration(string configurationId)
public List<OldSection> GetAllFromConfiguration(string configurationId)
{
return _Sections.Find(s => !s.IsSubSection && s.ConfigurationId == configurationId).ToList();
}
public List<Section> GetAllFromConfigurationEvenSubsection(string configurationId)
public List<OldSection> GetAllFromConfigurationEvenSubsection(string configurationId)
{
return _Sections.Find(s => s.ConfigurationId == configurationId).ToList();
}
@ -40,33 +41,33 @@ namespace Manager.Services
return _Sections.Find(s => !s.IsSubSection && s.ConfigurationId == configurationId).ToList().Select(s => s.Id).ToList();
}
public List<Section> GetAllWeatherSectionsFromConfiguration(string configurationId)
public List<OldSection> GetAllWeatherSectionsFromConfiguration(string configurationId)
{
return _Sections.Find(s => s.ConfigurationId == configurationId && s.Type == SectionType.Weather).ToList();
}
public List<Section> GetAllSubSection(string parentId)
public List<OldSection> GetAllSubSection(string parentId)
{
return _Sections.Find(s => s.IsSubSection && s.ParentId == parentId).ToList();
}
public Section GetById(string id)
public OldSection GetById(string id)
{
return _Sections.Find<Section>(s => s.Id == id).FirstOrDefault();
return _Sections.Find<OldSection>(s => s.Id == id).FirstOrDefault();
}
public bool IsExist(string id)
{
return _Sections.Find<Section>(s => s.Id == id).FirstOrDefault() != null ? true : false;
return _Sections.Find<OldSection>(s => s.Id == id).FirstOrDefault() != null ? true : false;
}
public Section Create(Section section)
public OldSection Create(OldSection section)
{
_Sections.InsertOne(section);
return section;
}
public Section Update(string id, Section sectionIn)
public OldSection Update(string id, OldSection sectionIn)
{
_Sections.ReplaceOne(s => s.Id == id, sectionIn);
return sectionIn;

View File

@ -11,46 +11,46 @@ namespace Manager.Services
{
public class UserDatabaseService
{
private readonly IMongoCollection<User> _Users;
private readonly IMongoCollection<OldUser> _Users;
public UserDatabaseService(IConfiguration config)
{
var client = new MongoClient(config.GetConnectionString("TabletDb"));
var database = client.GetDatabase("TabletDb");
_Users = database.GetCollection<User>("Users");
_Users = database.GetCollection<OldUser>("Users");
}
public List<User> GetAll()
public List<OldUser> GetAll()
{
return _Users.Find(u => true).ToList();
}
public User GetByEmail(string email)
public OldUser GetByEmail(string email)
{
return _Users.Find<User>(u => u.Email == email).FirstOrDefault();
return _Users.Find<OldUser>(u => u.Email == email).FirstOrDefault();
}
public User GetById(string id)
public OldUser GetById(string id)
{
return _Users.Find<User>(u => u.Id == id).FirstOrDefault();
return _Users.Find<OldUser>(u => u.Id == id).FirstOrDefault();
}
public List<User> GetByInstanceId(string id)
public List<OldUser> GetByInstanceId(string id)
{
return _Users.Find<User>(u => u.InstanceId == id).ToList();
return _Users.Find<OldUser>(u => u.InstanceId == id).ToList();
}
public bool IsExist(string id)
{
return _Users.Find<User>(u => u.Id == id).FirstOrDefault() != null ? true : false;
return _Users.Find<OldUser>(u => u.Id == id).FirstOrDefault() != null ? true : false;
}
public User Create(User user)
public OldUser Create(OldUser user)
{
_Users.InsertOne(user);
return user;
}
public User Update(string id, User userIn)
public OldUser Update(string id, OldUser userIn)
{
_Users.ReplaceOne(user => user.Id == id, userIn);
return userIn;

View File

@ -25,6 +25,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using Mqtt.Client.AspNetCore.Settings;
using MyCore.Service.Extensions;
using Npgsql;
using NSwag;
using NSwag.Generation.AspNetCore;
using NSwag.Generation.Processors.Security;
@ -151,8 +152,13 @@ namespace ManagerService
var connectionString = Configuration.GetConnectionString("PostgresConnection");
var dataSourceBuilder = new NpgsqlDataSourceBuilder(connectionString);
dataSourceBuilder.EnableDynamicJson();
var dataSource = dataSourceBuilder.Build();
services.AddDbContext<MyInfoMateDbContext>(options =>
options.UseNpgsql(connectionString));
options.UseNpgsql(dataSource)
);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.