finalizare 1.0

This commit is contained in:
andrei-mihnea-cerbu
2024-05-21 12:10:53 +03:00
parent f7795f7519
commit 1cc1d34003
11268 changed files with 2102399 additions and 10909 deletions
@@ -0,0 +1,111 @@
// <auto-generated />
using System;
using Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Infrastructure.Migrations
{
[DbContext(typeof(HealthcareManagerDatabase))]
[Migration("20240519210912_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Domain.Entities.Admin", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Email")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Password")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Admins");
});
modelBuilder.Entity("Domain.Entities.Doctor", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Description")
.HasColumnType("text");
b.Property<string>("Email")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Password")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Doctors");
});
modelBuilder.Entity("Domain.Entities.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Content")
.IsRequired()
.HasColumnType("bytea");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.ToTable("MedicalHistories");
});
modelBuilder.Entity("Domain.Entities.Patient", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Email")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Password")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Patients");
});
#pragma warning restore 612, 618
}
}
}
@@ -3,14 +3,28 @@ using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Admins",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: true),
Email = table.Column<string>(type: "text", nullable: true),
Password = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Admins", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Doctors",
columns: table => new
@@ -50,13 +64,16 @@ namespace Infrastructure.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_Pacients", x => x.Id);
table.PrimaryKey("PK_Patients", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Admins");
migrationBuilder.DropTable(
name: "Doctors");
@@ -67,4 +84,3 @@ namespace Infrastructure.Migrations
name: "Patients");
}
}
}
@@ -1,6 +1,6 @@
// <auto-generated />
using System;
using Infrastructure.Data;
using Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
@@ -12,20 +12,40 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Infrastructure.Migrations
{
[DbContext(typeof(HealthcareManagerDatabase))]
[Migration("20240404131625_InitialCreate")]
partial class InitialCreate
[Migration("20240519211516_SeedAdminTable")]
partial class SeedAdminTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("ProductVersion", "8.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Core.Entities.Doctor", b =>
modelBuilder.Entity("Domain.Entities.Admin", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Email")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Password")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Admins");
});
modelBuilder.Entity("Domain.Entities.Doctor", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -48,13 +68,13 @@ namespace Infrastructure.Migrations
b.ToTable("Doctors");
});
modelBuilder.Entity("Core.Entities.MedicalHistory", b =>
modelBuilder.Entity("Domain.Entities.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<byte[]>("Description")
b.Property<byte[]>("Content")
.IsRequired()
.HasColumnType("bytea");
@@ -66,7 +86,7 @@ namespace Infrastructure.Migrations
b.ToTable("MedicalHistories");
});
modelBuilder.Entity("Core.Entities.Pacient", b =>
modelBuilder.Entity("Domain.Entities.Patient", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -83,7 +103,7 @@ namespace Infrastructure.Migrations
b.HasKey("Id");
b.ToTable("Pacients");
b.ToTable("Patients");
});
#pragma warning restore 612, 618
}
@@ -0,0 +1,64 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using Application.Services.HashingAlgorithms; // Ensure this namespace matches your actual service namespace
using Infrastructure.Services.HashingAlgorithms; // Ensure this namespace matches your actual service namespace
using Domain.Entities;
#nullable disable
namespace Infrastructure.Migrations;
/// <inheritdoc />
public partial class SeedAdminTable : Migration{
private readonly IConfiguration _configuration;
private readonly IHashingAlgorithms _hashingAlgorithms;
public SeedAdminTable()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../API"))
.AddJsonFile("appsettings.json");
_configuration = builder.Build();
// Build the service provider
var serviceProvider = new ServiceCollection()
.AddSingleton<IHashingAlgorithms, HashingAlgorithms>()
.BuildServiceProvider();
// Resolve the hashing service
_hashingAlgorithms = serviceProvider.GetService<IHashingAlgorithms>();
}
protected override void Up(MigrationBuilder migrationBuilder)
{
var adminName = _configuration["AdminSettings:Name"];
var adminEmail = _configuration["AdminSettings:Email"];
var adminPassword = _configuration["AdminSettings:Password"];
var adminUser = new Admin();
adminUser.SetName(adminName);
adminUser.SetEmail(adminEmail);
adminUser.SetPassword(_hashingAlgorithms.Sha256Algorithm(adminPassword));
migrationBuilder.InsertData(
table: "Admins",
columns: new[] { "Id", "Name", "Email", "Password" },
values: new object[] { adminUser.Id, adminUser.Name, adminUser.Email, adminUser.Password }
);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
var adminEmail = _configuration["AdminSettings:Email"];
migrationBuilder.DeleteData(
table: "Admins",
keyColumn: "Email",
keyValue: adminEmail
);
}
}
@@ -1,6 +1,6 @@
// <auto-generated />
using System;
using Infrastructure.Data;
using Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@@ -11,18 +11,38 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Infrastructure.Migrations
{
[DbContext(typeof(HealthcareManagerDatabase))]
partial class HealthcareManagerContextModelSnapshot : ModelSnapshot
partial class HealthcareManagerDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("ProductVersion", "8.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Core.Entities.Doctor", b =>
modelBuilder.Entity("Domain.Entities.Admin", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Email")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Password")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Admins");
});
modelBuilder.Entity("Domain.Entities.Doctor", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -45,7 +65,7 @@ namespace Infrastructure.Migrations
b.ToTable("Doctors");
});
modelBuilder.Entity("Core.Entities.MedicalHistory", b =>
modelBuilder.Entity("Domain.Entities.MedicalHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -63,7 +83,7 @@ namespace Infrastructure.Migrations
b.ToTable("MedicalHistories");
});
modelBuilder.Entity("Core.Entities.Patient", b =>
modelBuilder.Entity("Domain.Entities.Patient", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()