From 08e2f1b8b5528e1b58942c26ab2c37f763325b85 Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Sat, 20 May 2023 02:10:55 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BA=D1=83=D0=BF=D0=BA=D0=B8=20=D0=B2=D0=B0=D0=BB=D1=8E?= =?UTF-8?q?=D1=82=20+=20=D0=B8=D1=85=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/CurrencyPurchaseBindingModel.cs | 2 +- .../Implements/CurrencyPurchaseStorage.cs | 10 +++++++++- Bank/BankOperatorApp/Controllers/HomeController.cs | 13 +++++++++++-- .../Views/Home/CreateCurrencyPurchase.cshtml | 2 +- .../BankOperatorApp/Views/Home/CreditProgram.cshtml | 4 ++-- .../Views/Home/CurrencyPurchases.cshtml | 2 +- Bank/BankOperatorApp/Views/Home/Index.cshtml | 2 +- Bank/BankOperatorApp/Views/Shared/_Layout.cshtml | 2 +- 8 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Bank/BankContracts/BindingModels/CurrencyPurchaseBindingModel.cs b/Bank/BankContracts/BindingModels/CurrencyPurchaseBindingModel.cs index d0b8727..ca5d54b 100644 --- a/Bank/BankContracts/BindingModels/CurrencyPurchaseBindingModel.cs +++ b/Bank/BankContracts/BindingModels/CurrencyPurchaseBindingModel.cs @@ -11,7 +11,7 @@ namespace BankContracts.BindingModels { public float Amount { get; set; } - public DateTime PurchaseDate { get; set; } = DateTime.Now.Date; + public DateTime PurchaseDate { get; set; } = DateTime.Now; public int BankOperatorId { get; set; } diff --git a/Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs b/Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs index 0e50b36..53d5773 100644 --- a/Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CurrencyPurchaseStorage.cs @@ -41,7 +41,7 @@ namespace BankDatabaseImplement.Implements public List GetFilteredList(CurrencyPurchaseSearchModel model) { - if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.BankOperatorId.HasValue) { return new(); } @@ -53,6 +53,14 @@ namespace BankDatabaseImplement.Implements .Select(x => x.GetViewModel) .ToList(); } + else if (model.BankOperatorId.HasValue) + { + using var context = new BankDatabase(); + return context.CurrencyPurchases.Include(x => x.BankOperator).Include(x => x.Currency) + .Where(x => x.BankOperatorId == model.BankOperatorId) + .Select(x => x.GetViewModel) + .ToList(); + } else { using var context = new BankDatabase(); diff --git a/Bank/BankOperatorApp/Controllers/HomeController.cs b/Bank/BankOperatorApp/Controllers/HomeController.cs index 9973ba6..126a8a3 100644 --- a/Bank/BankOperatorApp/Controllers/HomeController.cs +++ b/Bank/BankOperatorApp/Controllers/HomeController.cs @@ -210,8 +210,7 @@ namespace BankOperatorApp.Controllers { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } - ViewBag.Currency = _currencyLogic.ReadList - (new CurrencySearchModel { BankOperatorId = APIClient.BankOperator.Id }); + ViewBag.Currencies = _currencyLogic.ReadList(null); return View(); } [HttpPost] @@ -230,5 +229,15 @@ namespace BankOperatorApp.Controllers }); Response.Redirect("CurrencyPurchases"); } + + public IActionResult CurrencyPurchases() + { + if (APIClient.BankOperator == null) + { + return Redirect("~/Home/Enter"); + } + return View(_currencyPurchaseLogic.ReadList(new CurrencyPurchaseSearchModel + { BankOperatorId = APIClient.BankOperator.Id })); + } } } \ No newline at end of file diff --git a/Bank/BankOperatorApp/Views/Home/CreateCurrencyPurchase.cshtml b/Bank/BankOperatorApp/Views/Home/CreateCurrencyPurchase.cshtml index 17a6641..c0c31e5 100644 --- a/Bank/BankOperatorApp/Views/Home/CreateCurrencyPurchase.cshtml +++ b/Bank/BankOperatorApp/Views/Home/CreateCurrencyPurchase.cshtml @@ -8,7 +8,7 @@
Валюты::
-
diff --git a/Bank/BankOperatorApp/Views/Home/CreditProgram.cshtml b/Bank/BankOperatorApp/Views/Home/CreditProgram.cshtml index 02be98c..c613177 100644 --- a/Bank/BankOperatorApp/Views/Home/CreditProgram.cshtml +++ b/Bank/BankOperatorApp/Views/Home/CreditProgram.cshtml @@ -7,7 +7,7 @@ }
-

Кредитная программа№@Model.Id

+

Кредитная программа № @Model.Id

@@ -26,7 +26,7 @@

Валюты:

@foreach (var currency in Model.CreditProgramCurrencies) { -
Валюта №@currency.Value.Id, +
Валюта № @currency.Value.Id, @currency.Value.Name
} \ No newline at end of file diff --git a/Bank/BankOperatorApp/Views/Home/CurrencyPurchases.cshtml b/Bank/BankOperatorApp/Views/Home/CurrencyPurchases.cshtml index 08c0cdd..ddf22e5 100644 --- a/Bank/BankOperatorApp/Views/Home/CurrencyPurchases.cshtml +++ b/Bank/BankOperatorApp/Views/Home/CurrencyPurchases.cshtml @@ -19,7 +19,7 @@ return; }

- Купить валюту +

diff --git a/Bank/BankOperatorApp/Views/Home/Index.cshtml b/Bank/BankOperatorApp/Views/Home/Index.cshtml index 6c2adb4..77a4ac4 100644 --- a/Bank/BankOperatorApp/Views/Home/Index.cshtml +++ b/Bank/BankOperatorApp/Views/Home/Index.cshtml @@ -20,7 +20,7 @@ }

- Создать валюту +

diff --git a/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml b/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml index 5bcf537..6212d5c 100644 --- a/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml +++ b/Bank/BankOperatorApp/Views/Shared/_Layout.cshtml @@ -26,7 +26,7 @@ Кредитные программы