From 59f7017528be7caa717ca080a07b8e515812aa11 Mon Sep 17 00:00:00 2001 From: abazov73 <92822431+abazov73@users.noreply.github.com> Date: Sat, 20 May 2023 05:14:55 +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=D0=B2=D0=B0=D0=BB=D1=8E=D1=82=20=D0=BA=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bank/BankDatabaseImplement/Models/Payment.cs | 2 +- .../OperatorApp/Controllers/HomeController.cs | 35 ++++++++++++++++++- Bank/OperatorApp/Program.cs | 1 + .../Views/Home/AddCurrenciesToPayment.cshtml | 24 +++++++++++++ Bank/OperatorApp/Views/Shared/_Layout.cshtml | 15 ++++---- 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 Bank/OperatorApp/Views/Home/AddCurrenciesToPayment.cshtml diff --git a/Bank/BankDatabaseImplement/Models/Payment.cs b/Bank/BankDatabaseImplement/Models/Payment.cs index 4f513a7..2504f82 100644 --- a/Bank/BankDatabaseImplement/Models/Payment.cs +++ b/Bank/BankDatabaseImplement/Models/Payment.cs @@ -111,7 +111,7 @@ namespace BankDatabaseImplement.Models public void UpdateCurrencies(BankDatabase context, PaymentBindingModel model) { var currencyPayments = context.CurrencyPayments.Where(rec => rec.PaymentId == model.Id).ToList(); - if (currencyPayments != null && currencyPayments.Count > 0) + if (currencyPayments != null) { context.CurrencyPayments.RemoveRange(currencyPayments.Where(rec => !model.CurrencyPayments.ContainsKey(rec.CurrencyId))); context.SaveChanges(); diff --git a/Bank/OperatorApp/Controllers/HomeController.cs b/Bank/OperatorApp/Controllers/HomeController.cs index eba9f65..03e1179 100644 --- a/Bank/OperatorApp/Controllers/HomeController.cs +++ b/Bank/OperatorApp/Controllers/HomeController.cs @@ -21,9 +21,10 @@ namespace OperatorApp.Controllers private readonly ITransferLogic _transferLogic; private readonly IOperatorLogic _operatorLogic; private readonly IReportLogic _reportLogic; + private readonly ICurrencyLogic _currencyLogic; private readonly AbstractMailWorker _mailWorker; - public HomeController(ILogger logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic, AbstractMailWorker mailWorker) + public HomeController(ILogger logger, IDealLogic dealLogic, IPaymentLogic paymentLogic, ITransferLogic transferLogic, IOperatorLogic operatorLogic, IReportLogic reportLogic, ICurrencyLogic currencyLogic, AbstractMailWorker mailWorker) { _logger = logger; _dealLogic = dealLogic; @@ -31,6 +32,7 @@ namespace OperatorApp.Controllers _transferLogic = transferLogic; _operatorLogic = operatorLogic; _reportLogic = reportLogic; + _currencyLogic = currencyLogic; _mailWorker = mailWorker; } @@ -344,5 +346,36 @@ namespace OperatorApp.Controllers return Redirect("/"); } } + [HttpGet] + public IActionResult AddCurrenciesToPayment() + { + if (APIClient.Operator == null) + { + Response.WriteAsync($""); + return Redirect("/Home/Enter"); + } + ViewBag.Currencies = _currencyLogic.ReadList(null); + ViewBag.Payments = _paymentLogic.ReadList(null); + return View(); + } + [HttpPost] + public void AddCurrenciesToPayment(int payment, List currencies) + { + if (APIClient.Operator == null) + { + Response.WriteAsync($""); + Redirect("/Home/Enter"); + } + var paymentModel = _paymentLogic.ReadElement(new PaymentSearchModel { Id = payment }); + Dictionary updCurrencies = new Dictionary(); + foreach (var currencyId in currencies) + { + var currency = _currencyLogic.ReadElement(new CurrencySearchModel { Id = currencyId }); + if (currency != null) updCurrencies.Add(currencyId, currency); + } + _paymentLogic.Update(new PaymentBindingModel { Id = paymentModel.Id, PaymentDate = paymentModel.PaymentDate, CurrencyPayments = updCurrencies }); + Response.WriteAsync($""); + Redirect("/"); + } } } \ No newline at end of file diff --git a/Bank/OperatorApp/Program.cs b/Bank/OperatorApp/Program.cs index 641b38a..a47f347 100644 --- a/Bank/OperatorApp/Program.cs +++ b/Bank/OperatorApp/Program.cs @@ -31,6 +31,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); var app = builder.Build(); diff --git a/Bank/OperatorApp/Views/Home/AddCurrenciesToPayment.cshtml b/Bank/OperatorApp/Views/Home/AddCurrenciesToPayment.cshtml new file mode 100644 index 0000000..10d3bdb --- /dev/null +++ b/Bank/OperatorApp/Views/Home/AddCurrenciesToPayment.cshtml @@ -0,0 +1,24 @@ +@{ + ViewData["Title"] = "CreatePayment"; +} +
+

Создание выплаты

+
+
+
+
Выплата:
+
+ +
+
+
+
Валюты:
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/Bank/OperatorApp/Views/Shared/_Layout.cshtml b/Bank/OperatorApp/Views/Shared/_Layout.cshtml index 887959a..d96ffaa 100644 --- a/Bank/OperatorApp/Views/Shared/_Layout.cshtml +++ b/Bank/OperatorApp/Views/Shared/_Layout.cshtml @@ -31,6 +31,15 @@ + + + @@ -40,12 +49,6 @@ - -