diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs index 817215b..6227a20 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/DebitingViewModel .cs @@ -16,7 +16,7 @@ namespace BankYouBankruptContracts.ViewModels public int CardId { get; set; } [DisplayName("Номер карты")] - public string? CardNumber { get; set; } + public string CardNumber { get; set; } = string.Empty; [DisplayName("Сумма операции")] public int Sum { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs index aeebce6..5ca7324 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs @@ -28,15 +28,10 @@ namespace BankYouBankruptDatabaseImplement.Implements public List GetFilteredList(DebitingSearchModel model) { - if (model.CardId < 0) - { - return new(); - } - using var context = new BankYouBancruptDatabase(); //для получения всех заявок на стнятие со статусом "Открыта" - if(model.Status != StatusEnum.Закрыта) + if(model.Status == StatusEnum.Открыта) { return context.Debitings .Include(x => x.Card) @@ -47,7 +42,6 @@ namespace BankYouBankruptDatabaseImplement.Implements return context.Debitings .Include(x => x.Card) - .Where(x => x.CardId == model.CardId) .Select(x => x.GetViewModel) .ToList(); } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230401180945_InitMagration.Designer.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230401180945_InitMagration.Designer.cs deleted file mode 100644 index 18326b0..0000000 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230401180945_InitMagration.Designer.cs +++ /dev/null @@ -1,386 +0,0 @@ -// -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("20230401180945_InitMagration")] - partial class InitMagration - { - /// - 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("DateOperation") - .HasColumnType("datetime2"); - - b.Property("Sum") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - 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("Date") - .HasColumnType("datetime2"); - - 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.Navigation("Account"); - }); - - 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"); - }); - - 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 deleted file mode 100644 index b9a5886..0000000 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.cs +++ /dev/null @@ -1,115 +0,0 @@ -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/20230514113052_ChangeBD.Designer.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514143703_InitMigration.Designer.cs similarity index 98% rename from BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.Designer.cs rename to BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514143703_InitMigration.Designer.cs index 0a63034..f8ce0b6 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514113052_ChangeBD.Designer.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514143703_InitMigration.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace BankYouBankruptDatabaseImplement.Migrations { [DbContext(typeof(BankYouBancruptDatabase))] - [Migration("20230514113052_ChangeBD")] - partial class ChangeBD + [Migration("20230514143703_InitMigration")] + partial class InitMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -239,7 +239,8 @@ namespace BankYouBankruptDatabaseImplement.Migrations b.Property("CardId") .HasColumnType("int"); - b.Property("DateClose") + b.Property("DateClose") + .IsRequired() .HasColumnType("datetime2"); b.Property("DateOpen") diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230401180945_InitMagration.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514143703_InitMigration.cs similarity index 88% rename from BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230401180945_InitMagration.cs rename to BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514143703_InitMigration.cs index baeb448..91b9cfe 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230401180945_InitMagration.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514143703_InitMigration.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace BankYouBankruptDatabaseImplement.Migrations { /// - public partial class InitMagration : Migration + public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -106,27 +106,6 @@ namespace BankYouBankruptDatabaseImplement.Migrations onDelete: ReferentialAction.NoAction); }); - migrationBuilder.CreateTable( - name: "CashWithdrawals", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AccountId = 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); - }); - migrationBuilder.CreateTable( name: "MoneyTransfers", columns: table => new @@ -184,7 +163,9 @@ namespace BankYouBankruptDatabaseImplement.Migrations .Annotation("SqlServer:Identity", "1, 1"), CardId = table.Column(type: "int", nullable: false), Sum = table.Column(type: "int", nullable: false), - Date = table.Column(type: "datetime2", nullable: false) + DateOpen = table.Column(type: "datetime2", nullable: false), + DateClose = table.Column(type: "datetime2", nullable: false), + Status = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -197,6 +178,41 @@ namespace BankYouBankruptDatabaseImplement.Migrations 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", @@ -222,6 +238,16 @@ namespace BankYouBankruptDatabaseImplement.Migrations 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", @@ -253,10 +279,10 @@ namespace BankYouBankruptDatabaseImplement.Migrations name: "Creditings"); migrationBuilder.DropTable( - name: "Debitings"); + name: "MoneyTransfers"); migrationBuilder.DropTable( - name: "MoneyTransfers"); + name: "Debitings"); migrationBuilder.DropTable( name: "Cards"); diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514120539_support.Designer.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514144846_Support.Designer.cs similarity index 99% rename from BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514120539_support.Designer.cs rename to BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514144846_Support.Designer.cs index e311a17..9fec44f 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514120539_support.Designer.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514144846_Support.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace BankYouBankruptDatabaseImplement.Migrations { [DbContext(typeof(BankYouBancruptDatabase))] - [Migration("20230514120539_support")] - partial class support + [Migration("20230514144846_Support")] + partial class Support { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514120539_support.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514144846_Support.cs similarity index 62% rename from BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514120539_support.cs rename to BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514144846_Support.cs index 9cd4605..2a0d511 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514120539_support.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Migrations/20230514144846_Support.cs @@ -5,13 +5,20 @@ namespace BankYouBankruptDatabaseImplement.Migrations { /// - public partial class support : Migration + public partial class Support : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.DropColumn( + name: "DateClose", + table: "Debitings"); - } + migrationBuilder.AddColumn( + name: "DateClose", + table: "Debitings", + nullable: true); + } /// protected override void Down(MigrationBuilder migrationBuilder) diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs index 6cfc047..ad09706 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Debiting.cs @@ -36,7 +36,7 @@ namespace BankYouBankruptDatabaseImplement.Models { Id = Id, CardId = CardId, - CardNumber = Card.Number, + CardNumber = Card == null ? string.Empty : Card.Number, Sum = Sum, DateOpen = DateOpen, DateClose = DateClose, @@ -49,6 +49,7 @@ namespace BankYouBankruptDatabaseImplement.Models { Id = model.Id, CardId = model.CardId, + Card = context.Cards.First(x => x.Id == model.CardId), Sum = model.Sum, DateOpen = model.DateOpen, Status = StatusEnum.Открыта diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs index 2f1c1cc..a3330ac 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/AccountController.cs @@ -2,6 +2,7 @@ using BankYouBankruptContracts.BusinessLogicsContracts; using BankYouBankruptContracts.SearchModels; using BankYouBankruptContracts.ViewModels; +using BankYouBankruptDataModels.Enums; using Microsoft.AspNetCore.Mvc; namespace BankYouBankruptRestApi.Controllers @@ -15,10 +16,13 @@ namespace BankYouBankruptRestApi.Controllers private readonly IAccountLogic _accountLogic; - public AccountController(IAccountLogic accountLogic, ILogger logger) + private readonly IDebitingLogic _debitingLogic; + + public AccountController(IAccountLogic accountLogic, IDebitingLogic debitingLogic, ILogger logger) { _logger = logger; _accountLogic = accountLogic; + _debitingLogic = debitingLogic; } [HttpGet] @@ -106,5 +110,23 @@ namespace BankYouBankruptRestApi.Controllers throw; } } + + //найти все открытые заявки на снятие средств + [HttpGet] + public List? FindOpenDebiting() + { + try + { + return _debitingLogic.ReadList(new DebitingSearchModel + { + Status = StatusEnum.Открыта + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } } }