FullDebitings
This commit is contained in:
parent
4f3acf362a
commit
8ca968e67e
@ -2,6 +2,7 @@
|
|||||||
using BankYouBankruptClientApp.Models;
|
using BankYouBankruptClientApp.Models;
|
||||||
using BankYouBankruptContracts.BindingModels;
|
using BankYouBankruptContracts.BindingModels;
|
||||||
using BankYouBankruptContracts.ViewModels;
|
using BankYouBankruptContracts.ViewModels;
|
||||||
|
using BankYouBankruptDataModels.Enums;
|
||||||
using BankYouBankruptСlientApp;
|
using BankYouBankruptСlientApp;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -117,11 +118,12 @@ namespace BankYouBankruptClientApp.Controllers
|
|||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewBag.Accounts = APIClient.GetRequest<List<AccountViewModel>>($"api/Account/SearchAccountsOfCLient?clientId={APIClient.Client.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public IActionResult CreateCard(string account, string number, string cvc, string period) {
|
public IActionResult CreateCard(string accountId, string number, string cvc, string period) {
|
||||||
if (APIClient.Client == null)
|
if (APIClient.Client == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Не авторизованы");
|
throw new Exception("Не авторизованы");
|
||||||
@ -129,7 +131,7 @@ namespace BankYouBankruptClientApp.Controllers
|
|||||||
|
|
||||||
APIClient.PostRequest("api/Card/CreateCard", new CardBindingModel {
|
APIClient.PostRequest("api/Card/CreateCard", new CardBindingModel {
|
||||||
ClientID = APIClient.Client.Id,
|
ClientID = APIClient.Client.Id,
|
||||||
AccountId = int.Parse(account),
|
AccountId = int.Parse(accountId),
|
||||||
Number = number,
|
Number = number,
|
||||||
CVC = cvc,
|
CVC = cvc,
|
||||||
Period = DateTime.Parse(period)
|
Period = DateTime.Parse(period)
|
||||||
@ -141,6 +143,8 @@ namespace BankYouBankruptClientApp.Controllers
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Снятие средств
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult DebitingList()
|
public IActionResult DebitingList()
|
||||||
{
|
{
|
||||||
@ -151,5 +155,53 @@ namespace BankYouBankruptClientApp.Controllers
|
|||||||
|
|
||||||
return View(APIClient.GetRequest<List<DebitingViewModel>>($"api/Client/getUsersDebitings?userId={APIClient.Client.Id}"));
|
return View(APIClient.GetRequest<List<DebitingViewModel>>($"api/Client/getUsersDebitings?userId={APIClient.Client.Id}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateDebiting()
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/Card/GetUsersCardsList?id={APIClient.Client.Id}");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateDebiting(string cardId, int sum)
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Не авторизованы");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/Card/CreateDebitingRequest", new DebitingBindingModel()
|
||||||
|
{
|
||||||
|
CardId = int.Parse(cardId),
|
||||||
|
Sum = sum,
|
||||||
|
DateOpen = DateTime.Now,
|
||||||
|
Status = StatusEnum.Открыта
|
||||||
|
});
|
||||||
|
|
||||||
|
return Redirect("~/Home/DebitingList");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Пополнение средств
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreditingList()
|
||||||
|
{
|
||||||
|
if (APIClient.Client == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
return View(APIClient.GetRequest<List<CreditingViewModel>>($"api/Client/getUsersCreditings?userId={APIClient.Client.Id}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,9 +29,6 @@
|
|||||||
<th>
|
<th>
|
||||||
CVC
|
CVC
|
||||||
</th>
|
</th>
|
||||||
<th>
|
|
||||||
Фамилия владельца
|
|
||||||
</th>
|
|
||||||
<th>
|
<th>
|
||||||
Срок действия
|
Срок действия
|
||||||
</th>
|
</th>
|
||||||
@ -47,9 +44,6 @@
|
|||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.CVC)
|
@Html.DisplayFor(modelItem => item.CVC)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
@Html.DisplayFor(modelItem => item.ClientSurname)
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
@Html.DisplayFor(modelItem => item.Period)
|
@Html.DisplayFor(modelItem => item.Period)
|
||||||
</td>
|
</td>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Номер счета:</div>
|
<div class="col-4">Номер счета:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<input type="text" name="account" />
|
<select id="accountId" name="accountId" class="form-control" asp-items="@(new SelectList( @ViewBag.Accounts, "Id", "AccountNumber"))"></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Register";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Создание карты</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Номер счета:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="cardId" name="cardId" class="form-control" asp-items="@(new SelectList( @ViewBag.Cards, "Id", "Number"))"></select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Cумма операции:</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<input type="number" name="sum" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4">
|
||||||
|
<input type="submit" value="Создание" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -18,7 +18,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="CreateCard">Снять средства</a>
|
<a asp-action="CreateCard">Пополнить средства</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="CreateCard">Снять средства</a>
|
<a asp-action="CreateDebiting">Снять средства</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -31,6 +31,9 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="DebitingList">Снятие средств</a>
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="DebitingList">Снятие средств</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreditingList">Пополнить средства</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ namespace BankYouBankruptContracts.SearchModels
|
|||||||
|
|
||||||
public int? Sum { get; set; }
|
public int? Sum { get; set; }
|
||||||
|
|
||||||
|
public int? UserId { get; set; }
|
||||||
|
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
|
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
@ -27,11 +27,6 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
|||||||
|
|
||||||
public List<CreditingViewModel> GetFilteredList(CreditingSearchModel model)
|
public List<CreditingViewModel> GetFilteredList(CreditingSearchModel model)
|
||||||
{
|
{
|
||||||
if (model.CardId < 0)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
using var context = new BankYouBancruptDatabase();
|
using var context = new BankYouBancruptDatabase();
|
||||||
|
|
||||||
if (model.Status.HasValue)
|
if (model.Status.HasValue)
|
||||||
@ -43,6 +38,12 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.UserId.HasValue)
|
||||||
|
{
|
||||||
|
List<int> cards = context.Cards.Where(x => x.ClientID == model.UserId).Select(x => x.Id).ToList();
|
||||||
|
return context.Creditings.Include(x => x.Card).Where(x => cards.Contains(x.CardId)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
return context.Creditings
|
return context.Creditings
|
||||||
.Include(x => x.Card)
|
.Include(x => x.Card)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
|
@ -18,12 +18,15 @@ namespace BankYouBankruptRestApi.Controllers
|
|||||||
private readonly IClientLogic _clientLogic;
|
private readonly IClientLogic _clientLogic;
|
||||||
|
|
||||||
private readonly IDebitingLogic _debitingLogic;
|
private readonly IDebitingLogic _debitingLogic;
|
||||||
|
private readonly ICreditingLogic _creditingLogic;
|
||||||
|
|
||||||
public ClientController(IClientLogic clientLogic, IDebitingLogic debitingLogic, ILogger<ClientController> logger)
|
public ClientController(ILogger<ClientController> logger,
|
||||||
|
IClientLogic clientLogic, IDebitingLogic debitingLogic, ICreditingLogic creditingLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_clientLogic = clientLogic;
|
_clientLogic = clientLogic;
|
||||||
_debitingLogic = debitingLogic;
|
_debitingLogic = debitingLogic;
|
||||||
|
_creditingLogic = creditingLogic;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -117,5 +120,22 @@ namespace BankYouBankruptRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<CreditingViewModel>? getUsersCreditings(int userId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _creditingLogic.ReadList(new CreditingSearchModel()
|
||||||
|
{
|
||||||
|
UserId = userId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения пользователей");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user