diff --git a/MagicCarpetProject/MagicCarpetDatabase/DefaultConfigurationDatabase.cs b/MagicCarpetProject/MagicCarpetDatabase/DefaultConfigurationDatabase.cs
new file mode 100644
index 0000000..8ff767d
--- /dev/null
+++ b/MagicCarpetProject/MagicCarpetDatabase/DefaultConfigurationDatabase.cs
@@ -0,0 +1,8 @@
+using MagicCarpetContracts.Infrastructure;
+
+namespace MagicCarpetDatabase;
+
+class DefaultConfigurationDatabase : IConfigurationDatabase
+{
+ public string ConnectionString => "";
+}
\ No newline at end of file
diff --git a/MagicCarpetProject/MagicCarpetDatabase/MagicCarpetDatabase.csproj b/MagicCarpetProject/MagicCarpetDatabase/MagicCarpetDatabase.csproj
index be81d75..235ae58 100644
--- a/MagicCarpetProject/MagicCarpetDatabase/MagicCarpetDatabase.csproj
+++ b/MagicCarpetProject/MagicCarpetDatabase/MagicCarpetDatabase.csproj
@@ -8,7 +8,11 @@
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/MagicCarpetProject/MagicCarpetDatabase/Migrations/20250408110058_FirstMigration.Designer.cs b/MagicCarpetProject/MagicCarpetDatabase/Migrations/20250408110058_FirstMigration.Designer.cs
new file mode 100644
index 0000000..b9d85e0
--- /dev/null
+++ b/MagicCarpetProject/MagicCarpetDatabase/Migrations/20250408110058_FirstMigration.Designer.cs
@@ -0,0 +1,333 @@
+//
+using System;
+using MagicCarpetDatabase;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace MagicCarpetDatabase.Migrations
+{
+ [DbContext(typeof(MagicCarpetDbContext))]
+ [Migration("20250408110058_FirstMigration")]
+ partial class FirstMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Client", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("DiscountSize")
+ .HasColumnType("double precision");
+
+ b.Property("FIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("PhoneNumber")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PhoneNumber")
+ .IsUnique();
+
+ b.ToTable("Clients");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Employee", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("BirthDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("EmploymentDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("FIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("PostId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Employees");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Post", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("ChangeDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsActual")
+ .HasColumnType("boolean");
+
+ b.Property("PostId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("PostName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("PostType")
+ .HasColumnType("integer");
+
+ b.Property("Salary")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PostId", "IsActual")
+ .IsUnique()
+ .HasFilter("\"IsActual\" = TRUE");
+
+ b.HasIndex("PostName", "IsActual")
+ .IsUnique()
+ .HasFilter("\"IsActual\" = TRUE");
+
+ b.ToTable("Posts");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Salary", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("EmployeeId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("EmployeeSalary")
+ .HasColumnType("double precision");
+
+ b.Property("SalaryDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmployeeId");
+
+ b.ToTable("Salaries");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Sale", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("ClientId")
+ .HasColumnType("text");
+
+ b.Property("Discount")
+ .HasColumnType("double precision");
+
+ b.Property("DiscountType")
+ .HasColumnType("integer");
+
+ b.Property("EmployeeId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsCancel")
+ .HasColumnType("boolean");
+
+ b.Property("SaleDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("EmployeeId");
+
+ b.ToTable("Sales");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.SaleTour", b =>
+ {
+ b.Property("SaleId")
+ .HasColumnType("text");
+
+ b.Property("TourId")
+ .HasColumnType("text");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.HasKey("SaleId", "TourId");
+
+ b.HasIndex("TourId");
+
+ b.ToTable("SaleTours");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Tour", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.Property("TourCountry")
+ .HasColumnType("text");
+
+ b.Property("TourName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("TourType")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TourName")
+ .IsUnique();
+
+ b.ToTable("Tours");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.TourHistory", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("ChangeDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("OldPrice")
+ .HasColumnType("double precision");
+
+ b.Property("TourId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TourId");
+
+ b.ToTable("TourHistories");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Salary", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Employee", "Employee")
+ .WithMany("Salaries")
+ .HasForeignKey("EmployeeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Employee");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Sale", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Client", "Client")
+ .WithMany("Sales")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.HasOne("MagicCarpetDatabase.Models.Employee", "Employee")
+ .WithMany("Sales")
+ .HasForeignKey("EmployeeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Employee");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.SaleTour", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Sale", "Sale")
+ .WithMany("SaleTours")
+ .HasForeignKey("SaleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("MagicCarpetDatabase.Models.Tour", "Tour")
+ .WithMany("SaleTours")
+ .HasForeignKey("TourId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Sale");
+
+ b.Navigation("Tour");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.TourHistory", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Tour", "Tour")
+ .WithMany("TourHistories")
+ .HasForeignKey("TourId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Tour");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Client", b =>
+ {
+ b.Navigation("Sales");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Employee", b =>
+ {
+ b.Navigation("Salaries");
+
+ b.Navigation("Sales");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Sale", b =>
+ {
+ b.Navigation("SaleTours");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Tour", b =>
+ {
+ b.Navigation("SaleTours");
+
+ b.Navigation("TourHistories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/MagicCarpetProject/MagicCarpetDatabase/Migrations/20250408110058_FirstMigration.cs b/MagicCarpetProject/MagicCarpetDatabase/Migrations/20250408110058_FirstMigration.cs
new file mode 100644
index 0000000..6becb10
--- /dev/null
+++ b/MagicCarpetProject/MagicCarpetDatabase/Migrations/20250408110058_FirstMigration.cs
@@ -0,0 +1,253 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MagicCarpetDatabase.Migrations
+{
+ ///
+ public partial class FirstMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Clients",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ FIO = table.Column(type: "text", nullable: false),
+ PhoneNumber = table.Column(type: "text", nullable: false),
+ DiscountSize = table.Column(type: "double precision", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Clients", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Employees",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ FIO = table.Column(type: "text", nullable: false),
+ Email = table.Column(type: "text", nullable: false),
+ PostId = table.Column(type: "text", nullable: false),
+ BirthDate = table.Column(type: "timestamp with time zone", nullable: false),
+ EmploymentDate = table.Column(type: "timestamp with time zone", nullable: false),
+ IsDeleted = table.Column(type: "boolean", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Employees", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Posts",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ PostId = table.Column(type: "text", nullable: false),
+ PostName = table.Column(type: "text", nullable: false),
+ PostType = table.Column(type: "integer", nullable: false),
+ Salary = table.Column(type: "double precision", nullable: false),
+ IsActual = table.Column(type: "boolean", nullable: false),
+ ChangeDate = table.Column(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Posts", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Tours",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ TourName = table.Column(type: "text", nullable: false),
+ TourCountry = table.Column(type: "text", nullable: true),
+ Price = table.Column(type: "double precision", nullable: false),
+ TourType = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Tours", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Salaries",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ EmployeeId = table.Column(type: "text", nullable: false),
+ SalaryDate = table.Column(type: "timestamp with time zone", nullable: false),
+ EmployeeSalary = table.Column(type: "double precision", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Salaries", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Salaries_Employees_EmployeeId",
+ column: x => x.EmployeeId,
+ principalTable: "Employees",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Sales",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ EmployeeId = table.Column(type: "text", nullable: false),
+ ClientId = table.Column(type: "text", nullable: true),
+ SaleDate = table.Column(type: "timestamp with time zone", nullable: false),
+ Sum = table.Column(type: "double precision", nullable: false),
+ DiscountType = table.Column(type: "integer", nullable: false),
+ Discount = table.Column(type: "double precision", nullable: false),
+ IsCancel = table.Column(type: "boolean", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Sales", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Sales_Clients_ClientId",
+ column: x => x.ClientId,
+ principalTable: "Clients",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.SetNull);
+ table.ForeignKey(
+ name: "FK_Sales_Employees_EmployeeId",
+ column: x => x.EmployeeId,
+ principalTable: "Employees",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "TourHistories",
+ columns: table => new
+ {
+ Id = table.Column(type: "text", nullable: false),
+ TourId = table.Column(type: "text", nullable: false),
+ OldPrice = table.Column(type: "double precision", nullable: false),
+ ChangeDate = table.Column(type: "timestamp with time zone", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_TourHistories", x => x.Id);
+ table.ForeignKey(
+ name: "FK_TourHistories_Tours_TourId",
+ column: x => x.TourId,
+ principalTable: "Tours",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "SaleTours",
+ columns: table => new
+ {
+ SaleId = table.Column(type: "text", nullable: false),
+ TourId = table.Column(type: "text", nullable: false),
+ Count = table.Column(type: "integer", nullable: false),
+ Price = table.Column(type: "double precision", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_SaleTours", x => new { x.SaleId, x.TourId });
+ table.ForeignKey(
+ name: "FK_SaleTours_Sales_SaleId",
+ column: x => x.SaleId,
+ principalTable: "Sales",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_SaleTours_Tours_TourId",
+ column: x => x.TourId,
+ principalTable: "Tours",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Clients_PhoneNumber",
+ table: "Clients",
+ column: "PhoneNumber",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Posts_PostId_IsActual",
+ table: "Posts",
+ columns: new[] { "PostId", "IsActual" },
+ unique: true,
+ filter: "\"IsActual\" = TRUE");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Posts_PostName_IsActual",
+ table: "Posts",
+ columns: new[] { "PostName", "IsActual" },
+ unique: true,
+ filter: "\"IsActual\" = TRUE");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Salaries_EmployeeId",
+ table: "Salaries",
+ column: "EmployeeId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Sales_ClientId",
+ table: "Sales",
+ column: "ClientId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Sales_EmployeeId",
+ table: "Sales",
+ column: "EmployeeId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_SaleTours_TourId",
+ table: "SaleTours",
+ column: "TourId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TourHistories_TourId",
+ table: "TourHistories",
+ column: "TourId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Tours_TourName",
+ table: "Tours",
+ column: "TourName",
+ unique: true);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Posts");
+
+ migrationBuilder.DropTable(
+ name: "Salaries");
+
+ migrationBuilder.DropTable(
+ name: "SaleTours");
+
+ migrationBuilder.DropTable(
+ name: "TourHistories");
+
+ migrationBuilder.DropTable(
+ name: "Sales");
+
+ migrationBuilder.DropTable(
+ name: "Tours");
+
+ migrationBuilder.DropTable(
+ name: "Clients");
+
+ migrationBuilder.DropTable(
+ name: "Employees");
+ }
+ }
+}
diff --git a/MagicCarpetProject/MagicCarpetDatabase/Migrations/MagicCarpetDbContextModelSnapshot.cs b/MagicCarpetProject/MagicCarpetDatabase/Migrations/MagicCarpetDbContextModelSnapshot.cs
new file mode 100644
index 0000000..088f9b3
--- /dev/null
+++ b/MagicCarpetProject/MagicCarpetDatabase/Migrations/MagicCarpetDbContextModelSnapshot.cs
@@ -0,0 +1,330 @@
+//
+using System;
+using MagicCarpetDatabase;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace MagicCarpetDatabase.Migrations
+{
+ [DbContext(typeof(MagicCarpetDbContext))]
+ partial class MagicCarpetDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "9.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Client", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("DiscountSize")
+ .HasColumnType("double precision");
+
+ b.Property("FIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("PhoneNumber")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PhoneNumber")
+ .IsUnique();
+
+ b.ToTable("Clients");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Employee", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("BirthDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("EmploymentDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("FIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("PostId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Employees");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Post", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("ChangeDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("IsActual")
+ .HasColumnType("boolean");
+
+ b.Property("PostId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("PostName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("PostType")
+ .HasColumnType("integer");
+
+ b.Property("Salary")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PostId", "IsActual")
+ .IsUnique()
+ .HasFilter("\"IsActual\" = TRUE");
+
+ b.HasIndex("PostName", "IsActual")
+ .IsUnique()
+ .HasFilter("\"IsActual\" = TRUE");
+
+ b.ToTable("Posts");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Salary", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("EmployeeId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("EmployeeSalary")
+ .HasColumnType("double precision");
+
+ b.Property("SalaryDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmployeeId");
+
+ b.ToTable("Salaries");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Sale", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("ClientId")
+ .HasColumnType("text");
+
+ b.Property("Discount")
+ .HasColumnType("double precision");
+
+ b.Property("DiscountType")
+ .HasColumnType("integer");
+
+ b.Property("EmployeeId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("IsCancel")
+ .HasColumnType("boolean");
+
+ b.Property("SaleDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("EmployeeId");
+
+ b.ToTable("Sales");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.SaleTour", b =>
+ {
+ b.Property("SaleId")
+ .HasColumnType("text");
+
+ b.Property("TourId")
+ .HasColumnType("text");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.HasKey("SaleId", "TourId");
+
+ b.HasIndex("TourId");
+
+ b.ToTable("SaleTours");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Tour", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.Property("TourCountry")
+ .HasColumnType("text");
+
+ b.Property("TourName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("TourType")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TourName")
+ .IsUnique();
+
+ b.ToTable("Tours");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.TourHistory", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("text");
+
+ b.Property("ChangeDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("OldPrice")
+ .HasColumnType("double precision");
+
+ b.Property("TourId")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("TourId");
+
+ b.ToTable("TourHistories");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Salary", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Employee", "Employee")
+ .WithMany("Salaries")
+ .HasForeignKey("EmployeeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Employee");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Sale", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Client", "Client")
+ .WithMany("Sales")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.HasOne("MagicCarpetDatabase.Models.Employee", "Employee")
+ .WithMany("Sales")
+ .HasForeignKey("EmployeeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Employee");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.SaleTour", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Sale", "Sale")
+ .WithMany("SaleTours")
+ .HasForeignKey("SaleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("MagicCarpetDatabase.Models.Tour", "Tour")
+ .WithMany("SaleTours")
+ .HasForeignKey("TourId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Sale");
+
+ b.Navigation("Tour");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.TourHistory", b =>
+ {
+ b.HasOne("MagicCarpetDatabase.Models.Tour", "Tour")
+ .WithMany("TourHistories")
+ .HasForeignKey("TourId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Tour");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Client", b =>
+ {
+ b.Navigation("Sales");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Employee", b =>
+ {
+ b.Navigation("Salaries");
+
+ b.Navigation("Sales");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Sale", b =>
+ {
+ b.Navigation("SaleTours");
+ });
+
+ modelBuilder.Entity("MagicCarpetDatabase.Models.Tour", b =>
+ {
+ b.Navigation("SaleTours");
+
+ b.Navigation("TourHistories");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/MagicCarpetProject/MagicCarpetDatabase/SampleContextFactory.cs b/MagicCarpetProject/MagicCarpetDatabase/SampleContextFactory.cs
new file mode 100644
index 0000000..98c4480
--- /dev/null
+++ b/MagicCarpetProject/MagicCarpetDatabase/SampleContextFactory.cs
@@ -0,0 +1,16 @@
+using Microsoft.EntityFrameworkCore.Design;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MagicCarpetDatabase;
+
+public class SampleContextFactory : IDesignTimeDbContextFactory
+{
+ public MagicCarpetDbContext CreateDbContext(string[] args)
+ {
+ return new MagicCarpetDbContext(new DefaultConfigurationDatabase());
+ }
+}
diff --git a/MagicCarpetProject/MagicCarpetWebApi/MagicCarpetWebApi.csproj b/MagicCarpetProject/MagicCarpetWebApi/MagicCarpetWebApi.csproj
index 39c7096..19a7830 100644
--- a/MagicCarpetProject/MagicCarpetWebApi/MagicCarpetWebApi.csproj
+++ b/MagicCarpetProject/MagicCarpetWebApi/MagicCarpetWebApi.csproj
@@ -9,6 +9,11 @@
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+