Формы. Фикс отображения валют в кредитной программе. Фикс отображения имени оператора.

This commit is contained in:
ksenianeva 2023-05-20 01:24:08 +04:00
parent e60309c7dd
commit 98e1450a2b
16 changed files with 720 additions and 36 deletions

View File

@ -47,7 +47,6 @@ namespace BankBusinessLogic.BusinessLogics
_logger.LogWarning("ReadElement element not found"); _logger.LogWarning("ReadElement element not found");
return null; return null;
} }
_logger.LogInformation("ReadElement find. Id:{Id}. Login: { Login}", element.Id);
return element; return element;
} }
public bool Create(BankOperatorBindingModel model) public bool Create(BankOperatorBindingModel model)

View File

@ -35,6 +35,7 @@ namespace BankDatabaseImplement.Implements
} }
using var context = new BankDatabase(); using var context = new BankDatabase();
return context.CreditPrograms.Include(x => x.BankOperator) return context.CreditPrograms.Include(x => x.BankOperator)
.Include(x => x.Currencies).ThenInclude(x => x.Currency)
.FirstOrDefault(x => x.Id == model.Id) .FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel; ?.GetViewModel;
} }
@ -49,6 +50,7 @@ namespace BankDatabaseImplement.Implements
{ {
using var context = new BankDatabase(); using var context = new BankDatabase();
return context.CreditPrograms.Include(x => x.BankOperator) return context.CreditPrograms.Include(x => x.BankOperator)
.Include(x => x.Currencies).ThenInclude(x => x.Currency)
.Where(x => x.BankOperatorId == model.BankOperatorId) .Where(x => x.BankOperatorId == model.BankOperatorId)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
@ -57,6 +59,7 @@ namespace BankDatabaseImplement.Implements
{ {
using var context = new BankDatabase(); using var context = new BankDatabase();
return context.CreditPrograms.Include(x => x.BankOperator) return context.CreditPrograms.Include(x => x.BankOperator)
.Include(x => x.Currencies).ThenInclude(x => x.Currency)
.Where(x => x.Id == model.Id) .Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
@ -67,6 +70,7 @@ namespace BankDatabaseImplement.Implements
{ {
using var context = new BankDatabase(); using var context = new BankDatabase();
return context.CreditPrograms.Include(x => x.BankOperator) return context.CreditPrograms.Include(x => x.BankOperator)
.Include(x => x.Currencies).ThenInclude(x => x.Currency)
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }

View File

@ -0,0 +1,485 @@
// <auto-generated />
using System;
using BankDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BankDatabaseImplement.Migrations
{
[DbContext(typeof(BankDatabase))]
[Migration("20230519211435_FixCurrencyAndCreditProgramRelation")]
partial class FixCurrencyAndCreditProgramRelation
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("BankDatabaseImplement.Models.BankOperator", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MiddleName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("BankOperators");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CreditProgram", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("BankOperatorId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<float>("Percent")
.HasColumnType("real");
b.HasKey("Id");
b.HasIndex("BankOperatorId");
b.ToTable("CreditPrograms");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CreditProgramCurrency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CreditProgramId")
.HasColumnType("int");
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CreditProgramId");
b.HasIndex("CurrencyId");
b.ToTable("CreditProgramCurrencies");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Currency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("BankOperatorId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("BankOperatorId");
b.ToTable("Currencies");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CurrencyPayment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<int>("PaymentId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CurrencyId");
b.HasIndex("PaymentId");
b.ToTable("CurrencyPayments");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CurrencyPurchase", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<float>("Amount")
.HasColumnType("real");
b.Property<int>("BankOperatorId")
.HasColumnType("int");
b.Property<int>("CurrencyId")
.HasColumnType("int");
b.Property<DateTime>("PurchaseDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("BankOperatorId");
b.HasIndex("CurrencyId");
b.ToTable("CurrencyPurchases");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Deal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int?>("CreditProgramId")
.HasColumnType("int");
b.Property<DateTime>("DealDate")
.HasColumnType("datetime2");
b.Property<int>("OperatorId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CreditProgramId");
b.HasIndex("OperatorId");
b.ToTable("Deals");
});
modelBuilder.Entity("BankDatabaseImplement.Models.DealPayment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DealId")
.HasColumnType("int");
b.Property<int>("PaymentId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DealId");
b.HasIndex("PaymentId");
b.ToTable("DealPayments");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Operator", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MiddleName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Operators");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Payment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("OperatorId")
.HasColumnType("int");
b.Property<DateTime>("PaymentDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("OperatorId");
b.ToTable("Payments");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Transfer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<float>("Amount")
.HasColumnType("real");
b.Property<int>("OperatorId")
.HasColumnType("int");
b.Property<int>("PaymentId")
.HasColumnType("int");
b.Property<DateTime>("TransferDateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("OperatorId");
b.HasIndex("PaymentId");
b.ToTable("Transfers");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CreditProgram", b =>
{
b.HasOne("BankDatabaseImplement.Models.BankOperator", "BankOperator")
.WithMany()
.HasForeignKey("BankOperatorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BankOperator");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CreditProgramCurrency", b =>
{
b.HasOne("BankDatabaseImplement.Models.CreditProgram", "CreditProgram")
.WithMany("Currencies")
.HasForeignKey("CreditProgramId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany("CreditProgramCurrency")
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CreditProgram");
b.Navigation("Currency");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Currency", b =>
{
b.HasOne("BankDatabaseImplement.Models.BankOperator", "BankOperator")
.WithMany()
.HasForeignKey("BankOperatorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BankOperator");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CurrencyPayment", b =>
{
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany()
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Payment", "Payment")
.WithMany("Currencies")
.HasForeignKey("PaymentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Currency");
b.Navigation("Payment");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CurrencyPurchase", b =>
{
b.HasOne("BankDatabaseImplement.Models.BankOperator", "BankOperator")
.WithMany()
.HasForeignKey("BankOperatorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany()
.HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("BankOperator");
b.Navigation("Currency");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Deal", b =>
{
b.HasOne("BankDatabaseImplement.Models.CreditProgram", "CreditProgram")
.WithMany()
.HasForeignKey("CreditProgramId");
b.HasOne("BankDatabaseImplement.Models.Operator", "Operator")
.WithMany()
.HasForeignKey("OperatorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CreditProgram");
b.Navigation("Operator");
});
modelBuilder.Entity("BankDatabaseImplement.Models.DealPayment", b =>
{
b.HasOne("BankDatabaseImplement.Models.Deal", "Deal")
.WithMany("DealPayments")
.HasForeignKey("DealId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Payment", "Payment")
.WithMany("Deals")
.HasForeignKey("PaymentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Deal");
b.Navigation("Payment");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Payment", b =>
{
b.HasOne("BankDatabaseImplement.Models.Operator", "Operator")
.WithMany()
.HasForeignKey("OperatorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Operator");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Transfer", b =>
{
b.HasOne("BankDatabaseImplement.Models.Operator", "Operator")
.WithMany()
.HasForeignKey("OperatorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BankDatabaseImplement.Models.Payment", "Payment")
.WithMany()
.HasForeignKey("PaymentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Operator");
b.Navigation("Payment");
});
modelBuilder.Entity("BankDatabaseImplement.Models.CreditProgram", b =>
{
b.Navigation("Currencies");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Currency", b =>
{
b.Navigation("CreditProgramCurrency");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Deal", b =>
{
b.Navigation("DealPayments");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Payment", b =>
{
b.Navigation("Currencies");
b.Navigation("Deals");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BankDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class FixCurrencyAndCreditProgramRelation : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -17,7 +17,7 @@ namespace BankDatabaseImplement.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.4") .HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@ -330,7 +330,7 @@ namespace BankDatabaseImplement.Migrations
.IsRequired(); .IsRequired();
b.HasOne("BankDatabaseImplement.Models.Currency", "Currency") b.HasOne("BankDatabaseImplement.Models.Currency", "Currency")
.WithMany() .WithMany("CreditProgramCurrency")
.HasForeignKey("CurrencyId") .HasForeignKey("CurrencyId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
@ -460,6 +460,11 @@ namespace BankDatabaseImplement.Migrations
b.Navigation("Currencies"); b.Navigation("Currencies");
}); });
modelBuilder.Entity("BankDatabaseImplement.Models.Currency", b =>
{
b.Navigation("CreditProgramCurrency");
});
modelBuilder.Entity("BankDatabaseImplement.Models.Deal", b => modelBuilder.Entity("BankDatabaseImplement.Models.Deal", b =>
{ {
b.Navigation("DealPayments"); b.Navigation("DealPayments");

View File

@ -68,6 +68,9 @@ namespace BankDatabaseImplement.Models
public CreditProgramViewModel GetViewModel => new() public CreditProgramViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
BankOperatorFIO = BankOperator.LastName + " "
+ BankOperator.FirstName + " "
+ BankOperator.MiddleName,
Name = Name, Name = Name,
Percent = Percent, Percent = Percent,
CreditProgramCurrencies = CreditProgramCurrencies, CreditProgramCurrencies = CreditProgramCurrencies,

View File

@ -18,6 +18,8 @@ namespace BankDatabaseImplement.Models
public string Name { get; set; } public string Name { get; set; }
public int BankOperatorId { get; set; } public int BankOperatorId { get; set; }
public virtual BankOperator BankOperator { get; set; } = new(); public virtual BankOperator BankOperator { get; set; } = new();
[ForeignKey("CurrencyId")]
public virtual List<CreditProgramCurrency> CreditProgramCurrency { get; set; } = new();
public static Currency? Create(BankDatabase context, CurrencyBindingModel model) public static Currency? Create(BankDatabase context, CurrencyBindingModel model)
{ {
if (model == null) if (model == null)
@ -56,6 +58,9 @@ namespace BankDatabaseImplement.Models
{ {
Id = Id, Id = Id,
Name = Name, Name = Name,
BankOperatorName = BankOperator.LastName + " "
+ BankOperator.FirstName + " "
+ BankOperator.MiddleName,
}; };
} }
} }

View File

@ -7,11 +7,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\BankBusinessLogic\BankBusinessLogic.csproj" />
<ProjectReference Include="..\BankContracts\BankContracts.csproj" /> <ProjectReference Include="..\BankContracts\BankContracts.csproj" />
<ProjectReference Include="..\BankDatabaseImplement\BankDatabaseImplement.csproj" />
<ProjectReference Include="..\BankDataModels\BankDataModels.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -6,6 +6,7 @@ using System.Diagnostics;
using BankContracts.BusinessLogicsContracts; using BankContracts.BusinessLogicsContracts;
using BankContracts.SearchModels; using BankContracts.SearchModels;
using BankDataModels.Models; using BankDataModels.Models;
using BankBusinessLogic.BusinessLogics;
namespace BankOperatorApp.Controllers namespace BankOperatorApp.Controllers
{ {
@ -56,12 +57,11 @@ namespace BankOperatorApp.Controllers
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(middleName))
|| string.IsNullOrEmpty(lastname) || string.IsNullOrEmpty(firstname) || string.IsNullOrEmpty(middleName))
{ {
throw new Exception("Введите логин, пароль и ФИО"); throw new Exception("Введите логин, пароль и ФИО");
} }
APIClient.PostRequest("api/bankoperator/updatebankoperator", new OperatorBindingModel _bankOperatorLogic.Update(new BankOperatorBindingModel
{ {
Id = APIClient.BankOperator.Id, Id = APIClient.BankOperator.Id,
LastName = lastname, LastName = lastname,
@ -99,9 +99,8 @@ namespace BankOperatorApp.Controllers
{ {
throw new Exception("Введите логин и пароль"); throw new Exception("Введите логин и пароль");
} }
APIClient.BankOperator = APIClient. APIClient.BankOperator = _bankOperatorLogic.ReadElement
GetRequest<BankOperatorViewModel> (new BankOperatorSearchModel { Login = login, Password = password });
($"api/bankoperator/login?login={login}&password={password}");
if (APIClient.BankOperator == null) if (APIClient.BankOperator == null)
{ {
throw new Exception("Неверный логин/пароль"); throw new Exception("Неверный логин/пароль");
@ -125,7 +124,7 @@ namespace BankOperatorApp.Controllers
{ {
throw new Exception("Введите логин, пароль и ФИО"); throw new Exception("Введите логин, пароль и ФИО");
} }
APIClient.PostRequest("api/bankoperator/createbankoperator", new BankOperatorBindingModel _bankOperatorLogic.Create(new BankOperatorBindingModel
{ {
LastName = lastname, LastName = lastname,
FirstName = firstname, FirstName = firstname,
@ -149,10 +148,10 @@ namespace BankOperatorApp.Controllers
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
APIClient.PostRequest("api/currency/createcurrency", new CurrencyBindingModel _currencyLogic.Create(new CurrencyBindingModel
{ {
BankOperatorId = APIClient.BankOperator.Id,
Name = name, Name = name,
BankOperatorId = APIClient.BankOperator.Id,
}); });
Response.Redirect("Index"); Response.Redirect("Index");
} }
@ -162,34 +161,32 @@ namespace BankOperatorApp.Controllers
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APIClient.GetRequest return View(_creditProgramLogic.ReadList(new CreditProgramSearchModel
<List<PaymentViewModel>> { BankOperatorId = APIClient.BankOperator.Id}));
($"api/creditprogram/getcreditprograms?bankoperatorId={APIClient.BankOperator.Id}"));
} }
[HttpGet] [HttpGet]
public IActionResult CreateCreditProgram() public IActionResult CreateCreditProgram()
{ {
ViewBag.Currencies = APIClient.GetRequest<List<CurrencyViewModel>> ViewBag.Currencies = _currencyLogic.ReadList(null);
("api/currency/getcurrencieslist");
return View(); return View();
} }
[HttpPost] [HttpPost]
public void CreateCreditProgram(List<int> currenciess) public void CreateCreditProgram(List<int> currencies, string name, float percent)
{ {
if (APIClient.BankOperator == null) if (APIClient.BankOperator == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
Dictionary<int, ICurrencyModel> CurrencyCreditPrograms = new(); Dictionary<int, ICurrencyModel> CurrencyCreditPrograms = new();
foreach (int id in currenciess) foreach (int id in currencies)
{ {
var currency = _currencyLogic.ReadElement(new CurrencySearchModel { Id = id }); var currency = _currencyLogic.ReadElement(new CurrencySearchModel { Id = id });
if (currency != null) CurrencyCreditPrograms.Add(currency.Id, currency); if (currency != null) CurrencyCreditPrograms.Add(currency.Id, currency);
} }
_creditProgramLogic.Create(new CreditProgramBindingModel { BankOperatorId = _creditProgramLogic.Create(new CreditProgramBindingModel { BankOperatorId =
APIClient.BankOperator.Id, APIClient.BankOperator.Id,
CreditProgramCurrencies = CurrencyCreditPrograms, }); CreditProgramCurrencies = CurrencyCreditPrograms, Name = name, Percent = percent});
Response.Redirect("Payments"); Response.Redirect("CreditPrograms");
} }
[HttpGet] [HttpGet]
public IActionResult CreditProgram(int id) public IActionResult CreditProgram(int id)

View File

@ -1,8 +1,32 @@
using BankBusinessLogic.BusinessLogics;
using BankContracts.BusinessLogicsContracts;
using BankContracts.StoragesContracts;
using BankDatabaseImplement.Implements;
using BankContracts.BindingModels;
using BankOperatorApp;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
builder.Services.AddTransient<ICurrencyPurchaseStorage, CurrencyPurchaseStorage>();
builder.Services.AddTransient<ICurrencyStorage, CurrencyStorage>();
builder.Services.AddTransient<ICreditProgramStorage, CreditProgramStorage>();
builder.Services.AddTransient<IBankOperatorStorage, BankOperatorStorage>();
builder.Services.AddTransient<IDealStorage, DealStorage>();
builder.Services.AddTransient<ITransferStorage, TransferStorage>();
builder.Services.AddTransient<IPaymentStorage, PaymentStorage>();
builder.Services.AddTransient<ICurrencyPurchaseLogic, CurrencyPurchaseLogic>();
builder.Services.AddTransient<ICurrencyLogic, CurrencyLogic>();
builder.Services.AddTransient<ICreditProgramLogic, CreditProgramLogic>();
builder.Services.AddTransient<IBankOperatorLogic, BankOperatorLogic>();
builder.Services.AddControllersWithViews();
var app = builder.Build(); var app = builder.Build();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.

View File

@ -0,0 +1,27 @@
@{
ViewData["Title"] = "CreateCreditProgram";
}
<div class="text-center">
<h2 class="display-4">Создание кредитной программы</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" /></div>
</div>
<div class="row">
<div class="col-4">Процент:</div>
<div class="col-8"><input type="text" name="percent" id="percent" /></div>
</div>
<div class="row">
<div class="col-4">Валюты:</div>
<div class="col-8">
<select id="currencies" name="currencies" class="form-control"
multiple asp-items="@(new SelectList(@ViewBag.Currencies,"Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,16 @@
@{
ViewData["Title"] = "CreateCurrency";
}
<div class="text-center">
<h2 class="display-4">Создание валюты</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -0,0 +1,23 @@
@{
ViewData["Title"] = "CreateCurrencyPurchase";
}
<div class="text-center">
<h2 class="display-4">Создание закупки валют</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Валюты::</div>
<div class="col-8">
<select id="currency" name="currency" class="form-control"
asp-items="@(new SelectList(@ViewBag.Currencies,"Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" name="amount" id="amount" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -1,5 +1,66 @@
@* @using BankContracts.ViewModels
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@ @model List<CreditProgramViewModel>
@{ @{
ViewData["Title"] = "CreditPrograms";
} }
<div class="text-center">
<h1 class="display-4">Кредитные программы</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="CreateCreditProgram">Создать кредитную программу</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название программы
</th>
<th>
Процент кредитования
</th>
<th>
ФИО оператора
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Percent)
</td>
<td>
@Html.DisplayFor(modelItem => item.BankOperatorFIO)
</td>
<td>
<a asp-action="CreditProgram" asp-route-id="@item.Id">Подробнее</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -31,9 +31,6 @@
<th> <th>
Название валюты Название валюты
</th> </th>
<th>
ФИО оператора
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -46,9 +43,6 @@
<td> <td>
@Html.DisplayFor(modelItem => item.Name) @Html.DisplayFor(modelItem => item.Name)
</td> </td>
<td>
@Html.DisplayFor(modelItem => item.BankOperatorName)
</td>
</tr> </tr>
} }
</tbody> </tbody>

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - BankOperatorApp</title> <title>@ViewData["Title"] - Банк "Вы банкрот!" - приложение оператора</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/BankOperatorApp.styles.css" asp-append-version="true" /> <link rel="stylesheet" href="~/BankOperatorApp.styles.css" asp-append-version="true" />
@ -12,18 +12,30 @@
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">BankOperatorApp</a> <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Оператор</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Валюты</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CreditPrograms">Кредитные программы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CurrencyPurchases">Закупкия</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li> </li>
</ul> </ul>
</div> </div>