From 7fb3feace42f13bea63c87ceafd76eacda8ebf2f Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 19 Mar 2025 10:57:53 +0100 Subject: [PATCH] Instance controller done --- .../Controllers/ConfigurationController.cs | 2 +- .../Controllers/InstanceController.cs | 46 +- ManagerService/DTOs/InstanceDTO.cs | 4 +- ManagerService/DTOs/OldInstanceDTO.cs | 12 + ManagerService/DTOs/TokenDTO.cs | 2 +- ManagerService/Data/Instance.cs | 13 +- ManagerService/Data/OldInstance.cs | 4 +- ...19095517_UpdatePinCodeToString.Designer.cs | 825 ++++++++++++++++++ .../20250319095517_UpdatePinCodeToString.cs | 36 + .../MyInfoMateDbContextModelSnapshot.cs | 4 +- ManagerService/Startup.cs | 13 +- 11 files changed, 932 insertions(+), 29 deletions(-) create mode 100644 ManagerService/DTOs/OldInstanceDTO.cs create mode 100644 ManagerService/Migrations/20250319095517_UpdatePinCodeToString.Designer.cs create mode 100644 ManagerService/Migrations/20250319095517_UpdatePinCodeToString.cs diff --git a/ManagerService/Controllers/ConfigurationController.cs b/ManagerService/Controllers/ConfigurationController.cs index 4bc30ad..aac6d30 100644 --- a/ManagerService/Controllers/ConfigurationController.cs +++ b/ManagerService/Controllers/ConfigurationController.cs @@ -85,7 +85,7 @@ namespace ManagerService.Controllers [ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 500)] [HttpGet("byPin")] - public ObjectResult GetConfigurationsByPinCode([FromQuery] int pinCode) + public ObjectResult GetConfigurationsByPinCode([FromQuery] string pinCode) { try { diff --git a/ManagerService/Controllers/InstanceController.cs b/ManagerService/Controllers/InstanceController.cs index fc3cdaf..9e5c75c 100644 --- a/ManagerService/Controllers/InstanceController.cs +++ b/ManagerService/Controllers/InstanceController.cs @@ -5,6 +5,7 @@ using Manager.Services; using ManagerService.Data; using ManagerService.DTOs; using ManagerService.Helpers; +using ManagerService.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; @@ -23,6 +24,7 @@ namespace ManagerService.Controllers private UserDatabaseService _userService; private readonly ILogger _logger; private readonly ProfileLogic _profileLogic; + IHexIdGeneratorService idService = new HexIdGeneratorService(); public InstanceController(ILogger logger, InstanceDatabaseService instanceService, UserDatabaseService userService, ProfileLogic profileLogic, MyInfoMateDbContext myInfoMateDbContext) { @@ -97,27 +99,30 @@ namespace ManagerService.Controllers [ProducesResponseType(typeof(string), 409)] [ProducesResponseType(typeof(string), 500)] [HttpPost] - public ObjectResult CreateInstance([FromBody] Instance newInstance) + public ObjectResult CreateInstance([FromBody] InstanceDTO newInstance) { try { if (newInstance == null) throw new ArgumentNullException("instance param is null"); - newInstance.DateCreation = DateTime.Now; + Instance instance = new Instance().FromDTO(newInstance); + + instance.DateCreation = DateTime.Now.ToUniversalTime(); + instance.Id = idService.GenerateHexId(); /*List instances = _instanceService.GetAll(); Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == id);*/ - if (_myInfoMateDbContext.Instances.Any(i => i.Name == newInstance.Name)) + if (_myInfoMateDbContext.Instances.Any(i => i.Name == instance.Name)) throw new InvalidOperationException("This name is already used"); //OldInstance instanceCreated = _instanceService.Create(newInstance); - _myInfoMateDbContext.Instances.Add(newInstance); + _myInfoMateDbContext.Instances.Add(instance); _myInfoMateDbContext.SaveChanges(); - return new OkObjectResult(newInstance.ToDTO()); + return new OkObjectResult(instance.ToDTO()); } catch (ArgumentNullException ex) { @@ -143,20 +148,23 @@ namespace ManagerService.Controllers [ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 500)] [HttpPut] - public ObjectResult Updateinstance([FromBody] Instance updatedInstance) + public ObjectResult Updateinstance([FromBody] InstanceDTO updatedInstance) { try { if (updatedInstance == null) throw new ArgumentNullException("instance param is null"); - Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == 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 = updatedInstance; + instance.DateCreation = updatedInstance.dateCreation != null ? updatedInstance.dateCreation.Value : instance.DateCreation; + instance.Name= updatedInstance.name != null ? updatedInstance.name : instance.Name; + instance.PinCode = updatedInstance.pinCode != null ? updatedInstance.pinCode : instance.PinCode; + //OldInstance instanceModified = _instanceService.Update(updatedInstance.Id, instance); _myInfoMateDbContext.SaveChanges(); @@ -185,11 +193,12 @@ namespace ManagerService.Controllers [ProducesResponseType(typeof(string), 404)] [ProducesResponseType(typeof(string), 500)] [HttpGet("byPin")] - public ObjectResult GetInstanceByPinCode([FromQuery] int pinCode) + public ObjectResult GetInstanceByPinCode([FromQuery] string pinCode) { try { - OldInstance instance = _instanceService.GetByPinCode(pinCode); + //OldInstance instance = _instanceService.GetByPinCode(pinCode); + Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.PinCode == pinCode); if (instance == null) throw new KeyNotFoundException("Instance was not found"); @@ -223,20 +232,27 @@ namespace ManagerService.Controllers if (id == null) throw new ArgumentNullException("instance param is null"); - OldInstance instance = _instanceService.GetById(id); + //OldInstance instance = _instanceService.GetById(id); + Instance instance = _myInfoMateDbContext.Instances.FirstOrDefault(i => i.Id == id); // Delete all user in instance - List users = _userService.GetByInstanceId(instance.Id); + //List users = _userService.GetByInstanceId(instance.Id); + List users = _myInfoMateDbContext.Users.Where(u => u.InstanceId == instance.Id).ToList(); - foreach(var user in users) + + foreach (var user in users) { - _userService.Remove(user.Id); + //_userService.Remove(user.Id); + _myInfoMateDbContext.Users.Remove(user); } if (instance == null) throw new KeyNotFoundException("instance does not exist"); - _instanceService.Remove(id); + //_instanceService.Remove(id); + _myInfoMateDbContext.Instances.Remove(instance); + + _myInfoMateDbContext.SaveChanges(); return new ObjectResult("The instance has been deleted") { StatusCode = 202 }; diff --git a/ManagerService/DTOs/InstanceDTO.cs b/ManagerService/DTOs/InstanceDTO.cs index ba0a837..4d849f9 100644 --- a/ManagerService/DTOs/InstanceDTO.cs +++ b/ManagerService/DTOs/InstanceDTO.cs @@ -6,7 +6,7 @@ namespace ManagerService.DTOs { public string id { get; set; } public string name { get; set; } - public DateTime dateCreation { get; set; } - public int? pinCode { get; set; } + public DateTime? dateCreation { get; set; } + public string pinCode { get; set; } } } diff --git a/ManagerService/DTOs/OldInstanceDTO.cs b/ManagerService/DTOs/OldInstanceDTO.cs new file mode 100644 index 0000000..e883bb3 --- /dev/null +++ b/ManagerService/DTOs/OldInstanceDTO.cs @@ -0,0 +1,12 @@ +using System; + +namespace ManagerService.DTOs +{ + public class OldInstanceDTO + { + public string id { get; set; } + public string name { get; set; } + public DateTime? dateCreation { get; set; } + public int? pinCode { get; set; } + } +} diff --git a/ManagerService/DTOs/TokenDTO.cs b/ManagerService/DTOs/TokenDTO.cs index 2eb3ea2..7b0cd0b 100644 --- a/ManagerService/DTOs/TokenDTO.cs +++ b/ManagerService/DTOs/TokenDTO.cs @@ -11,6 +11,6 @@ namespace ManagerService.DTOs public int expires_in { get; set; } public DateTimeOffset expiration { get; set; } public string instanceId { get; set; } - public int? pinCode { get; set; } + public string pinCode { get; set; } } } diff --git a/ManagerService/Data/Instance.cs b/ManagerService/Data/Instance.cs index c79b3fb..948ee0a 100644 --- a/ManagerService/Data/Instance.cs +++ b/ManagerService/Data/Instance.cs @@ -24,7 +24,7 @@ namespace ManagerService.Data public DateTime DateCreation { get; set; } /*[BsonElement("PinCode")]*/ - public int? PinCode { get; set; } + public string PinCode { get; set; } public InstanceDTO ToDTO() { @@ -37,5 +37,16 @@ namespace ManagerService.Data }; } + public Instance FromDTO(InstanceDTO instanceDTO) + { + return new Instance() + { + Id = instanceDTO.id, + Name = instanceDTO.name, + DateCreation = instanceDTO.dateCreation != null ? instanceDTO.dateCreation.Value : DateTime.Now.ToUniversalTime(), + PinCode = instanceDTO.pinCode + }; + } + } } diff --git a/ManagerService/Data/OldInstance.cs b/ManagerService/Data/OldInstance.cs index bbeaf84..031a9f8 100644 --- a/ManagerService/Data/OldInstance.cs +++ b/ManagerService/Data/OldInstance.cs @@ -24,9 +24,9 @@ namespace ManagerService.Data [BsonElement("PinCode")] public int? PinCode { get; set; } - public InstanceDTO ToDTO() + public OldInstanceDTO ToDTO() { - return new InstanceDTO() + return new OldInstanceDTO() { id = Id, name = Name, diff --git a/ManagerService/Migrations/20250319095517_UpdatePinCodeToString.Designer.cs b/ManagerService/Migrations/20250319095517_UpdatePinCodeToString.Designer.cs new file mode 100644 index 0000000..5315a60 --- /dev/null +++ b/ManagerService/Migrations/20250319095517_UpdatePinCodeToString.Designer.cs @@ -0,0 +1,825 @@ +// +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("20250319095517_UpdatePinCodeToString")] + partial class UpdatePinCodeToString + { + /// + 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("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("ImageId") + .HasColumnType("text"); + + b.Property("ImageSource") + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsDate") + .HasColumnType("boolean"); + + b.Property("IsHour") + .HasColumnType("boolean"); + + b.Property("IsMobile") + .HasColumnType("boolean"); + + b.Property("IsOffline") + .HasColumnType("boolean"); + + b.Property("IsSectionImageBackground") + .HasColumnType("boolean"); + + b.Property("IsTablet") + .HasColumnType("boolean"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text"); + + b.PrimitiveCollection>("Languages") + .HasColumnType("text[]"); + + b.Property("LoaderImageId") + .HasColumnType("text"); + + b.Property("LoaderImageUrl") + .HasColumnType("text"); + + b.Property("PrimaryColor") + .HasColumnType("text"); + + b.Property("RoundedValue") + .HasColumnType("integer"); + + b.Property("ScreenPercentageSectionsMainPage") + .HasColumnType("integer"); + + b.Property("SecondaryColor") + .HasColumnType("text"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("WeatherCity") + .HasColumnType("text"); + + b.Property("WeatherResult") + .HasColumnType("text"); + + b.Property("WeatherUpdatedDate") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Configurations"); + }); + + modelBuilder.Entity("ManagerService.Data.Device", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BatteryLevel") + .HasColumnType("text"); + + b.Property("Configuration") + .HasColumnType("text"); + + b.Property("ConfigurationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Connected") + .HasColumnType("boolean"); + + b.Property("ConnectionLevel") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("DateUpdate") + .HasColumnType("timestamp with time zone"); + + b.Property("Identifier") + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IpAddressETH") + .IsRequired() + .HasColumnType("text"); + + b.Property("IpAddressWLAN") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastBatteryLevel") + .HasColumnType("timestamp with time zone"); + + b.Property("LastConnectionLevel") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("ManagerService.Data.Instance", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("PinCode") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Instances"); + }); + + modelBuilder.Entity("ManagerService.Data.Resource", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("Url") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Resources"); + }); + + modelBuilder.Entity("ManagerService.Data.Section", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("BeaconId") + .HasColumnType("integer"); + + b.Property("ConfigurationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property>("Description") + .HasColumnType("jsonb"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)"); + + b.Property("ImageId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImageSource") + .IsRequired() + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsBeacon") + .HasColumnType("boolean"); + + b.Property("IsSubSection") + .HasColumnType("boolean"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text"); + + b.Property("Latitude") + .HasColumnType("text"); + + b.Property("Longitude") + .HasColumnType("text"); + + b.Property("MeterZoneGPS") + .HasColumnType("integer"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ParentId") + .HasColumnType("text"); + + b.Property("SectionMenuId") + .HasColumnType("text"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Icon") + .HasColumnType("text"); + + b.Property>("Label") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionMapId"); + + b.ToTable("Categorie"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Description") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("SectionArticleId") + .HasColumnType("text"); + + b.Property("SectionSliderId") + .HasColumnType("text"); + + b.Property>("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategorieId") + .HasColumnType("integer"); + + b.Property>("Contents") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Description") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Email") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("ImageResourceId") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Latitude") + .HasColumnType("text"); + + b.Property("Longitude") + .HasColumnType("text"); + + b.Property>("Phone") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Prices") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Schedules") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionMapId") + .HasColumnType("text"); + + b.Property>("Site") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("Title") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionMapId"); + + b.ToTable("GeoPoint"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.OrderedTranslationAndResource", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("SectionPdfId") + .HasColumnType("text"); + + b.Property>("TranslationAndResources") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasKey("Id"); + + b.HasIndex("SectionPdfId"); + + b.ToTable("OrderedTranslationAndResource"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.QuizQuestion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property>("Label") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Order") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property>("Responses") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("SectionQuizId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ResourceId"); + + b.HasIndex("SectionQuizId"); + + b.ToTable("QuizQuestion"); + }); + + modelBuilder.Entity("ManagerService.Data.User", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("DateCreation") + .HasColumnType("timestamp with time zone"); + + b.Property("Email") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstName") + .HasColumnType("text"); + + b.Property("InstanceId") + .IsRequired() + .HasColumnType("text"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("Token") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionAgenda", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("mapProvider") + .HasColumnType("integer"); + + b.Property>("resourceIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.HasDiscriminator().HasValue("Agenda"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionArticle", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("audioIds") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("content") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("isContentTop") + .HasColumnType("boolean"); + + b.Property("isReadAudioAuto") + .HasColumnType("boolean"); + + b.HasDiscriminator().HasValue("Article"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionMap", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("CenterLatitude") + .HasColumnType("text"); + + b.Property("CenterLongitude") + .HasColumnType("text"); + + b.Property("MapProvider") + .HasColumnType("integer"); + + b.Property("MapType") + .HasColumnType("integer"); + + b.Property("MapTypeMapbox") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("text"); + + b.Property("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("Cols") + .HasColumnType("integer"); + + b.Property("ContentId") + .HasColumnType("text"); + + b.Property("ContentId1") + .HasColumnType("integer"); + + b.Property>("MessageDebut") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("MessageFin") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("Rows") + .HasColumnType("integer"); + + b.HasIndex("ContentId1"); + + b.HasDiscriminator().HasValue("Puzzle"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionQuiz", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property>("BadLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("GoodLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("GreatLevel") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("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("Source") + .IsRequired() + .HasColumnType("text"); + + b.HasDiscriminator().HasValue("Video"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeather", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Result") + .HasColumnType("text"); + + b.Property("UpdatedDate") + .HasColumnType("timestamp with time zone"); + + b.HasDiscriminator().HasValue("Weather"); + }); + + modelBuilder.Entity("ManagerService.Data.SubSection.SectionWeb", b => + { + b.HasBaseType("ManagerService.Data.Section"); + + b.Property("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 + } + } +} diff --git a/ManagerService/Migrations/20250319095517_UpdatePinCodeToString.cs b/ManagerService/Migrations/20250319095517_UpdatePinCodeToString.cs new file mode 100644 index 0000000..4b74428 --- /dev/null +++ b/ManagerService/Migrations/20250319095517_UpdatePinCodeToString.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ManagerService.Migrations +{ + /// + public partial class UpdatePinCodeToString : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "PinCode", + table: "Instances", + type: "text", + nullable: true, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "PinCode", + table: "Instances", + type: "integer", + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + } + } +} diff --git a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs index 55d4d09..9cd95f9 100644 --- a/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs +++ b/ManagerService/Migrations/MyInfoMateDbContextModelSnapshot.cs @@ -173,8 +173,8 @@ namespace ManagerService.Migrations .IsRequired() .HasColumnType("text"); - b.Property("PinCode") - .HasColumnType("integer"); + b.Property("PinCode") + .HasColumnType("text"); b.HasKey("Id"); diff --git a/ManagerService/Startup.cs b/ManagerService/Startup.cs index ca7ba4e..be449e2 100644 --- a/ManagerService/Startup.cs +++ b/ManagerService/Startup.cs @@ -142,13 +142,16 @@ namespace ManagerService #endif services.AddScoped(typeof(ProfileLogic)); services.AddScoped(); - /*services.AddScoped(); + services.AddScoped(); + + // OLD services + services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped();*/ - services.AddScoped(); - /*services.AddScoped(); - services.AddScoped();*/ + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + var connectionString = Configuration.GetConnectionString("PostgresConnection");