Instance controller done
This commit is contained in:
parent
11cfeab210
commit
7fb3feace4
@ -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
|
||||
{
|
||||
|
||||
@ -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<InstanceController> _logger;
|
||||
private readonly ProfileLogic _profileLogic;
|
||||
IHexIdGeneratorService idService = new HexIdGeneratorService();
|
||||
|
||||
public InstanceController(ILogger<InstanceController> 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<OldInstance> 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<OldUser> users = _userService.GetByInstanceId(instance.Id);
|
||||
//List<OldUser> users = _userService.GetByInstanceId(instance.Id);
|
||||
List<User> users = _myInfoMateDbContext.Users.Where(u => u.InstanceId == instance.Id).ToList();
|
||||
|
||||
|
||||
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 };
|
||||
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
12
ManagerService/DTOs/OldInstanceDTO.cs
Normal file
12
ManagerService/DTOs/OldInstanceDTO.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
825
ManagerService/Migrations/20250319095517_UpdatePinCodeToString.Designer.cs
generated
Normal file
825
ManagerService/Migrations/20250319095517_UpdatePinCodeToString.Designer.cs
generated
Normal 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("20250319095517_UpdatePinCodeToString")]
|
||||
partial class UpdatePinCodeToString
|
||||
{
|
||||
/// <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<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.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
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ManagerService.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class UpdatePinCodeToString : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "PinCode",
|
||||
table: "Instances",
|
||||
type: "text",
|
||||
nullable: true,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "integer",
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "PinCode",
|
||||
table: "Instances",
|
||||
type: "integer",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "text",
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,8 +173,8 @@ namespace ManagerService.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("PinCode")
|
||||
.HasColumnType("integer");
|
||||
b.Property<string>("PinCode")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
|
||||
@ -142,13 +142,16 @@ namespace ManagerService
|
||||
#endif
|
||||
services.AddScoped(typeof(ProfileLogic));
|
||||
services.AddScoped<TokensService>();
|
||||
/*services.AddScoped<UserDatabaseService>();
|
||||
services.AddScoped<LanguageInit>();
|
||||
|
||||
// OLD services
|
||||
services.AddScoped<UserDatabaseService>();
|
||||
services.AddScoped<SectionDatabaseService>();
|
||||
services.AddScoped<ConfigurationDatabaseService>();
|
||||
services.AddScoped<ResourceDatabaseService>();*/
|
||||
services.AddScoped<LanguageInit>();
|
||||
/*services.AddScoped<DeviceDatabaseService>();
|
||||
services.AddScoped<InstanceDatabaseService>();*/
|
||||
services.AddScoped<ResourceDatabaseService>();
|
||||
services.AddScoped<DeviceDatabaseService>();
|
||||
services.AddScoped<InstanceDatabaseService>();
|
||||
|
||||
|
||||
var connectionString = Configuration.GetConnectionString("PostgresConnection");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user