Нечто

This commit is contained in:
Programmist73 2023-05-14 19:07:43 +04:00
parent de25c5ce83
commit 83fb4d8d9d
10 changed files with 93 additions and 543 deletions

View File

@ -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; }

View File

@ -28,15 +28,10 @@ namespace BankYouBankruptDatabaseImplement.Implements
public List<DebitingViewModel> 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();
}

View File

@ -1,386 +0,0 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AccountNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Balance")
.HasColumnType("float");
b.Property<int>("CashierId")
.HasColumnType("int");
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<DateTime>("DateOpen")
.HasColumnType("datetime2");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AccountId")
.HasColumnType("int");
b.Property<string>("CVC")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ClientID")
.HasColumnType("int");
b.Property<string>("Number")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("Period")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("AccountId");
b.HasIndex("ClientID");
b.ToTable("Cards");
});
modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.CashWithdrawal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AccountId")
.HasColumnType("int");
b.Property<DateTime>("DateOperation")
.HasColumnType("datetime2");
b.Property<int>("Sum")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AccountId");
b.ToTable("CashWithdrawals");
});
modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Cashier", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Telephone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Cashiers");
});
modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Patronymic")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Telephone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Crediting", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CardId")
.HasColumnType("int");
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
b.Property<int>("Sum")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("Creditings");
});
modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.Debiting", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CardId")
.HasColumnType("int");
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
b.Property<int>("Sum")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CardId");
b.ToTable("Debitings");
});
modelBuilder.Entity("BankYouBankruptDatabaseImplement.Models.MoneyTransfer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AccountPayeeId")
.HasColumnType("int");
b.Property<int>("AccountSenderId")
.HasColumnType("int");
b.Property<DateTime>("DateOperation")
.HasColumnType("datetime2");
b.Property<int>("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
}
}
}

View File

@ -1,115 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BankYouBankruptDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class ChangeBD : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Date",
table: "Debitings",
newName: "DateOpen");
migrationBuilder.AddColumn<DateTime>(
name: "DateClose",
table: "Debitings",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<int>(
name: "Status",
table: "Debitings",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "CashierId",
table: "CashWithdrawals",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
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);
}
/// <inheritdoc />
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");
}
}
}

View File

@ -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
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -239,7 +239,8 @@ namespace BankYouBankruptDatabaseImplement.Migrations
b.Property<int>("CardId")
.HasColumnType("int");
b.Property<DateTime>("DateClose")
b.Property<DateTime?>("DateClose")
.IsRequired()
.HasColumnType("datetime2");
b.Property<DateTime>("DateOpen")

View File

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace BankYouBankruptDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitMagration : Migration
public partial class InitMigration : Migration
{
/// <inheritdoc />
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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AccountId = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<int>(type: "int", nullable: false),
DateOperation = table.Column<DateTime>(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<int>(type: "int", nullable: false),
Sum = table.Column<int>(type: "int", nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
DateOpen = table.Column<DateTime>(type: "datetime2", nullable: false),
DateClose = table.Column<DateTime>(type: "datetime2", nullable: false),
Status = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DebitingId = table.Column<int>(type: "int", nullable: false),
AccountId = table.Column<int>(type: "int", nullable: false),
CashierId = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<int>(type: "int", nullable: false),
DateOperation = table.Column<DateTime>(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");

View File

@ -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
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -5,13 +5,20 @@
namespace BankYouBankruptDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class support : Migration
public partial class Support : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "DateClose",
table: "Debitings");
}
migrationBuilder.AddColumn<string>(
name: "DateClose",
table: "Debitings",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)

View File

@ -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.Открыта

View File

@ -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<AccountController> logger)
private readonly IDebitingLogic _debitingLogic;
public AccountController(IAccountLogic accountLogic, IDebitingLogic debitingLogic, ILogger<AccountController> logger)
{
_logger = logger;
_accountLogic = accountLogic;
_debitingLogic = debitingLogic;
}
[HttpGet]
@ -106,5 +110,23 @@ namespace BankYouBankruptRestApi.Controllers
throw;
}
}
//найти все открытые заявки на снятие средств
[HttpGet]
public List<DebitingViewModel>? FindOpenDebiting()
{
try
{
return _debitingLogic.ReadList(new DebitingSearchModel
{
Status = StatusEnum.Открыта
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
}
}