diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.Designer.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.Designer.cs new file mode 100644 index 0000000..0a63034 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.Designer.cs @@ -0,0 +1,420 @@ +// +using System; +using BankYouBankruptDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BankYouBankruptDatabaseImplement.Migrations +{ + [DbContext(typeof(BankYouBancruptDatabase))] + [Migration("20230514113052_ChangeBD")] + partial class ChangeBD + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.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("PasswordAccount") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CashierId"); + + b.HasIndex("ClientId"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Card", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("CVC") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClientID") + .HasColumnType("int"); + + b.Property("Number") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Period") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("ClientID"); + + b.ToTable("Cards"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.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("DateOperation") + .HasColumnType("datetime2"); + + b.Property("DebitingId") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("CashierId"); + + b.HasIndex("DebitingId"); + + b.ToTable("CashWithdrawals"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Cashier", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .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.Property("Telephone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Cashiers"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .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.Property("Telephone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Crediting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CardId") + .HasColumnType("int"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Sum") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CardId"); + + b.ToTable("Creditings"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Debiting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CardId") + .HasColumnType("int"); + + b.Property("DateClose") + .HasColumnType("datetime2"); + + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CardId"); + + b.ToTable("Debitings"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.MoneyTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccountPayeeId") + .HasColumnType("int"); + + b.Property("AccountSenderId") + .HasColumnType("int"); + + b.Property("DateOperation") + .HasColumnType("datetime2"); + + b.Property("Sum") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AccountPayeeId"); + + b.HasIndex("AccountSenderId"); + + b.ToTable("MoneyTransfers"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Account", b => + { + b.HasOne("BankYouBankruptDatabaseImplement.Models.Cashier", null) + .WithMany("Accounts") + .HasForeignKey("CashierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankYouBankruptDatabaseImplement.Models.Client", "Client") + .WithMany() + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Card", b => + { + b.HasOne("BankYouBankruptDatabaseImplement.Models.Account", null) + .WithMany("Cards") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankYouBankruptDatabaseImplement.Models.Client", "Client") + .WithMany("Cards") + .HasForeignKey("ClientID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.CashWithdrawal", b => + { + b.HasOne("BankYouBankruptDatabaseImplement.Models.Account", "Account") + .WithMany("CashWithdrawals") + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankYouBankruptDatabaseImplement.Models.Cashier", "Cashier") + .WithMany("CashWithdrawals") + .HasForeignKey("CashierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankYouBankruptDatabaseImplement.Models.Debiting", "Debiting") + .WithMany() + .HasForeignKey("DebitingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Cashier"); + + b.Navigation("Debiting"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Crediting", b => + { + b.HasOne("BankYouBankruptDatabaseImplement.Models.Card", "Card") + .WithMany("Creditings") + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Debiting", b => + { + b.HasOne("BankYouBankruptDatabaseImplement.Models.Card", "Card") + .WithMany("Debitings") + .HasForeignKey("CardId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Card"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.MoneyTransfer", b => + { + b.HasOne("BankYouBankruptDatabaseImplement.Models.Account", null) + .WithMany("MoneyTransferPayees") + .HasForeignKey("AccountPayeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankYouBankruptDatabaseImplement.Models.Account", null) + .WithMany("MoneyTransferSenders") + .HasForeignKey("AccountSenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Account", b => + { + b.Navigation("Cards"); + + b.Navigation("CashWithdrawals"); + + b.Navigation("MoneyTransferPayees"); + + b.Navigation("MoneyTransferSenders"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Card", b => + { + b.Navigation("Creditings"); + + b.Navigation("Debitings"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Cashier", b => + { + b.Navigation("Accounts"); + + b.Navigation("CashWithdrawals"); + }); + + modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Client", b => + { + b.Navigation("Cards"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.cs new file mode 100644 index 0000000..b9a5886 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.cs @@ -0,0 +1,115 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BankYouBankruptDatabaseImplement.Migrations +{ + /// + public partial class ChangeBD : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Date", + table: "Debitings", + newName: "DateOpen"); + + migrationBuilder.AddColumn( + name: "DateClose", + table: "Debitings", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "Status", + table: "Debitings", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CashierId", + table: "CashWithdrawals", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "DebitingId", + table: "CashWithdrawals", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateIndex( + name: "IX_CashWithdrawals_CashierId", + table: "CashWithdrawals", + column: "CashierId"); + + migrationBuilder.CreateIndex( + name: "IX_CashWithdrawals_DebitingId", + table: "CashWithdrawals", + column: "DebitingId"); + + migrationBuilder.AddForeignKey( + name: "FK_CashWithdrawals_Cashiers_CashierId", + table: "CashWithdrawals", + column: "CashierId", + principalTable: "Cashiers", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + + migrationBuilder.AddForeignKey( + name: "FK_CashWithdrawals_Debitings_DebitingId", + table: "CashWithdrawals", + column: "DebitingId", + principalTable: "Debitings", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_CashWithdrawals_Cashiers_CashierId", + table: "CashWithdrawals"); + + migrationBuilder.DropForeignKey( + name: "FK_CashWithdrawals_Debitings_DebitingId", + table: "CashWithdrawals"); + + migrationBuilder.DropIndex( + name: "IX_CashWithdrawals_CashierId", + table: "CashWithdrawals"); + + migrationBuilder.DropIndex( + name: "IX_CashWithdrawals_DebitingId", + table: "CashWithdrawals"); + + migrationBuilder.DropColumn( + name: "DateClose", + table: "Debitings"); + + migrationBuilder.DropColumn( + name: "Status", + table: "Debitings"); + + migrationBuilder.DropColumn( + name: "CashierId", + table: "CashWithdrawals"); + + migrationBuilder.DropColumn( + name: "DebitingId", + table: "CashWithdrawals"); + + migrationBuilder.RenameColumn( + name: "DateOpen", + table: "Debitings", + newName: "Date"); + } + } +} diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/BankYouBancruptDatabaseModelSnapshot.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/BankYouBancruptDatabaseModelSnapshot.cs index 054bbd7..ea3d0d9 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/BankYouBancruptDatabaseModelSnapshot.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/BankYouBancruptDatabaseModelSnapshot.cs @@ -104,9 +104,15 @@ namespace BankYouBankruptDatabaseImplement.Migrations b.Property("AccountId") .HasColumnType("int"); + b.Property("CashierId") + .HasColumnType("int"); + b.Property("DateOperation") .HasColumnType("datetime2"); + b.Property("DebitingId") + .HasColumnType("int"); + b.Property("Sum") .HasColumnType("int"); @@ -114,6 +120,10 @@ namespace BankYouBankruptDatabaseImplement.Migrations b.HasIndex("AccountId"); + b.HasIndex("CashierId"); + + b.HasIndex("DebitingId"); + b.ToTable("CashWithdrawals"); }); @@ -226,9 +236,15 @@ namespace BankYouBankruptDatabaseImplement.Migrations b.Property("CardId") .HasColumnType("int"); - b.Property("Date") + b.Property("DateClose") .HasColumnType("datetime2"); + b.Property("DateOpen") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + b.Property("Sum") .HasColumnType("int"); @@ -310,7 +326,23 @@ namespace BankYouBankruptDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("BankYouBankruptDatabaseImplement.Models.Cashier", "Cashier") + .WithMany("CashWithdrawals") + .HasForeignKey("CashierId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BankYouBankruptDatabaseImplement.Models.Debiting", "Debiting") + .WithMany() + .HasForeignKey("DebitingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Account"); + + b.Navigation("Cashier"); + + b.Navigation("Debiting"); }); modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Crediting", b => @@ -371,6 +403,8 @@ namespace BankYouBankruptDatabaseImplement.Migrations modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Cashier", b => { b.Navigation("Accounts"); + + b.Navigation("CashWithdrawals"); }); modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Client", b =>