clean configuration + user controller done

This commit is contained in:
Thomas Fransolet 2025-03-19 15:01:58 +01:00
parent 8b68ebe8c9
commit 1242d6c790
10 changed files with 919 additions and 62 deletions

View File

@ -237,9 +237,6 @@ namespace ManagerService.Controllers
configuration.SecondaryColor = newConfiguration.secondaryColor; configuration.SecondaryColor = newConfiguration.secondaryColor;
configuration.LoaderImageId = newConfiguration.loaderImageId; configuration.LoaderImageId = newConfiguration.loaderImageId;
configuration.LoaderImageUrl = newConfiguration.loaderImageUrl; configuration.LoaderImageUrl = newConfiguration.loaderImageUrl;
configuration.WeatherCity = newConfiguration.weatherCity;
configuration.WeatherUpdatedDate = null;
configuration.WeatherResult = null;
configuration.IsDate = newConfiguration.isDate; configuration.IsDate = newConfiguration.isDate;
configuration.IsHour = newConfiguration.isHour; configuration.IsHour = newConfiguration.isHour;
configuration.IsSectionImageBackground = true; configuration.IsSectionImageBackground = true;
@ -315,12 +312,6 @@ namespace ManagerService.Controllers
configuration.IsOffline = updatedConfiguration.isOffline; configuration.IsOffline = updatedConfiguration.isOffline;
configuration.LoaderImageId = updatedConfiguration.loaderImageId; configuration.LoaderImageId = updatedConfiguration.loaderImageId;
configuration.LoaderImageUrl = updatedConfiguration.loaderImageUrl; configuration.LoaderImageUrl = updatedConfiguration.loaderImageUrl;
configuration.WeatherCity = updatedConfiguration.weatherCity;
if (configuration.WeatherCity != updatedConfiguration.weatherCity)
{
configuration.WeatherUpdatedDate = null;
configuration.WeatherResult = null;
}
configuration.IsDate = updatedConfiguration.isDate; configuration.IsDate = updatedConfiguration.isDate;
configuration.IsHour = updatedConfiguration.isHour; configuration.IsHour = updatedConfiguration.isHour;
configuration.IsSectionImageBackground = updatedConfiguration.isSectionImageBackground; configuration.IsSectionImageBackground = updatedConfiguration.isSectionImageBackground;
@ -682,7 +673,6 @@ namespace ManagerService.Controllers
createResource(exportConfiguration.resources.Where(r => r.id == configuration.LoaderImageId).FirstOrDefault()); createResource(exportConfiguration.resources.Where(r => r.id == configuration.LoaderImageId).FirstOrDefault());
} }
configuration.WeatherCity = exportConfiguration.weatherCity;
configuration.IsDate = exportConfiguration.isDate; configuration.IsDate = exportConfiguration.isDate;
configuration.IsHour = exportConfiguration.isHour; configuration.IsHour = exportConfiguration.isHour;
configuration.IsSectionImageBackground = exportConfiguration.isSectionImageBackground; configuration.IsSectionImageBackground = exportConfiguration.isSectionImageBackground;

View File

@ -6,6 +6,7 @@ using ManagerService.Data;
using ManagerService.DTOs; using ManagerService.DTOs;
using ManagerService.Helpers; using ManagerService.Helpers;
using ManagerService.Service.Services; using ManagerService.Service.Services;
using ManagerService.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -23,12 +24,16 @@ namespace ManagerService.Controllers
private readonly ILogger<UserController> _logger; private readonly ILogger<UserController> _logger;
private readonly ProfileLogic _profileLogic; private readonly ProfileLogic _profileLogic;
public UserController(ILogger<UserController> logger, UserDatabaseService userService, TokensService tokenService, ProfileLogic profileLogic) private readonly MyInfoMateDbContext _myInfoMateDbContext;
IHexIdGeneratorService idService = new HexIdGeneratorService();
public UserController(ILogger<UserController> logger, UserDatabaseService userService, TokensService tokenService, ProfileLogic profileLogic, MyInfoMateDbContext myInfoMateDbContext)
{ {
_logger = logger; _logger = logger;
_userService = userService; _userService = userService;
_tokenService = tokenService; _tokenService = tokenService;
_profileLogic = profileLogic; _profileLogic = profileLogic;
_myInfoMateDbContext = myInfoMateDbContext;
} }
/// <summary> /// <summary>
@ -41,7 +46,8 @@ namespace ManagerService.Controllers
{ {
try try
{ {
List<OldUser> users = _userService.GetAll(); //List<OldUser> users = _userService.GetAll();
List<User> users= _myInfoMateDbContext.Users.ToList();
return new OkObjectResult(users); return new OkObjectResult(users);
} }
@ -64,7 +70,8 @@ namespace ManagerService.Controllers
{ {
try try
{ {
OldUser user = _userService.GetById(id); User user = _myInfoMateDbContext.Users.FirstOrDefault(i => i.Id == id);
//OldUser user = _userService.GetById(id);
if (user == null) if (user == null)
throw new KeyNotFoundException("This user was not found"); throw new KeyNotFoundException("This user was not found");
@ -91,29 +98,39 @@ namespace ManagerService.Controllers
[ProducesResponseType(typeof(string), 409)] [ProducesResponseType(typeof(string), 409)]
[ProducesResponseType(typeof(string), 500)] [ProducesResponseType(typeof(string), 500)]
[HttpPost] [HttpPost]
public ObjectResult CreateUser([FromBody] OldUser newUser) public ObjectResult CreateUser([FromBody] UserDetailDTO newUserDTO)
{ {
try try
{ {
if (newUser == null) if (newUserDTO == null)
throw new ArgumentNullException("User param is null"); throw new ArgumentNullException("User param is null");
if (newUser.InstanceId == null) if (newUserDTO.instanceId == null)
throw new ArgumentNullException("InstanceId is null"); throw new ArgumentNullException("InstanceId is null");
User newUser = new User();
newUser.InstanceId = newUserDTO.instanceId;
newUser.Email = newUserDTO.email;
newUser.FirstName = newUserDTO.firstName;
newUser.LastName = newUserDTO.lastName;
newUser.Token = _tokenService.GenerateToken(newUser.Email).ToString(); newUser.Token = _tokenService.GenerateToken(newUser.Email).ToString();
newUser.DateCreation = DateTime.Now; newUser.DateCreation = DateTime.Now.ToUniversalTime();
newUser.Id = idService.GenerateHexId();
List<OldUser> users = _userService.GetAll(); List<User> users= _myInfoMateDbContext.Users.ToList();
//List<OldUser> users = _userService.GetAll();
if (users.Select(u => u.Email).Contains(newUser.Email)) if (users.Select(u => u.Email).Contains(newUser.Email))
throw new InvalidOperationException("This Email is already used"); throw new InvalidOperationException("This Email is already used");
newUser.Password = _profileLogic.HashPassword(newUser.Password); newUser.Password = _profileLogic.HashPassword(newUser.Password);
OldUser userCreated = _userService.Create(newUser); //OldUser userCreated = _userService.Create(newUser);
return new OkObjectResult(userCreated.ToDTO()); _myInfoMateDbContext.Add(newUser);
_myInfoMateDbContext.SaveChanges();
return new OkObjectResult(newUser.ToDTO());
} }
catch (ArgumentNullException ex) catch (ArgumentNullException ex)
{ {
@ -139,21 +156,27 @@ namespace ManagerService.Controllers
[ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 404)]
[ProducesResponseType(typeof(string), 500)] [ProducesResponseType(typeof(string), 500)]
[HttpPut] [HttpPut]
public ObjectResult UpdateUser([FromBody] OldUser updatedUser) public ObjectResult UpdateUser([FromBody] UserDetailDTO updatedUser)
{ {
try try
{ {
if (updatedUser == null) if (updatedUser == null)
throw new ArgumentNullException("User param is null"); throw new ArgumentNullException("User param is null");
OldUser user = _userService.GetById(updatedUser.Id); User user = _myInfoMateDbContext.Users.FirstOrDefault(u => u.Id == updatedUser.id);
//OldUser user = _userService.GetById(updatedUser.Id);
if (user == null) if (user == null)
throw new KeyNotFoundException("User does not exist"); throw new KeyNotFoundException("User does not exist");
OldUser userModified = _userService.Update(updatedUser.Id, updatedUser); //OldUser userModified = _userService.Update(updatedUser.Id, updatedUser);
user.FirstName = updatedUser.firstName;
user.LastName = updatedUser.lastName;
// TODO other field ?
return new OkObjectResult(userModified.ToDTO()); _myInfoMateDbContext.SaveChanges();
return new OkObjectResult(user.ToDTO());
} }
catch (ArgumentNullException ex) catch (ArgumentNullException ex)
{ {
@ -186,12 +209,15 @@ namespace ManagerService.Controllers
if (id == null) if (id == null)
throw new ArgumentNullException("User param is null"); throw new ArgumentNullException("User param is null");
OldUser user = _userService.GetById(id); User user = _myInfoMateDbContext.Users.FirstOrDefault(u => u.Id == id);
//OldUser user = _userService.GetById(id);
if (user == null) if (user == null)
throw new KeyNotFoundException("User does not exist"); throw new KeyNotFoundException("User does not exist");
_userService.Remove(id); //_userService.Remove(id);
_myInfoMateDbContext.Remove(user);
_myInfoMateDbContext.SaveChanges();
return new ObjectResult("The user has been deleted") { StatusCode = 202 }; return new ObjectResult("The user has been deleted") { StatusCode = 202 };

View File

@ -23,16 +23,6 @@ namespace ManagerService.DTOs
public List<string> sectionIds { get; set; } public List<string> sectionIds { get; set; }
public string loaderImageId { get; set; } // == ResourceId public string loaderImageId { get; set; } // == ResourceId
public string loaderImageUrl { get; set; } // == Image url public string loaderImageUrl { get; set; } // == Image url
public string weatherCity { get; set; } // Weather City // TODO REMOVE
public DateTimeOffset? weatherUpdatedDate { get; set; } // Weather date update (to only refresh) // TODO REMOVE
public string weatherResult { get; set; } // Weather result // TODO REMOVE
public bool isWeather // TODO REMOVE
{
get
{
return weatherCity != null && weatherCity.Trim().Length > 0;
}
}
public bool isDate { get; set; } public bool isDate { get; set; }
public bool isHour { get; set; } public bool isHour { get; set; }

View File

@ -6,5 +6,6 @@
public string email { get; set; } public string email { get; set; }
public string firstName { get; set; } public string firstName { get; set; }
public string lastName { get; set; } public string lastName { get; set; }
public string instanceId { get; set; }
} }
} }

View File

@ -70,15 +70,6 @@ namespace ManagerService.Data
/*[BsonElement("LoaderImageUrl")]*/ /*[BsonElement("LoaderImageUrl")]*/
public string LoaderImageUrl { get; set; } 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")]*/ /*[BsonElement("IsDate")]*/
public bool IsDate { get; set; } public bool IsDate { get; set; }
@ -105,9 +96,6 @@ namespace ManagerService.Data
imageSource = ImageSource, imageSource = ImageSource,
loaderImageId = LoaderImageId, loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl, loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
weatherUpdatedDate = WeatherUpdatedDate,
weatherResult = WeatherResult,
dateCreation = DateCreation, dateCreation = DateCreation,
primaryColor = PrimaryColor, primaryColor = PrimaryColor,
languages = Languages, languages = Languages,
@ -135,7 +123,6 @@ namespace ManagerService.Data
imageSource = ImageSource, imageSource = ImageSource,
loaderImageId = LoaderImageId, loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl, loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
dateCreation = DateCreation, dateCreation = DateCreation,
primaryColor = PrimaryColor, primaryColor = PrimaryColor,
languages = Languages, languages = Languages,

View File

@ -95,9 +95,6 @@ namespace ManagerService.Data
imageSource = ImageSource, imageSource = ImageSource,
loaderImageId = LoaderImageId, loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl, loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
weatherUpdatedDate = WeatherUpdatedDate,
weatherResult = WeatherResult,
dateCreation = DateCreation, dateCreation = DateCreation,
primaryColor = PrimaryColor, primaryColor = PrimaryColor,
languages = Languages, languages = Languages,
@ -125,7 +122,6 @@ namespace ManagerService.Data
imageSource = ImageSource, imageSource = ImageSource,
loaderImageId = LoaderImageId, loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl, loaderImageUrl = LoaderImageUrl,
weatherCity = WeatherCity,
dateCreation = DateCreation, dateCreation = DateCreation,
primaryColor = PrimaryColor, primaryColor = PrimaryColor,
languages = Languages, languages = Languages,

View File

@ -55,6 +55,7 @@ namespace ManagerService.Data
email = Email, email = Email,
firstName = FirstName, firstName = FirstName,
lastName = LastName, lastName = LastName,
instanceId = InstanceId,
}; };
} }

View File

@ -0,0 +1,826 @@
// <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("20250319134251_CleanWeatherInConfiguration")]
partial class CleanWeatherInConfiguration
{
/// <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.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>("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.HasIndex("ConfigurationId");
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<string>("PinCode")
.HasColumnType("text");
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.Device", b =>
{
b.HasOne("ManagerService.Data.Configuration", "Configuration")
.WithMany()
.HasForeignKey("ConfigurationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Configuration");
});
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,49 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ManagerService.Migrations
{
/// <inheritdoc />
public partial class CleanWeatherInConfiguration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "WeatherCity",
table: "Configurations");
migrationBuilder.DropColumn(
name: "WeatherResult",
table: "Configurations");
migrationBuilder.DropColumn(
name: "WeatherUpdatedDate",
table: "Configurations");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "WeatherCity",
table: "Configurations",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "WeatherResult",
table: "Configurations",
type: "text",
nullable: true);
migrationBuilder.AddColumn<DateTimeOffset>(
name: "WeatherUpdatedDate",
table: "Configurations",
type: "timestamp with time zone",
nullable: true);
}
}
}

View File

@ -91,15 +91,6 @@ namespace ManagerService.Migrations
.IsRequired() .IsRequired()
.HasColumnType("jsonb"); .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.HasKey("Id");
b.ToTable("Configurations"); b.ToTable("Configurations");