diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs index bf60b49..2ef0c87 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs +++ b/BankYouBankrupt/BankYouBankruptClientApp/Controllers/HomeController.cs @@ -18,17 +18,6 @@ namespace BankYouBankruptClientApp.Controllers _logger = logger; } - [HttpGet] - public IActionResult Index() - { - if (APIClient.Client == null) - { - return Redirect("~/Home/Enter"); - } - - return View(APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}")); - } - [HttpGet] public IActionResult Profile() @@ -109,6 +98,18 @@ namespace BankYouBankruptClientApp.Controllers return; } + #region Карты + [HttpGet] + public IActionResult CardsList() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + + return View(APIClient.GetRequest>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}")); + } + [HttpGet] public IActionResult CreateCard() { if (APIClient.Client == null) @@ -134,7 +135,21 @@ namespace BankYouBankruptClientApp.Controllers Period = DateTime.Parse(period) }); - return Redirect("~/Home/Index"); + return Redirect("~/Home/CardsList"); + } + + #endregion + + + [HttpGet] + public IActionResult DebitingList() + { + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + + return View(APIClient.GetRequest>($"api/Client/getUsersDebitings?userId={APIClient.Client.Id}")); } } } \ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Index.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CardsList.cshtml similarity index 100% rename from BankYouBankrupt/BankYouBankruptClientApp/Views/Home/Index.cshtml rename to BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CardsList.cshtml diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreditingList.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreditingList.cshtml new file mode 100644 index 0000000..0f85fe3 --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/CreditingList.cshtml @@ -0,0 +1,67 @@ +@using BankYouBankruptContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Операция пополнения"; +} + +
+

Операция пополнения

+
+ +
+ @{ + if (Model == null) + { +

Сначала авторизируйтесь

+ return; + } +

+ Снять средства +

+ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер карты + + Сумма + + Статус + + Дата открытия + + Дата закрытия +
+ @Html.DisplayFor(modelItem => item.CardNumber) + + @Html.DisplayFor(modelItem => item.Sum) + + @Html.DisplayFor(modelItem => item.Status) + + @Html.DisplayFor(modelItem => item.DateOpen) + + @Html.DisplayFor(modelItem => item.DateClose) +
+ } +
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/DebitingList.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/DebitingList.cshtml new file mode 100644 index 0000000..c11c6da --- /dev/null +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Home/DebitingList.cshtml @@ -0,0 +1,67 @@ +@using BankYouBankruptContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "Операция снятия"; +} + +
+

Операция снятия

+
+ +
+ @{ + if (Model == null) + { +

Сначала авторизируйтесь

+ return; + } +

+ Снять средства +

+ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер карты + + Сумма + + Статус + + Дата открытия + + Дата закрытия +
+ @Html.DisplayFor(modelItem => item.CardNumber) + + @Html.DisplayFor(modelItem => item.Sum) + + @Html.DisplayFor(modelItem => item.Status) + + @Html.DisplayFor(modelItem => item.DateOpen) + + @Html.DisplayFor(modelItem => item.DateClose) +
+ } +
\ No newline at end of file diff --git a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml index 7585851..9c8e7fa 100644 --- a/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml +++ b/BankYouBankrupt/BankYouBankruptClientApp/Views/Shared/_Layout.cshtml @@ -26,9 +26,13 @@ @{ if (authenticated) { + } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs index 32a6ed7..e96251b 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/DebitingSearchModel.cs @@ -13,6 +13,8 @@ namespace BankYouBankruptContracts.SearchModels public int? CardId { get; set; } + public int? UserId { get; set; } + public int? Sum { get; set; } public DateTime? DateFrom { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs index 06db9c9..bd75e06 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/DebitingStorage.cs @@ -40,6 +40,11 @@ namespace BankYouBankruptDatabaseImplement.Implements .ToList(); } + if (model.UserId.HasValue) { + List cards = context.Cards.Where(x => x.ClientID == model.UserId).Select(x => x.Id).ToList(); + return context.Debitings.Include(x => x.Card).Where(x => cards.Contains(x.CardId)).Select(x => x.GetViewModel).ToList(); + } + return context.Debitings .Include(x => x.Card) .Select(x => x.GetViewModel) diff --git a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ClientController.cs b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ClientController.cs index cb9c46e..27044ef 100644 --- a/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ClientController.cs +++ b/BankYouBankrupt/BankYouBankruptRestAPI/Controllers/ClientController.cs @@ -17,10 +17,13 @@ namespace BankYouBankruptRestApi.Controllers private readonly IClientLogic _clientLogic; - public ClientController(IClientLogic clientLogic, ILogger logger) + private readonly IDebitingLogic _debitingLogic; + + public ClientController(IClientLogic clientLogic, IDebitingLogic debitingLogic, ILogger logger) { _logger = logger; _clientLogic = clientLogic; + _debitingLogic = debitingLogic; } [HttpGet] @@ -98,5 +101,21 @@ namespace BankYouBankruptRestApi.Controllers throw; } } + + [HttpGet] + public List? getUsersDebitings(int userId) { + try + { + return _debitingLogic.ReadList(new DebitingSearchModel() + { + UserId = userId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения пользователей"); + throw; + } + } } }