CloseCrediting.cshtml

This commit is contained in:
Programmist73 2023-05-17 18:26:43 +04:00
parent 841d1e435a
commit 0e96f959d2
8 changed files with 112 additions and 5 deletions

View File

@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankYouBankruptRestAPI", "B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankYouBankruptCashierApp", "BankYouBankruptCashierApp\BankYouBankruptCashierApp.csproj", "{3530E2D9-CC6C-4F88-B9AA-90F5E6BBDE01}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BankYouBankruptClientApp", "BankYouBankruptClientApp\BankYouBankruptClientApp.csproj", "{8AD664D9-240B-41CD-9AB6-B56C64AC4291}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BankYouBankruptClientApp", "BankYouBankruptClientApp\BankYouBankruptClientApp.csproj", "{8AD664D9-240B-41CD-9AB6-B56C64AC4291}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -9,10 +9,18 @@ namespace BankYouBankruptCashierApp
{
private static readonly HttpClient _client = new();
//поле, хранящее кассира, которого необходимо авторизовать
//Вью-модели, необходимые для дальнейшего генерирования запросов к апишке
public static CashierViewModel? Cashier { get; set; } = null;
public static void Connect(IConfiguration configuration)
public static CreditingViewModel? Crediting { get; set; } = null;
public static DebitingViewModel? Debiting { get; set; } = null;
public static AccountViewModel? Account { get; set; } = null;
public static CardViewModel? Card { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();

View File

@ -258,5 +258,44 @@ namespace BankYouBankruptCashierApp.Controllers
return View(APICashier.GetRequest<List<DebitingViewModel>>($"/api/Account/FindOpenDebiting"));
}
//открытие формы отчёта. Получаем и передаём список изделий во вьюху?
[HttpGet]
public IActionResult CloseCrediting()
{
ViewBag.Creditings = APICashier.GetRequest<List<CreditingViewModel>>("/api/Account/FindOpenCrediting");
return View();
}
//создание отчёта Post-запросом
[HttpPost]
public void CloseCrediting(int creditingId)
{
if (APICashier.Cashier == null)
{
throw new Exception("Вы как сюда попали? Суда вход только авторизованным");
}
if(creditingId < 0)
{
throw new Exception("Некорректный номер заявки на зачисление");
}
//получаем необходимые данные для запроса
APICashier.Crediting = APICashier.GetRequest<CreditingViewModel>($"/api/Account/FindCrediting?id={creditingId}");
APICashier.Card = APICashier.GetRequest<CardViewModel>($"/api/Card/FindCard?id={APICashier.Crediting.CardId}");
APICashier.PostRequest("/api/Account/CloseCrediting", new MoneyTransferBindingModel
{
CashierId = APICashier.Cashier.Id,
CreditingId = creditingId,
Sum = APICashier.Crediting.Sum,
AccountPayeeId = APICashier.Card.AccountId
});
Response.Redirect("Crediting");
}
}
}

View File

@ -0,0 +1,21 @@
@{
ViewData["Title"] = "Одобрение зачислений";
}
<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="creditig" name="creditingId" class="form-control" asp-items="@(new SelectList( @ViewBag.Creditings, "Id", "Id"))"></select>
</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>

View File

@ -0,0 +1,5 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}

View File

@ -18,7 +18,7 @@
return;
}
<p>
<a asp-action="Create">Одобрение заявки</a>
<a asp-action="CloseCrediting">Одобрение заявки</a>
</p>
<table class="table">
<thead>

View File

@ -222,5 +222,22 @@ namespace BankYouBankruptRestApi.Controllers
throw;
}
}
[HttpGet]
public CreditingViewModel FindCrediting(int id)
{
try
{
return _creditingLogic.ReadElement(new CreditingSearchModel
{
Id = id
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
}
}

View File

@ -82,5 +82,22 @@ namespace BankYouBankruptRestApi.Controllers
Response.StatusCode = (int)HttpStatusCode.NotAcceptable;
}
}
}
[HttpGet]
public CardViewModel FindCard(int id)
{
try
{
return _cardLogic.ReadElement(new CardSearchModel
{
Id = id
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
}
}