конечно, мы все виноваты в этом ...

This commit is contained in:
DeerElk 2024-05-27 01:09:39 +04:00
parent dec9ceaf34
commit 8d73f33020
30 changed files with 178 additions and 396 deletions

View File

@ -51,7 +51,7 @@ namespace BankBusinessLogic.BusinessLogics
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
_logger.LogInformation(
"ReadList. ClientSurname: {ClientSurname} {ClientName} " +
"ReadList. ClientFullname: {ClientSurname} {ClientName} " +
"{ClientPatronomic}. Snils: {Snils}", model?.ClientSurname,
model?.ClientName, model?.ClientPatronymic, model?.Snils);
var list = model == null ? _clientStorage.GetFullList() :

View File

@ -8,6 +8,8 @@ namespace BankContracts.ViewModels
[DisplayName("Идентификатор")]
public int Id { get; set; }
[DisplayName("Идентификатор валюты")]
public int CurrencyId { get; set; }
[DisplayName("Название кредитной программы")]
public string ProgramName { get; set; } = string.Empty;
[DisplayName("Процентная ставка")]
public double InterestRate { get; set; }

View File

@ -10,7 +10,5 @@
string? Email { get; }
string PasswordHash { get; }
int WorkerId { get; }
Dictionary<int, IProgramModel> ClientPrograms { get; }
Dictionary<int, IDepositModel> ClientDeposits { get; }
}
}

View File

@ -2,9 +2,7 @@
{
public interface IDepositModel : IId
{
int WorkerId { get; }
double Sum { get; }
DateOnly OpeningDate { get; }
Dictionary<int, ICurrencyModel> DepositCurrencies { get; }
}
}

View File

@ -4,6 +4,5 @@
{
string ProgramName { get; }
double InterestRate { get; }
Dictionary<int, ICurrencyModel> ProgramCurrencies { get; }
}
}

View File

@ -3,7 +3,6 @@
public interface IRefillModel : IId
{
int DepositId { get; }
int WorkerId { get; }
double Sum { get; }
DateOnly RefillDate { get; }
}

View File

@ -18,6 +18,14 @@ namespace BankDatabaseImplement
{
modelBuilder.Entity<Client>()
.HasKey(c => c.Snils);
modelBuilder.Entity<ClientDeposit>()
.HasKey(sc => new { sc.ClientSnils, sc.DepositId });
modelBuilder.Entity<ClientProgram>()
.HasKey(sc => new { sc.ClientSnils, sc.ProgramId });
modelBuilder.Entity<DepositCurrency>()
.HasKey(sc => new { sc.DepositId, sc.CurrencyId });
modelBuilder.Entity<ProgramCurrency>()
.HasKey(sc => new { sc.ProgramId, sc.CurrencyId });
}
public virtual DbSet<Client> Clients { set; get; }
public virtual DbSet<ClientProgram> ClientPrograms { set; get; }

View File

@ -12,7 +12,7 @@ namespace BankDatabaseImplement.Implements
public List<DepositViewModel> GetFullList()
{
using var context = new BankDatabase();
return context.Deposits.Include(x => x.Worker)
return context.Deposits
.Select(x => x.GetViewModel).ToList();
}
public List<DepositViewModel> GetFilteredList(DepositSearchModel model)
@ -22,10 +22,8 @@ namespace BankDatabaseImplement.Implements
return new();
}
using var context = new BankDatabase();
return context.Deposits.Include(x => x.Worker)
.Where(x => (model.WorkerId == 0 ||
x.WorkerId == model.WorkerId) &&
(model.Sum == 0 || x.Sum == model.Sum))
return context.Deposits
.Where(x => (model.Sum == 0 || x.Sum == model.Sum))
.Select(x => x.GetViewModel)
.ToList();
}
@ -36,10 +34,8 @@ namespace BankDatabaseImplement.Implements
return null;
}
using var context = new BankDatabase();
return context.Deposits.Include(x => x.Worker)
.FirstOrDefault(x => (model.WorkerId == 0 ||
x.WorkerId == model.WorkerId) &&
(model.Sum == 0 || x.Sum == model.Sum) &&
return context.Deposits
.FirstOrDefault(x => (model.Sum == 0 || x.Sum == model.Sum) &&
(!model.Id.HasValue || x.Id == model.Id))
?.GetViewModel;
}

View File

@ -13,7 +13,7 @@ namespace BankDatabaseImplement.Implements
{
using var context = new BankDatabase();
return context.Refills.Include(x => x.Deposit)
.Include(x => x.Worker).Select(x => x.GetViewModel).ToList();
.Select(x => x.GetViewModel).ToList();
}
public List<RefillViewModel> GetFilteredList(RefillSearchModel model)
{
@ -24,10 +24,8 @@ namespace BankDatabaseImplement.Implements
}
using var context = new BankDatabase();
return context.Refills.Include(x => x.Deposit)
.Include(x => x.Worker)
.Where(x => (model.DepositId == 0 ||
x.DepositId == model.DepositId) &&
(model.WorkerId == 0 || x.WorkerId == model.WorkerId) &&
(model.Sum == 0 || x.Sum == model.Sum) &&
(model.RefillDate == null ||
x.RefillDate == model.RefillDate))
@ -43,10 +41,8 @@ namespace BankDatabaseImplement.Implements
}
using var context = new BankDatabase();
return context.Refills.Include(x => x.Deposit)
.Include(x => x.Worker)
.FirstOrDefault(x => (model.DepositId == 0 ||
x.DepositId == model.DepositId) &&
(model.WorkerId == 0 || x.WorkerId == model.WorkerId) &&
(model.Sum == 0 || x.Sum == model.Sum) &&
(model.RefillDate == null ||
x.RefillDate == model.RefillDate) &&

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace BankDatabaseImplement.Migrations
{
[DbContext(typeof(BankDatabase))]
[Migration("20240502003921_InitialCreate")]
[Migration("20240526202321_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
@ -66,22 +66,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientDeposit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientSnils")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("DepositId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientSnils");
b.HasKey("ClientSnils", "DepositId");
b.HasIndex("DepositId");
@ -90,22 +81,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientProgram", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientSnils")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("ProgramId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientSnils");
b.HasKey("ClientSnils", "ProgramId");
b.HasIndex("ProgramId");
@ -158,24 +140,16 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.DepositCurrency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
b.Property<int>("DepositId")
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<int>("DepositId")
.HasColumnType("int");
b.HasKey("Id");
b.HasKey("DepositId", "CurrencyId");
b.HasIndex("CurrencyId");
b.HasIndex("DepositId");
b.ToTable("DepositCurrencies");
});
@ -201,24 +175,16 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ProgramCurrency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
b.Property<int>("ProgramId")
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<int>("ProgramId")
.HasColumnType("int");
b.HasKey("Id");
b.HasKey("ProgramId", "CurrencyId");
b.HasIndex("CurrencyId");
b.HasIndex("ProgramId");
b.ToTable("ProgramCurrencies");
});
@ -292,9 +258,6 @@ namespace BankDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("WorkerId")
.HasColumnType("int");
b.Property<string>("WorkerName")
.IsRequired()
.HasColumnType("nvarchar(max)");
@ -309,8 +272,6 @@ namespace BankDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("Workers");
});
@ -328,13 +289,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientDeposit", b =>
{
b.HasOne("BankDatabaseImplement.Models.Client", "Client")
.WithMany("Deposits")
.WithMany("ClientDeposits")
.HasForeignKey("ClientSnils")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Deposit", "Deposit")
.WithMany("Clients")
.WithMany("ClientDeposits")
.HasForeignKey("DepositId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -347,7 +308,7 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientProgram", b =>
{
b.HasOne("BankDatabaseImplement.Models.Client", "Client")
.WithMany("Programs")
.WithMany("ClientPrograms")
.HasForeignKey("ClientSnils")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -366,7 +327,7 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.Deposit", b =>
{
b.HasOne("BankDatabaseImplement.Models.Worker", "Worker")
.WithMany()
.WithMany("Deposits")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -377,13 +338,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.DepositCurrency", b =>
{
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany("Deposits")
.WithMany("DepositCurrencies")
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Deposit", "Deposit")
.WithMany("Currencies")
.WithMany("DepositCurrencies")
.HasForeignKey("DepositId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -396,13 +357,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ProgramCurrency", b =>
{
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany("Programs")
.WithMany("ProgramCurrencies")
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Program", "Program")
.WithMany("Currencies")
.WithMany("ProgramCurrencies")
.HasForeignKey("ProgramId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -421,7 +382,7 @@ namespace BankDatabaseImplement.Migrations
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Worker", "Worker")
.WithMany()
.WithMany("Refills")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -442,32 +403,25 @@ namespace BankDatabaseImplement.Migrations
b.Navigation("Program");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Worker", b =>
{
b.HasOne("BankDatabaseImplement.Models.Worker", null)
.WithMany("Workers")
.HasForeignKey("WorkerId");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Client", b =>
{
b.Navigation("Deposits");
b.Navigation("ClientDeposits");
b.Navigation("Programs");
b.Navigation("ClientPrograms");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Currency", b =>
{
b.Navigation("Deposits");
b.Navigation("DepositCurrencies");
b.Navigation("Programs");
b.Navigation("ProgramCurrencies");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Deposit", b =>
{
b.Navigation("Clients");
b.Navigation("ClientDeposits");
b.Navigation("Currencies");
b.Navigation("DepositCurrencies");
b.Navigation("Refills");
});
@ -476,14 +430,16 @@ namespace BankDatabaseImplement.Migrations
{
b.Navigation("Clients");
b.Navigation("Currencies");
b.Navigation("ProgramCurrencies");
b.Navigation("Terms");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Worker", b =>
{
b.Navigation("Workers");
b.Navigation("Deposits");
b.Navigation("Refills");
});
#pragma warning restore 612, 618
}

View File

@ -50,42 +50,37 @@ namespace BankDatabaseImplement.Migrations
WorkerPatronymic = table.Column<string>(type: "nvarchar(max)", nullable: false),
Phone = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: false),
WorkerId = table.Column<int>(type: "int", nullable: true)
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Workers", x => x.Id);
table.ForeignKey(
name: "FK_Workers_Workers_WorkerId",
column: x => x.WorkerId,
principalTable: "Workers",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "ProgramCurrencies",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProgramId = table.Column<int>(type: "int", nullable: false),
CurrencyId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProgramCurrencies", x => x.Id);
table.PrimaryKey("PK_ProgramCurrencies", x => new { x.ProgramId, x.CurrencyId });
table.ForeignKey(
name: "FK_ProgramCurrencies_Currencies_CurrencyId",
column: x => x.CurrencyId,
principalTable: "Currencies",
principalColumn: "Id");
principalColumn: "Id",
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ProgramCurrencies_Programs_ProgramId",
column: x => x.ProgramId,
principalTable: "Programs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -94,8 +89,8 @@ namespace BankDatabaseImplement.Migrations
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Duration = table.Column<int>(type: "int", nullable: false),
ProgramId = table.Column<int>(type: "int", nullable: false)
ProgramId = table.Column<int>(type: "int", nullable: false),
Duration = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
@ -105,14 +100,15 @@ namespace BankDatabaseImplement.Migrations
column: x => x.ProgramId,
principalTable: "Programs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Snils = table.Column<string>(type: "nvarchar(450)", nullable: false),
Snils = table.Column<string>(type: "nvarchar(400)", nullable: false),
ClientSurname = table.Column<string>(type: "nvarchar(max)", nullable: false),
ClientName = table.Column<string>(type: "nvarchar(max)", nullable: false),
ClientPatronymic = table.Column<string>(type: "nvarchar(max)", nullable: false),
@ -129,7 +125,8 @@ namespace BankDatabaseImplement.Migrations
column: x => x.WorkerId,
principalTable: "Workers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Restrict,
onUpdate: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -138,93 +135,90 @@ namespace BankDatabaseImplement.Migrations
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkerId = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
OpeningDate = table.Column<DateOnly>(type: "date", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Deposits", x => x.Id);
table.ForeignKey(
name: "FK_Deposits_Workers_WorkerId",
column: x => x.WorkerId,
principalTable: "Workers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientPrograms",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientSnils = table.Column<string>(type: "nvarchar(450)", nullable: false),
ClientSnils = table.Column<string>(type: "nvarchar(400)", nullable: false),
ProgramId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientPrograms", x => x.Id);
table.PrimaryKey("PK_ClientPrograms", x => new { x.ClientSnils, x.ProgramId });
table.ForeignKey(
name: "FK_ClientPrograms_Clients_ClientSnils",
column: x => x.ClientSnils,
principalTable: "Clients",
principalColumn: "Snils",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ClientPrograms_Programs_ProgramId",
column: x => x.ProgramId,
principalTable: "Programs",
principalColumn: "Id");
principalColumn: "Id",
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ClientDeposits",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientSnils = table.Column<string>(type: "nvarchar(450)", nullable: false),
ClientSnils = table.Column<string>(type: "nvarchar(400)", nullable: false),
DepositId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ClientDeposits", x => x.Id);
table.PrimaryKey("PK_ClientDeposits", x => new { x.ClientSnils, x.DepositId });
table.ForeignKey(
name: "FK_ClientDeposits_Clients_ClientSnils",
column: x => x.ClientSnils,
principalTable: "Clients",
principalColumn: "Snils",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ClientDeposits_Deposits_DepositId",
column: x => x.DepositId,
principalTable: "Deposits");
principalTable: "Deposits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "DepositCurrencies",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DepositId = table.Column<int>(type: "int", nullable: false),
CurrencyId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DepositCurrencies", x => x.Id);
table.PrimaryKey("PK_DepositCurrencies", x => new { x.DepositId, x.CurrencyId });
table.ForeignKey(
name: "FK_DepositCurrencies_Currencies_CurrencyId",
column: x => x.CurrencyId,
principalTable: "Currencies",
principalColumn: "Id");
principalColumn: "Id",
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DepositCurrencies_Deposits_DepositId",
column: x => x.DepositId,
principalTable: "Deposits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
@ -234,7 +228,6 @@ namespace BankDatabaseImplement.Migrations
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DepositId = table.Column<int>(type: "int", nullable: false),
WorkerId = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false),
RefillDate = table.Column<DateOnly>(type: "date", nullable: false)
},
@ -246,29 +239,15 @@ namespace BankDatabaseImplement.Migrations
column: x => x.DepositId,
principalTable: "Deposits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Refills_Workers_WorkerId",
column: x => x.WorkerId,
principalTable: "Workers",
principalColumn: "Id");
onDelete: ReferentialAction.Cascade,
onUpdate: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ClientDeposits_ClientSnils",
table: "ClientDeposits",
column: "ClientSnils");
migrationBuilder.CreateIndex(
name: "IX_ClientDeposits_DepositId",
table: "ClientDeposits",
column: "DepositId");
migrationBuilder.CreateIndex(
name: "IX_ClientPrograms_ClientSnils",
table: "ClientPrograms",
column: "ClientSnils");
migrationBuilder.CreateIndex(
name: "IX_ClientPrograms_ProgramId",
table: "ClientPrograms",
@ -284,45 +263,20 @@ namespace BankDatabaseImplement.Migrations
table: "DepositCurrencies",
column: "CurrencyId");
migrationBuilder.CreateIndex(
name: "IX_DepositCurrencies_DepositId",
table: "DepositCurrencies",
column: "DepositId");
migrationBuilder.CreateIndex(
name: "IX_Deposits_WorkerId",
table: "Deposits",
column: "WorkerId");
migrationBuilder.CreateIndex(
name: "IX_ProgramCurrencies_CurrencyId",
table: "ProgramCurrencies",
column: "CurrencyId");
migrationBuilder.CreateIndex(
name: "IX_ProgramCurrencies_ProgramId",
table: "ProgramCurrencies",
column: "ProgramId");
migrationBuilder.CreateIndex(
name: "IX_Refills_DepositId",
table: "Refills",
column: "DepositId");
migrationBuilder.CreateIndex(
name: "IX_Refills_WorkerId",
table: "Refills",
column: "WorkerId");
migrationBuilder.CreateIndex(
name: "IX_Terms_ProgramId",
table: "Terms",
column: "ProgramId");
migrationBuilder.CreateIndex(
name: "IX_Workers_WorkerId",
table: "Workers",
column: "WorkerId");
}
/// <inheritdoc />

View File

@ -63,22 +63,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientDeposit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientSnils")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("DepositId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientSnils");
b.HasKey("ClientSnils", "DepositId");
b.HasIndex("DepositId");
@ -87,22 +78,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientProgram", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientSnils")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<int>("ProgramId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientSnils");
b.HasKey("ClientSnils", "ProgramId");
b.HasIndex("ProgramId");
@ -155,24 +137,16 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.DepositCurrency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
b.Property<int>("DepositId")
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<int>("DepositId")
.HasColumnType("int");
b.HasKey("Id");
b.HasKey("DepositId", "CurrencyId");
b.HasIndex("CurrencyId");
b.HasIndex("DepositId");
b.ToTable("DepositCurrencies");
});
@ -198,24 +172,16 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ProgramCurrency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
b.Property<int>("ProgramId")
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<int>("ProgramId")
.HasColumnType("int");
b.HasKey("Id");
b.HasKey("ProgramId", "CurrencyId");
b.HasIndex("CurrencyId");
b.HasIndex("ProgramId");
b.ToTable("ProgramCurrencies");
});
@ -289,9 +255,6 @@ namespace BankDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("WorkerId")
.HasColumnType("int");
b.Property<string>("WorkerName")
.IsRequired()
.HasColumnType("nvarchar(max)");
@ -306,8 +269,6 @@ namespace BankDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("Workers");
});
@ -325,13 +286,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientDeposit", b =>
{
b.HasOne("BankDatabaseImplement.Models.Client", "Client")
.WithMany("Deposits")
.WithMany("ClientDeposits")
.HasForeignKey("ClientSnils")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Deposit", "Deposit")
.WithMany("Clients")
.WithMany("ClientDeposits")
.HasForeignKey("DepositId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -344,7 +305,7 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ClientProgram", b =>
{
b.HasOne("BankDatabaseImplement.Models.Client", "Client")
.WithMany("Programs")
.WithMany("ClientPrograms")
.HasForeignKey("ClientSnils")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -363,7 +324,7 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.Deposit", b =>
{
b.HasOne("BankDatabaseImplement.Models.Worker", "Worker")
.WithMany()
.WithMany("Deposits")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -374,13 +335,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.DepositCurrency", b =>
{
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany("Deposits")
.WithMany("DepositCurrencies")
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Deposit", "Deposit")
.WithMany("Currencies")
.WithMany("DepositCurrencies")
.HasForeignKey("DepositId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -393,13 +354,13 @@ namespace BankDatabaseImplement.Migrations
modelBuilder.Entity("BankDatabaseImplement.Models.ProgramCurrency", b =>
{
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany("Programs")
.WithMany("ProgramCurrencies")
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Program", "Program")
.WithMany("Currencies")
.WithMany("ProgramCurrencies")
.HasForeignKey("ProgramId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -418,7 +379,7 @@ namespace BankDatabaseImplement.Migrations
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Worker", "Worker")
.WithMany()
.WithMany("Refills")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -439,32 +400,25 @@ namespace BankDatabaseImplement.Migrations
b.Navigation("Program");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Worker", b =>
{
b.HasOne("BankDatabaseImplement.Models.Worker", null)
.WithMany("Workers")
.HasForeignKey("WorkerId");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Client", b =>
{
b.Navigation("Deposits");
b.Navigation("ClientDeposits");
b.Navigation("Programs");
b.Navigation("ClientPrograms");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Currency", b =>
{
b.Navigation("Deposits");
b.Navigation("DepositCurrencies");
b.Navigation("Programs");
b.Navigation("ProgramCurrencies");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Deposit", b =>
{
b.Navigation("Clients");
b.Navigation("ClientDeposits");
b.Navigation("Currencies");
b.Navigation("DepositCurrencies");
b.Navigation("Refills");
});
@ -473,14 +427,16 @@ namespace BankDatabaseImplement.Migrations
{
b.Navigation("Clients");
b.Navigation("Currencies");
b.Navigation("ProgramCurrencies");
b.Navigation("Terms");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Worker", b =>
{
b.Navigation("Workers");
b.Navigation("Deposits");
b.Navigation("Refills");
});
#pragma warning restore 612, 618
}

View File

@ -23,45 +23,39 @@ namespace BankDatabaseImplement.Models
public string PasswordHash { get; set; } = string.Empty;
[Required]
public int WorkerId { get; set; }
public virtual Worker? Worker { get; set; }
[ForeignKey("ClientSnils")]
public virtual List<ClientProgram> Programs { get; set; } = new();
private Dictionary<int, IProgramModel>?
_clientPrograms { get; set; } = null;
[ForeignKey("ClientSnils")]
public virtual List<ClientDeposit> Deposits { get; set; } = new();
private Dictionary<int, IDepositModel>?
_clientDeposits { get; set; } = null;
[NotMapped]
public Dictionary<int, IProgramModel> ClientPrograms
{
get
{
if (_clientPrograms == null)
{
_clientPrograms = Programs.ToDictionary(
x => x.ProgramId,
x => (x.Program as IProgramModel)
);
}
return _clientPrograms;
}
}
[NotMapped]
public Dictionary<int, IDepositModel> ClientDeposits
{
get
{
if (_clientDeposits == null)
{
_clientDeposits = Deposits.ToDictionary(
x => x.DepositId,
x => (x.Deposit as IDepositModel)
);
}
return _clientDeposits;
}
}
public virtual Worker Worker { get; set; } = null!;
public virtual List<ClientProgram> ClientPrograms { get; set; } = null!;
public virtual List<ClientDeposit> ClientDeposits { get; set; } = null!;
//[NotMapped]
//public Dictionary<int, IProgramModel> ClientPrograms
//{
// get
// {
// if (_clientPrograms == null)
// {
// _clientPrograms = Programs.ToDictionary(
// x => x.ProgramId,
// x => (x.Program as IProgramModel)
// );
// }
// return _clientPrograms;
// }
//}
//[NotMapped]
//public Dictionary<int, IDepositModel> ClientDeposits
//{
// get
// {
// if (_clientDeposits == null)
// {
// _clientDeposits = Deposits.ToDictionary(
// x => x.DepositId,
// x => (x.Deposit as IDepositModel)
// );
// }
// return _clientDeposits;
// }
//}
public static Client? Create(ClientBindingModel model)
{
if (model == null)

View File

@ -9,12 +9,10 @@ namespace BankDatabaseImplement.Models
{
public class ClientDeposit
{
public int Id { get; set; }
[Required]
public string ClientSnils { get; set; } = string.Empty;
[Required]
[ForeignKey("ClientSnils")]
public virtual Client Client { get; set; } = null!;
public int DepositId { get; set; }
public virtual Client Client { get; set; } = new();
public virtual Deposit Deposit { get; set; } = new();
public virtual Deposit Deposit { get; set; } = null!;
}
}

View File

@ -8,12 +8,10 @@ namespace BankDatabaseImplement.Models
{
public class ClientProgram
{
public int Id { get; set; }
[Required]
public string ClientSnils { get; set; } = string.Empty;
[Required]
[ForeignKey("ClientSnils")]
public virtual Client Client { get; set; } = null!;
public int ProgramId { get; set; }
public virtual Client Client { get; set; } = new();
public virtual Program Program { get; set; } = new();
public virtual Program Program { get; set; } = null!;
}
}

View File

@ -15,10 +15,8 @@ namespace BankDatabaseImplement.Models
public string CurrencyName { get; set; } = string.Empty;
[Required]
public double Course { get; set; }
[ForeignKey("CurrencyId")]
public virtual List<DepositCurrency> Deposits { get; set; } = new();
[ForeignKey("CurrencyId")]
public virtual List<ProgramCurrency> Programs { get; set; } = new();
public virtual List<DepositCurrency> DepositCurrencies { get; set; } = null!;
public virtual List<ProgramCurrency> ProgramCurrencies { get; set; } = null!;
public static Currency? Create(CurrencyBindingModel model)
{
if (model == null)

View File

@ -10,35 +10,12 @@ namespace BankDatabaseImplement.Models
{
public int Id { get; set; }
[Required]
public int WorkerId { get; set; }
public virtual Worker? Worker { get; set; }
[Required]
public double Sum { get; set; }
[Required]
public DateOnly OpeningDate { get; set; }
[ForeignKey("DepositId")]
public virtual List<DepositCurrency> Currencies { get; set; } = new();
[ForeignKey("DepositId")]
public virtual List<ClientDeposit> Clients { get; set; } = new();
[ForeignKey("DepositId")]
public virtual List<Refill> Refills { get; set; } = new();
private Dictionary<int, ICurrencyModel>?
_depositCurrencies { get; set; } = null;
[NotMapped]
public Dictionary<int, ICurrencyModel> DepositCurrencies
{
get
{
if (_depositCurrencies == null)
{
_depositCurrencies = Currencies.ToDictionary(
x => x.CurrencyId,
x => (x.Currency as ICurrencyModel)
);
}
return _depositCurrencies;
}
}
public virtual List<DepositCurrency> DepositCurrencies { get; set; } = null!;
public virtual List<ClientDeposit> ClientDeposits { get; set; } = null!;
public virtual List<Refill> Refills { get; set; } = null!;
public static Deposit? Create(DepositBindingModel model)
{
if (model == null)
@ -46,7 +23,6 @@ namespace BankDatabaseImplement.Models
return new Deposit
{
Id = model.Id,
WorkerId = model.WorkerId,
Sum = model.Sum,
};
}
@ -55,13 +31,11 @@ namespace BankDatabaseImplement.Models
if (model == null)
return;
Id = model.Id;
WorkerId = model.WorkerId;
Sum = model.Sum;
}
public DepositViewModel GetViewModel => new()
{
Id = Id,
WorkerId = WorkerId,
Sum = Sum,
};
}

View File

@ -8,12 +8,9 @@ namespace BankDatabaseImplement.Models
{
public class DepositCurrency
{
public int Id { get; set; }
[Required]
public int DepositId { get; set; }
[Required]
public virtual Deposit Deposit { get; set; } = null!;
public int CurrencyId { get; set; }
public virtual Deposit Deposit { get; set; } = new();
public virtual Currency Currency { get; set; } = new();
public virtual Currency Currency { get; set; } = null!;
}
}

View File

@ -13,30 +13,9 @@ namespace BankDatabaseImplement.Models
public string ProgramName { get; set; } = string.Empty;
[Required]
public double InterestRate { get; set; }
[ForeignKey("ProgramId")]
public virtual List<ProgramCurrency> Currencies { get; set; } = new();
[ForeignKey("ProgramId")]
public virtual List<ClientProgram> Clients { get; set; } = new();
[ForeignKey("ProgramId")]
public virtual List<Term> Terms { get; set; } = new();
private Dictionary<int, ICurrencyModel>?
_programCurrencies
{ get; set; } = null;
[NotMapped]
public Dictionary<int, ICurrencyModel> ProgramCurrencies
{
get
{
if (_programCurrencies == null)
{
_programCurrencies = Currencies.ToDictionary(
x => x.CurrencyId,
x => (x.Currency as ICurrencyModel)
);
}
return _programCurrencies;
}
}
public virtual List<ProgramCurrency> ProgramCurrencies { get; set; } = null!;
public virtual List<ClientProgram> Clients { get; set; } = null!;
public virtual List<Term> Terms { get; set; } = null!;
public static Program? Create(ProgramBindingModel model)
{
if (model == null)

View File

@ -8,12 +8,9 @@ namespace BankDatabaseImplement.Models
{
public class ProgramCurrency
{
public int Id { get; set; }
[Required]
public int ProgramId { get; set; }
[Required]
public virtual Program Program { get; set; } = null!;
public int CurrencyId { get; set; }
public virtual Program Program { get; set; } = new();
public virtual Currency Currency { get; set; } = new();
public virtual Currency Currency { get; set; } = null!;
}
}

View File

@ -11,10 +11,7 @@ namespace BankDatabaseImplement.Models
public int Id { get; set; }
[Required]
public int DepositId { get; set; }
public virtual Deposit? Deposit { get; set; }
[Required]
public int WorkerId { get; set; }
public virtual Worker? Worker { get; set; }
public virtual Deposit Deposit { get; set; } = null!;
[Required]
public double Sum { get; set; }
[Required]
@ -27,7 +24,6 @@ namespace BankDatabaseImplement.Models
{
Id = model.Id,
DepositId = model.DepositId,
WorkerId = model.WorkerId,
Sum = model.Sum,
RefillDate = model.RefillDate,
};
@ -38,7 +34,6 @@ namespace BankDatabaseImplement.Models
return;
Id = model.Id;
DepositId = model.DepositId;
WorkerId = model.WorkerId;
Sum = model.Sum;
RefillDate = model.RefillDate;
}
@ -46,7 +41,6 @@ namespace BankDatabaseImplement.Models
{
Id = Id,
DepositId = DepositId,
WorkerId = WorkerId,
Sum = Sum,
RefillDate = RefillDate,
};

View File

@ -10,10 +10,10 @@ namespace BankDatabaseImplement.Models
{
public int Id { get; set; }
[Required]
public int Duration { get; set; }
[Required]
public int ProgramId { get; set; }
public virtual Program? Program { get; set; }
public virtual Program Program { get; set; } = null!;
[Required]
public int Duration { get; set; }
public static Term? Create(TermBindingModel model)
{
if (model == null)

View File

@ -21,8 +21,8 @@ namespace BankDatabaseImplement.Models
public string Email { get; set; } = string.Empty;
[Required]
public string PasswordHash { get; set; } = string.Empty;
[ForeignKey("WorkerId")]
public virtual List<Worker> Workers { get; set; } = new();
public List<Deposit> Deposits { get; set; } = null!;
public List<Refill> Refills { get; set; } = null!;
public static Worker? Create(WorkerBindingModel model)
{
if (model == null)

View File

@ -1,30 +1,20 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:64404",
"sslPort": 44307
"applicationUrl": "http://localhost:27552",
"sslPort": 44383
}
},
"profiles": {
"http": {
"BankRestApi": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5142",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7061;http://localhost:5142",
"applicationUrl": "https://localhost:7177;http://localhost:5116",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
@ -38,4 +28,4 @@
}
}
}
}
}

View File

@ -1,5 +1,5 @@
using BankWorkerApp.Models;
using Microsoft.AspNetCore.Mvc;
using BankWorkerApp.Models;
using System.Diagnostics;
namespace BankWorkerApp.Controllers

View File

@ -10,9 +10,10 @@ namespace BankWorkerApp
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want

View File

@ -8,7 +8,7 @@
}
},
"profiles": {
"BankWorkerApp": {
"BankManagersClientApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
@ -26,3 +26,4 @@
}
}
}

View File

@ -1,8 +1,7 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
</div>

View File

@ -18,7 +18,7 @@ html {
}
body {
overflow-x: hidden;
background-color: #B2309D;
min-height: 100vh;
overflow-x: hidden;
background-color: #FFA500;
min-height: 100vh;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 15 KiB