This commit is contained in:
Zakharov_Rostislav 2024-05-26 13:45:54 +04:00
commit 717d6e9e25
5 changed files with 31 additions and 10 deletions

View File

@ -353,7 +353,7 @@ namespace BankClientApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Operations = APIClient.GetRequest<List<OperationViewModel>>($"api/operation/getoperationlist?clientid={APIClient.Client.Id}");
ViewBag.Transfers = APIClient.GetRequest<List<TransferViewModel>>($"api/transfer/gettransferlist");
ViewBag.Transfers = APIClient.GetRequest<List<TransferViewModel>>($"api/transfer/getfulltransferlist");
return View();
}
@ -427,7 +427,7 @@ namespace BankClientApp.Controllers
}
[HttpPost]
public void RequestUpdate(int sum, List<int> cards)
public void RequestUpdate(int request, int sum, List<int> cards)
{
if (APIClient.Client == null)
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
@ -438,6 +438,7 @@ namespace BankClientApp.Controllers
}
APIClient.PostRequest("/api/request/updaterequest", new RequestBindingModel
{
Id = request,
Sum = sum,
CardRequests = a,
Status = RequestStatus.Неизвестен
@ -471,6 +472,21 @@ namespace BankClientApp.Controllers
Response.Redirect("Request");
}
[HttpGet]
public RequestViewModel? GetRequest(int requestId)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
var result = APIClient.GetRequest<RequestViewModel>($"api/request/getrequest?requestid={requestId}");
if (result == null)
{
return default;
}
return result;
}
#endregion
#region//работа с отчетами

View File

@ -55,7 +55,7 @@
};
}
check();
$('#card').on('change', function () {
$('#operation').on('change', function () {
check();
});
</script>

View File

@ -40,23 +40,26 @@
{
<script>
function check() {
var cards = $('#cards').val();
var request = $('#request').val();
$("#cards option:selected").removeAttr("selected");
if (cards && request) {
if (request) {
$.ajax({
method: "GET",
url: "/Home/GetCards",
data: { requestId: request },
success: function (result) {
$.map(result, function (n) {
$(`option[data-name=${n}]`).attr("selected", "selected")
$(`#cards option[value=${n}]`).attr("selected", "selected")
});
}
});
$.ajax({
method: "GET",
url: "/Home/GetRequest",
data: {requestId: request},
success: function (result) {
$('#sum').val(result.sum)
}
});
};
}

View File

@ -48,7 +48,7 @@ namespace BankDatabaseImplement.Implements
{
if (!model.Id.HasValue) return null;
using var context = new BankDatabase();
return context.Requests.Include(x => x.Cards).ThenInclude(x => x.Card)
return context.Requests.Include(x => x.Cards).ThenInclude(x => x.Card).ToList()
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
}
public RequestViewModel? Insert(RequestBindingModel model)

View File

@ -44,10 +44,12 @@ namespace BankRestApi.Controllers
{
try
{
return _logic.ReadElement(new RequestSearchModel
var tmp = _logic.ReadElement(new RequestSearchModel
{
Id = RequestId
});
tmp.CardRequests = null;
return tmp;
}
catch (Exception ex)
{