Merge branch 'main' of http://student.git.athene.tech/shadowik/CourseWork_BankYouBankrupt
This commit is contained in:
commit
97294824c2
@ -2,6 +2,7 @@
|
||||
using BankYouBankruptClientApp.Models;
|
||||
using BankYouBankruptContracts.BindingModels;
|
||||
using BankYouBankruptContracts.ViewModels;
|
||||
using BankYouBankruptDataModels.Enums;
|
||||
using BankYouBankruptСlientApp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
@ -117,11 +118,12 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Accounts = APIClient.GetRequest<List<AccountViewModel>>($"api/Account/SearchAccountsOfCLient?clientId={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[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)
|
||||
{
|
||||
throw new Exception("Не авторизованы");
|
||||
@ -129,7 +131,7 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
|
||||
APIClient.PostRequest("api/Card/CreateCard", new CardBindingModel {
|
||||
ClientID = APIClient.Client.Id,
|
||||
AccountId = int.Parse(account),
|
||||
AccountId = int.Parse(accountId),
|
||||
Number = number,
|
||||
CVC = cvc,
|
||||
Period = DateTime.Parse(period)
|
||||
@ -141,6 +143,8 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
#endregion
|
||||
|
||||
|
||||
#region Снятие средств
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult DebitingList()
|
||||
{
|
||||
@ -151,5 +155,53 @@ namespace BankYouBankruptClientApp.Controllers
|
||||
|
||||
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>
|
||||
CVC
|
||||
</th>
|
||||
<th>
|
||||
Фамилия владельца
|
||||
</th>
|
||||
<th>
|
||||
Срок действия
|
||||
</th>
|
||||
@ -47,9 +44,6 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CVC)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ClientSurname)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Period)
|
||||
</td>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Номер счета:</div>
|
||||
<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 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;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateCard">Снять средства</a>
|
||||
<a asp-action="CreateCard">Пополнить средства</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -18,7 +18,7 @@
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateCard">Снять средства</a>
|
||||
<a asp-action="CreateDebiting">Снять средства</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -31,6 +31,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="DebitingList">Снятие средств</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="CreditingList">Пополнить средства</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ namespace BankYouBankruptContracts.SearchModels
|
||||
|
||||
public int? Sum { get; set; }
|
||||
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
|
@ -27,11 +27,6 @@ namespace BankYouBankruptDatabaseImplement.Implements
|
||||
|
||||
public List<CreditingViewModel> GetFilteredList(CreditingSearchModel model)
|
||||
{
|
||||
if (model.CardId < 0)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BankYouBancruptDatabase();
|
||||
|
||||
if (model.Status.HasValue)
|
||||
@ -43,6 +38,12 @@ 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.Creditings.Include(x => x.Card).Where(x => cards.Contains(x.CardId)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
return context.Creditings
|
||||
.Include(x => x.Card)
|
||||
.Select(x => x.GetViewModel)
|
||||
|
@ -18,12 +18,15 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
private readonly IClientLogic _clientLogic;
|
||||
|
||||
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;
|
||||
_clientLogic = clientLogic;
|
||||
_debitingLogic = debitingLogic;
|
||||
_creditingLogic = creditingLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -117,5 +120,22 @@ namespace BankYouBankruptRestApi.Controllers
|
||||
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