From 56f7e44dd496efe1e1b1ef67b9d9a15826d8cfcd Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Sat, 20 May 2023 06:25:15 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=B2=D1=8F=D0=B7=D0=BA?= =?UTF-8?q?=D0=B0=20"=D1=81=D0=B4=D0=B5=D0=BB=D0=BA=D0=B0-=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D0=B0".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 58 ++++++++++++++++--- Bank/BankOperatorApp/Program.cs | 1 + .../Views/Home/AddDealsToCreditProgram.cshtml | 24 ++++++++ .../Views/Shared/_Layout.cshtml | 3 + 4 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 Bank/BankOperatorApp/Views/Home/AddDealsToCreditProgram.cshtml diff --git a/Bank/BankOperatorApp/Controllers/HomeController.cs b/Bank/BankOperatorApp/Controllers/HomeController.cs index b0cb35f..49ee135 100644 --- a/Bank/BankOperatorApp/Controllers/HomeController.cs +++ b/Bank/BankOperatorApp/Controllers/HomeController.cs @@ -18,6 +18,7 @@ namespace BankOperatorApp.Controllers private readonly ICreditProgramLogic _creditProgramLogic; private readonly ICurrencyLogic _currencyLogic; private readonly ICurrencyPurchaseLogic _currencyPurchaseLogic; + private readonly IDealLogic _dealLogic; private readonly IReportLogic _reportLogic; private readonly AbstractMailWorker _mailWorker; public static BankOperatorViewModel? BankOperator { get; set; } = null; @@ -25,7 +26,8 @@ namespace BankOperatorApp.Controllers public HomeController(ILogger logger, IBankOperatorLogic bankOperatorLogic, ICreditProgramLogic creditProgramLogic, ICurrencyLogic currencyLogic, - ICurrencyPurchaseLogic currencyPurchaseLogic, IReportLogic reportLogic, AbstractMailWorker mailWorker) + ICurrencyPurchaseLogic currencyPurchaseLogic, IReportLogic reportLogic, + IDealLogic dealLogic, AbstractMailWorker mailWorker) { _logger = logger; _bankOperatorLogic = bankOperatorLogic; @@ -33,6 +35,7 @@ namespace BankOperatorApp.Controllers _currencyLogic = currencyLogic; _currencyPurchaseLogic = currencyPurchaseLogic; _reportLogic = reportLogic; + _dealLogic = dealLogic; _mailWorker = mailWorker; } @@ -110,7 +113,8 @@ namespace BankOperatorApp.Controllers (new BankOperatorSearchModel { Login = login, Password = password }); if (HomeController.BankOperator == null) { - throw new Exception("Неверный логин/пароль"); + Response.WriteAsync($""); + return; } Response.Redirect("Index"); } @@ -153,7 +157,9 @@ namespace BankOperatorApp.Controllers { if (HomeController.BankOperator == null) { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Response.WriteAsync($""); + Redirect("/Home/Enter"); } _currencyLogic.Create(new CurrencyBindingModel { @@ -182,7 +188,9 @@ namespace BankOperatorApp.Controllers { if (HomeController.BankOperator == null) { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Response.WriteAsync($""); + Redirect("/Home/Enter"); } Dictionary CurrencyCreditPrograms = new(); foreach (int id in currencies) @@ -205,7 +213,9 @@ namespace BankOperatorApp.Controllers { if (HomeController.BankOperator == null) { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Response.WriteAsync($""); + return Redirect("/Home/Enter"); } return View(_currencyPurchaseLogic.ReadList (new CurrencyPurchaseSearchModel { BankOperatorId = HomeController.BankOperator.Id })); @@ -215,7 +225,9 @@ namespace BankOperatorApp.Controllers { if (HomeController.BankOperator == null) { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Response.WriteAsync($""); + return Redirect("/Home/Enter"); } ViewBag.Currencies = _currencyLogic.ReadList(null); return View(); @@ -225,7 +237,9 @@ namespace BankOperatorApp.Controllers { if (HomeController.BankOperator == null) { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + Response.WriteAsync($""); + Redirect("/Home/Enter"); } _currencyPurchaseLogic.Create(new CurrencyPurchaseBindingModel @@ -345,5 +359,35 @@ namespace BankOperatorApp.Controllers return Redirect("/"); } } + + public IActionResult AddDealsToCreditProgram() + { + if (HomeController.BankOperator == null) + { + Response.WriteAsync($""); + return Redirect("/Home/Enter"); + } + ViewBag.CreditPrograms = _creditProgramLogic.ReadList(new CreditProgramSearchModel { BankOperatorId = HomeController.BankOperator.Id}); + ViewBag.Deals = _dealLogic.ReadList(null); + return View(); + } + + [HttpPost] + public void AddDealsToCreditProgram(int creditProgram, List deals) + { + if (HomeController.BankOperator == null) + { + Response.WriteAsync($""); + Redirect("/Home/Enter"); + } + foreach (var dealId in deals) + { + var deal = _dealLogic.ReadElement(new DealSearchModel { Id = dealId }); + if (deal != null) _dealLogic.Update(new DealBindingModel { Id = deal.Id, ClientId = deal.ClientId, CreditProgramId = creditProgram }); + } + Response.WriteAsync($""); + Redirect("/"); + } } } \ No newline at end of file diff --git a/Bank/BankOperatorApp/Program.cs b/Bank/BankOperatorApp/Program.cs index f0dbb15..08918f7 100644 --- a/Bank/BankOperatorApp/Program.cs +++ b/Bank/BankOperatorApp/Program.cs @@ -33,6 +33,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddControllersWithViews(); diff --git a/Bank/BankOperatorApp/Views/Home/AddDealsToCreditProgram.cshtml b/Bank/BankOperatorApp/Views/Home/AddDealsToCreditProgram.cshtml new file mode 100644 index 0000000..e2d6f8e --- /dev/null +++ b/Bank/BankOperatorApp/Views/Home/AddDealsToCreditProgram.cshtml @@ -0,0 +1,24 @@ +@{ + ViewData["Title"] = "CreatePayment"; +} +
+

Привязка сделок

+
+
+
+
Выплата:
+
+ +
+
+
+
Сделки:
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml b/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml index 0f4ddb8..561b489 100644 --- a/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml +++ b/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml @@ -33,6 +33,9 @@ +