From 159c1286e546c32faeaffcd5f15925cccd66fe97 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Tue, 28 May 2024 16:35:20 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 2 +- .../20230516171124_NewTransferAndCrediting.cs | 323 +++++++++++++ .../Migrations/20230516172054_SmallFix.cs.cs | 43 ++ .../Migrations/20230516175437_NewSmallFix.cs | 103 ++++ .../20240528115815_Initial.Designer.cs | 454 ++++++++++++++++++ .../Migrations/20240528115815_Initial.cs | 324 +++++++++++++ 6 files changed, 1248 insertions(+), 1 deletion(-) create mode 100644 Bank/BankDatabaseImplement/Migrations/20230516171124_NewTransferAndCrediting.cs create mode 100644 Bank/BankDatabaseImplement/Migrations/20230516172054_SmallFix.cs.cs create mode 100644 Bank/BankDatabaseImplement/Migrations/20230516175437_NewSmallFix.cs create mode 100644 Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.Designer.cs create mode 100644 Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.cs diff --git a/Bank/BankClientApp/Controllers/HomeController.cs b/Bank/BankClientApp/Controllers/HomeController.cs index f7fbbac..ace2fe7 100644 --- a/Bank/BankClientApp/Controllers/HomeController.cs +++ b/Bank/BankClientApp/Controllers/HomeController.cs @@ -63,7 +63,7 @@ namespace BankClientApp.Controllers return Redirect("ErrorPage"); } - APIClient.Client = APIClient.GetRequest($"api/Client/Logn?login={login}&password={password}"); + APIClient.Client = APIClient.GetRequest($"api/Client/Login?login={login}&password={password}"); if (APIClient.Client == null) { diff --git a/Bank/BankDatabaseImplement/Migrations/20230516171124_NewTransferAndCrediting.cs b/Bank/BankDatabaseImplement/Migrations/20230516171124_NewTransferAndCrediting.cs new file mode 100644 index 0000000..6d137ed --- /dev/null +++ b/Bank/BankDatabaseImplement/Migrations/20230516171124_NewTransferAndCrediting.cs @@ -0,0 +1,323 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDatabaseImplement.Migrations +{ + using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + + /// + public partial class NewTransferAndCrediting : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Cashiers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Surname = table.Column(type: "nvarchar(max)", nullable: false), + Patronymic = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + MobilePhone = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cashiers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Surname = table.Column(type: "nvarchar(max)", nullable: false), + Patronymic = table.Column(type: "nvarchar(max)", nullable: false), + MobilePhone = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Accounts", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AccountNumber = table.Column(type: "nvarchar(max)", nullable: false), + CashierId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false), + PasswordAccount = table.Column(type: "nvarchar(max)", nullable: false), + Balance = table.Column(type: "float", nullable: false), + DateOpen = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Accounts", x => x.Id); + table.ForeignKey( +name: "FK_Accounts_Cashiers_CashierId", +column: x => x.CashierId, +principalTable: "Cashiers", +principalColumn: "Id", +onDelete: ReferentialAction.Cascade); + table.ForeignKey( +name: "FK_Accounts_Clients_ClientId", +column: x => x.ClientId, +principalTable: "Clients", +principalColumn: "Id", +onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Cards", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientID = table.Column(type: "int", nullable: false), + AccountId = table.Column(type: "int", nullable: false), + Number = table.Column(type: "nvarchar(max)", nullable: false), + CVC = table.Column(type: "nvarchar(max)", nullable: false), + Period = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cards", x => x.Id); + table.ForeignKey( +name: "FK_Cards_Accounts_AccountId", +column: x => x.AccountId, +principalTable: "Accounts", +principalColumn: "Id", +onDelete: ReferentialAction.Cascade); + table.ForeignKey( +name: "FK_Cards_Clients_ClientID", +column: x => x.ClientID, +principalTable: "Clients", +principalColumn: "Id", +onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "MoneyTransfers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Sum = table.Column(type: "int", nullable: false), + AccountSenderId = table.Column(type: "int", nullable: false), + AccountPayeeId = table.Column(type: "int", nullable: false), + DateOperation = table.Column(type: "datetime2", nullable: + false), + CreditingId = table.Column(type: "int", nullable: false), + CashierId = table.Column(type: "int", nullable: false), + AccountPayeerId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MoneyTransfers", x => x.Id); + table.ForeignKey( +name: "FK_MoneyTransfers_Accounts_AccountPayeerId", +column: x => x.AccountPayeerId, +principalTable: "Accounts", +principalColumn: "Id", +onDelete: ReferentialAction.Cascade); + table.ForeignKey( +name: "FK_MoneyTransfers_Accounts_AccountSenderId", +column: x => x.AccountSenderId, +principalTable: "Accounts", +principalColumn: "Id", +onDelete: ReferentialAction.NoAction); + table.ForeignKey( +name: "FK_MoneyTransfers_Cashiers_CashierId", +column: x => x.CashierId, +principalTable: "Cashiers", +principalColumn: "Id", +onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "Creditings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CardId = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "int", nullable: false), + DateOpen = table.Column(type: "datetime2", nullable: false), + DateClose = table.Column(type: "datetime2", nullable: true), + Status = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Creditings", x => x.Id); + table.ForeignKey( +name: "FK_Creditings_Cards_CardId", +column: x => x.CardId, +principalTable: "Cards", +principalColumn: "Id", +onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Debitings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CardId = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "int", nullable: false), + DateOpen = table.Column(type: "datetime2", nullable: false), + DateClose = table.Column(type: "datetime2", nullable: true), + Status = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Debitings", x => x.Id); + table.ForeignKey( +name: "FK_Debitings_Cards_CardId", +column: x => x.CardId, +principalTable: "Cards", +principalColumn: "Id", +onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CashWithdrawals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DebitingId = table.Column(type: "int", nullable: false), + AccountId = table.Column(type: "int", nullable: false), + CashierId = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "int", nullable: false), + DateOperation = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CashWithdrawals", x => x.Id); + table.ForeignKey( +name: "FK_CashWithdrawals_Accounts_AccountId", +column: x => x.AccountId, +principalTable: "Accounts", +principalColumn: "Id", +onDelete: ReferentialAction.Cascade); + table.ForeignKey( +name: "FK_CashWithdrawals_Cashiers_CashierId", +column: x => x.CashierId, +principalTable: "Cashiers", +principalColumn: "Id", +onDelete: ReferentialAction.NoAction); + table.ForeignKey( +name: "FK_CashWithdrawals_Debitings_DebitingId", +column: x => x.DebitingId, +principalTable: "Debitings", +principalColumn: "Id", +onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_Accounts_CashierId", + table: "Accounts", + column: "CashierId"); + + migrationBuilder.CreateIndex( + name: "IX_Accounts_ClientId", + table: "Accounts", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_Cards_AccountId", + table: "Cards", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_Cards_ClientID", + table: "Cards", + column: "ClientID"); + + migrationBuilder.CreateIndex( + name: "IX_CashWithdrawals_AccountId", + table: "CashWithdrawals", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: + "IX_CashWithdrawals_CashierId", + table: "CashWithdrawals", + column: "CashierId"); + + migrationBuilder.CreateIndex( + name: "IX_CashWithdrawals_DebitingId", + table: "CashWithdrawals", + column: "DebitingId"); + + migrationBuilder.CreateIndex( + name: "IX_Creditings_CardId", + table: "Creditings", + column: "CardId"); + + migrationBuilder.CreateIndex( + name: "IX_Debitings_CardId", + table: "Debitings", + column: "CardId"); + + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_AccountPayeerId", + table: "MoneyTransfers", + column: "AccountPayeerId"); + + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_AccountSenderId", + table: "MoneyTransfers", + column: "AccountSenderId"); + + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_CashierId", + table: "MoneyTransfers", + column: "CashierId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CashWithdrawals"); + + migrationBuilder.DropTable( + name: "Creditings"); + + migrationBuilder.DropTable( + name: "MoneyTransfers"); + + migrationBuilder.DropTable( + name: "Debitings"); + + migrationBuilder.DropTable( + name: "Cards"); + + migrationBuilder.DropTable( + name: "Accounts"); + + migrationBuilder.DropTable( + name: "Cashiers"); + + migrationBuilder.DropTable( + name: "Clients"); + } + } +} diff --git a/Bank/BankDatabaseImplement/Migrations/20230516172054_SmallFix.cs.cs b/Bank/BankDatabaseImplement/Migrations/20230516172054_SmallFix.cs.cs new file mode 100644 index 0000000..7d4e8a7 --- /dev/null +++ b/Bank/BankDatabaseImplement/Migrations/20230516172054_SmallFix.cs.cs @@ -0,0 +1,43 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDatabaseImplement.Migrations +{ + /// + public partial class SmallFix : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_CreditingId", + table: "MoneyTransfers", + column: "CreditingId"); + + migrationBuilder.AddForeignKey( + name: "FK_MoneyTransfers_Creditings_CreditingId", + table: "MoneyTransfers", + column: "CreditingId", + principalTable: "Creditings", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_MoneyTransfers_Creditings_CreditingId", + table: "MoneyTransfers"); + + migrationBuilder.DropIndex( + name: "IX_MoneyTransfers_CreditingId", + table: "MoneyTransfers"); + } + } +} + diff --git a/Bank/BankDatabaseImplement/Migrations/20230516175437_NewSmallFix.cs b/Bank/BankDatabaseImplement/Migrations/20230516175437_NewSmallFix.cs new file mode 100644 index 0000000..377cc5a --- /dev/null +++ b/Bank/BankDatabaseImplement/Migrations/20230516175437_NewSmallFix.cs @@ -0,0 +1,103 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BankDatabaseImplement.Migrations +{ + /// + public partial class NewSmallFix : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_MoneyTransfers_Accounts_AccountSenderId", + table: "MoneyTransfers"); + + migrationBuilder.DropForeignKey( + name: "FK_MoneyTransfers_Creditings_CreditingId", + table: "MoneyTransfers"); + + migrationBuilder.AlterColumn( + name: "CreditingId", + table: "MoneyTransfers", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "AccountSenderId", + table: "MoneyTransfers", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AddForeignKey( + name: "FK_MoneyTransfers_Accounts_AccountSenderId", + table: "MoneyTransfers", + column: "AccountSenderId", + principalTable: "Accounts", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MoneyTransfers_Creditings_CreditingId", + table: "MoneyTransfers", + column: "CreditingId", + principalTable: "Creditings", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_MoneyTransfers_Accounts_AccountSenderId", + table: "MoneyTransfers"); + + migrationBuilder.DropForeignKey( + name: "FK_MoneyTransfers_Creditings_CreditingId", + table: "MoneyTransfers"); + + migrationBuilder.AlterColumn( + name: "CreditingId", + table: "MoneyTransfers", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "AccountSenderId", + table: "MoneyTransfers", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_MoneyTransfers_Accounts_AccountSenderId", + table: "MoneyTransfers", + column: "AccountSenderId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_MoneyTransfers_Creditings_CreditingId", + table: "MoneyTransfers", + column: "CreditingId", + principalTable: "Creditings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.Designer.cs b/Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.Designer.cs new file mode 100644 index 0000000..8d3642f --- /dev/null +++ b/Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.Designer.cs @@ -0,0 +1,454 @@ +// +using System; +using BankDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BankDatabaseImplement.Migrations +{ + [DbContext(typeof(BankDatabase))] + [Migration("20240528115815_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.18") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccountNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Balance") + .HasColumnType("float"); + + b.Property("CashierId") + .HasColumnType("int"); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("StatusAccount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CashierId"); + + b.HasIndex("ClientId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.CashWithdrawal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("CashierId") + .HasColumnType("int"); + + b.Property("DateWithdrawal") + .HasColumnType("datetime2"); + + b.Property("DebitingId") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CashierId"); + + b.HasIndex("DebitingId"); + + b.ToTable("CashWithdrawals"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.Cashier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobilePhone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Cashiers"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.MoneyTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccountPayeeId") + .HasColumnType("int"); + + b.Property("AccountPayeerId") + .HasColumnType("int"); + + b.Property("AccountSenderId") + .HasColumnType("int"); + + b.Property("CashierId") + .HasColumnType("int"); + + b.Property("CreditingId") + .HasColumnType("int"); + + b.Property("DateTransfer") + .HasColumnType("datetime2"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("AccountPayeerId"); + + b.HasIndex("AccountSenderId"); + + b.HasIndex("CashierId"); + + b.HasIndex("CreditingId"); + + b.ToTable("MoneyTransfers"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Card", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("Balance") + .HasColumnType("float"); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("ClientSurname") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Period") + .HasColumnType("datetime2"); + + b.Property("StatusCard") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("ClientId"); + + b.ToTable("Cards"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MobilePhone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Surname") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Crediting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CardId") + .HasColumnType("int"); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("DateCredit") + .HasColumnType("datetime2"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("CardId"); + + b.ToTable("Creditings"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Debiting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CardId") + .HasColumnType("int"); + + b.Property("DateDebit") + .HasColumnType("datetime2"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("CardId"); + + b.ToTable("Debitings"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.Account", b => + { + b.HasOne("BankDatabaseImplement.Models.CashierModels.Cashier", null) + .WithMany("Accounts") + .HasForeignKey("CashierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankDatabaseImplement.Models.ClientModels.Client", "Client") + .WithMany() + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.CashWithdrawal", b => + { + b.HasOne("BankDatabaseImplement.Models.CashierModels.Account", "Account") + .WithMany("CashWithdrawals") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankDatabaseImplement.Models.CashierModels.Cashier", "Cashier") + .WithMany("CashWithdrawals") + .HasForeignKey("CashierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankDatabaseImplement.Models.ClientModels.Debiting", "Debiting") + .WithMany() + .HasForeignKey("DebitingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Cashier"); + + b.Navigation("Debiting"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.MoneyTransfer", b => + { + b.HasOne("BankDatabaseImplement.Models.CashierModels.Account", "AccountPayeer") + .WithMany() + .HasForeignKey("AccountPayeerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankDatabaseImplement.Models.CashierModels.Account", "AccountSender") + .WithMany() + .HasForeignKey("AccountSenderId"); + + b.HasOne("BankDatabaseImplement.Models.CashierModels.Cashier", "Cashier") + .WithMany("MoneyTransfers") + .HasForeignKey("CashierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankDatabaseImplement.Models.ClientModels.Crediting", null) + .WithMany("MoneyTransfers") + .HasForeignKey("CreditingId"); + + b.Navigation("AccountPayeer"); + + b.Navigation("AccountSender"); + + b.Navigation("Cashier"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Card", b => + { + b.HasOne("BankDatabaseImplement.Models.CashierModels.Account", "Account") + .WithMany("Cards") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankDatabaseImplement.Models.ClientModels.Client", "Client") + .WithMany("Cards") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Crediting", b => + { + b.HasOne("BankDatabaseImplement.Models.ClientModels.Card", "Card") + .WithMany("creditings") + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Debiting", b => + { + b.HasOne("BankDatabaseImplement.Models.ClientModels.Card", "Card") + .WithMany("debitings") + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.Account", b => + { + b.Navigation("Cards"); + + b.Navigation("CashWithdrawals"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.CashierModels.Cashier", b => + { + b.Navigation("Accounts"); + + b.Navigation("CashWithdrawals"); + + b.Navigation("MoneyTransfers"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Card", b => + { + b.Navigation("creditings"); + + b.Navigation("debitings"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Client", b => + { + b.Navigation("Cards"); + }); + + modelBuilder.Entity("BankDatabaseImplement.Models.ClientModels.Crediting", b => + { + b.Navigation("MoneyTransfers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.cs b/Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.cs new file mode 100644 index 0000000..14c0195 --- /dev/null +++ b/Bank/BankDatabaseImplement/Migrations/20240528115815_Initial.cs @@ -0,0 +1,324 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BankDatabaseImplement.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Cashiers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Surname = table.Column(type: "nvarchar(max)", nullable: false), + Patronymic = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + MobilePhone = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cashiers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Surname = table.Column(type: "nvarchar(max)", nullable: false), + Patronymic = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + MobilePhone = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Accounts", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AccountNumber = table.Column(type: "nvarchar(max)", nullable: false), + CashierId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false), + Balance = table.Column(type: "float", nullable: false), + DateOpen = table.Column(type: "datetime2", nullable: false), + StatusAccount = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Accounts", x => x.Id); + table.ForeignKey( + name: "FK_Accounts_Cashiers_CashierId", + column: x => x.CashierId, + principalTable: "Cashiers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Accounts_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Cards", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientId = table.Column(type: "int", nullable: false), + AccountId = table.Column(type: "int", nullable: false), + Number = table.Column(type: "nvarchar(max)", nullable: false), + Balance = table.Column(type: "float", nullable: false), + Period = table.Column(type: "datetime2", nullable: false), + StatusCard = table.Column(type: "int", nullable: false), + ClientSurname = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cards", x => x.Id); + table.ForeignKey( + name: "FK_Cards_Accounts_AccountId", + column: x => x.AccountId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Cards_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "Creditings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CardId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "float", nullable: false), + DateCredit = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Creditings", x => x.Id); + table.ForeignKey( + name: "FK_Creditings_Cards_CardId", + column: x => x.CardId, + principalTable: "Cards", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Debitings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CardId = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "float", nullable: false), + DateDebit = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Debitings", x => x.Id); + table.ForeignKey( + name: "FK_Debitings_Cards_CardId", + column: x => x.CardId, + principalTable: "Cards", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MoneyTransfers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Sum = table.Column(type: "float", nullable: false), + AccountSenderId = table.Column(type: "int", nullable: true), + AccountPayeeId = table.Column(type: "int", nullable: false), + DateTransfer = table.Column(type: "datetime2", nullable: false), + CreditingId = table.Column(type: "int", nullable: true), + CashierId = table.Column(type: "int", nullable: false), + AccountPayeerId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MoneyTransfers", x => x.Id); + table.ForeignKey( + name: "FK_MoneyTransfers_Accounts_AccountPayeerId", + column: x => x.AccountPayeerId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_MoneyTransfers_Accounts_AccountSenderId", + column: x => x.AccountSenderId, + principalTable: "Accounts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_MoneyTransfers_Cashiers_CashierId", + column: x => x.CashierId, + principalTable: "Cashiers", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_MoneyTransfers_Creditings_CreditingId", + column: x => x.CreditingId, + principalTable: "Creditings", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "CashWithdrawals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DebitingId = table.Column(type: "int", nullable: false), + AccountId = table.Column(type: "int", nullable: false), + CashierId = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "float", nullable: false), + DateWithdrawal = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CashWithdrawals", x => x.Id); + table.ForeignKey( + name: "FK_CashWithdrawals_Accounts_AccountId", + column: x => x.AccountId, + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + table.ForeignKey( + name: "FK_CashWithdrawals_Cashiers_CashierId", + column: x => x.CashierId, + principalTable: "Cashiers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CashWithdrawals_Debitings_DebitingId", + column: x => x.DebitingId, + principalTable: "Debitings", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_Accounts_CashierId", + table: "Accounts", + column: "CashierId"); + + migrationBuilder.CreateIndex( + name: "IX_Accounts_ClientId", + table: "Accounts", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_Cards_AccountId", + table: "Cards", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_Cards_ClientId", + table: "Cards", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_CashWithdrawals_AccountId", + table: "CashWithdrawals", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_CashWithdrawals_CashierId", + table: "CashWithdrawals", + column: "CashierId"); + + migrationBuilder.CreateIndex( + name: "IX_CashWithdrawals_DebitingId", + table: "CashWithdrawals", + column: "DebitingId"); + + migrationBuilder.CreateIndex( + name: "IX_Creditings_CardId", + table: "Creditings", + column: "CardId"); + + migrationBuilder.CreateIndex( + name: "IX_Debitings_CardId", + table: "Debitings", + column: "CardId"); + + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_AccountPayeerId", + table: "MoneyTransfers", + column: "AccountPayeerId"); + + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_AccountSenderId", + table: "MoneyTransfers", + column: "AccountSenderId"); + + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_CashierId", + table: "MoneyTransfers", + column: "CashierId"); + + migrationBuilder.CreateIndex( + name: "IX_MoneyTransfers_CreditingId", + table: "MoneyTransfers", + column: "CreditingId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CashWithdrawals"); + + migrationBuilder.DropTable( + name: "MoneyTransfers"); + + migrationBuilder.DropTable( + name: "Debitings"); + + migrationBuilder.DropTable( + name: "Creditings"); + + migrationBuilder.DropTable( + name: "Cards"); + + migrationBuilder.DropTable( + name: "Accounts"); + + migrationBuilder.DropTable( + name: "Cashiers"); + + migrationBuilder.DropTable( + name: "Clients"); + } + } +}