Debiting list

This commit is contained in:
shadowik 2023-05-17 14:27:46 +04:00
parent 1f9307fb0e
commit 48e605834f
8 changed files with 193 additions and 14 deletions

View File

@ -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<List<CardViewModel>>($"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<List<CardViewModel>>($"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<List<DebitingViewModel>>($"api/Client/getUsersDebitings?userId={APIClient.Client.Id}"));
}
}
}

View File

@ -0,0 +1,67 @@
@using BankYouBankruptContracts.ViewModels
@model List<CreditingViewModel>
@{
ViewData["Title"] = "Операция пополнения";
}
<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="CreateCard">Снять средства</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер карты
</th>
<th>
Сумма
</th>
<th>
Статус
</th>
<th>
Дата открытия
</th>
<th>
Дата закрытия
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CardNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sum)
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOpen)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateClose)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,67 @@
@using BankYouBankruptContracts.ViewModels
@model List<DebitingViewModel>
@{
ViewData["Title"] = "Операция снятия";
}
<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="CreateCard">Снять средства</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер карты
</th>
<th>
Сумма
</th>
<th>
Статус
</th>
<th>
Дата открытия
</th>
<th>
Дата закрытия
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CardNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sum)
</td>
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateOpen)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateClose)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -26,9 +26,13 @@
@{ if (authenticated) {
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Index">Карты</a>
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CardsList">Карты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="DebitingList">Снятие средств</a>
</li>
</ul>
}
}
</div>

View File

@ -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; }

View File

@ -40,6 +40,11 @@ namespace BankYouBankruptDatabaseImplement.Implements
.ToList();
}
if (model.UserId.HasValue) {
List<int> 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)

View File

@ -17,10 +17,13 @@ namespace BankYouBankruptRestApi.Controllers
private readonly IClientLogic _clientLogic;
public ClientController(IClientLogic clientLogic, ILogger<ClientController> logger)
private readonly IDebitingLogic _debitingLogic;
public ClientController(IClientLogic clientLogic, IDebitingLogic debitingLogic, ILogger<ClientController> logger)
{
_logger = logger;
_clientLogic = clientLogic;
_debitingLogic = debitingLogic;
}
[HttpGet]
@ -98,5 +101,21 @@ namespace BankYouBankruptRestApi.Controllers
throw;
}
}
[HttpGet]
public List<DebitingViewModel>? getUsersDebitings(int userId) {
try
{
return _debitingLogic.ReadList(new DebitingSearchModel()
{
UserId = userId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения пользователей");
throw;
}
}
}
}