finish Transfers region
This commit is contained in:
parent
879a6536bc
commit
24637ec066
@ -14,5 +14,6 @@ namespace BankContracts.SearchModels
|
||||
public int? OperationId { get; set; }
|
||||
public int? SenderAccountId { get; set; }
|
||||
public int? RecipientAccountId { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ namespace BankDatabaseImplement.Implements
|
||||
.Include(x => x.Operation)
|
||||
.Where(x =>
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
((x.SenderAccount != null && x.SenderAccount.ManagerId == model.ManagerId) ||
|
||||
(x.RecipientAccount != null && x.RecipientAccount.ManagerId == model.ManagerId)) &&
|
||||
(!model.SenderAccountId.HasValue || x.SenderAccountId == model.SenderAccountId) &&
|
||||
(!model.RecipientAccountId.HasValue || x.RecipientAccountId == model.RecipientAccountId) &&
|
||||
(!model.OperationId.HasValue || x.OperationId == model.OperationId) &&
|
||||
|
@ -203,44 +203,120 @@ namespace BankManagersClientApp.Controllers
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region//работа с переводами
|
||||
public IActionResult Transfers()
|
||||
#region//Transfers
|
||||
[HttpGet]
|
||||
public IActionResult Transfers()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
return View(APIClient.GetRequest<List<TransferViewModel>>($"api/transfer/gettransferlist?managerid={APIClient.Client.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult TransferCreate()
|
||||
[HttpGet]
|
||||
public IActionResult TransferCreate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
ViewBag.Accounts = APIClient.GetRequest<List<AccountViewModel>>($"api/account/getaccountlist?managerid={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void TransferCreate(int sum, int senderaccount, int recipientaccount)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (senderaccount == recipientaccount)
|
||||
throw new Exception("Зачем в отправителе и получателе один и тот же счёт указали??? Думаете нам в банке заняться нечем?");
|
||||
APIClient.PostRequest("api/transfer/createtransfer", new TransferBindingModel
|
||||
{
|
||||
Sum = sum,
|
||||
SenderAccountId = senderaccount,
|
||||
RecipientAccountId = recipientaccount,
|
||||
});
|
||||
Response.Redirect("Transfers");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult TransferUpdate()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Transfers = APIClient.GetRequest<List<TransferViewModel>>($"api/transfer/gettransferlist?managerid={APIClient.Client.Id}");
|
||||
ViewBag.Accounts = APIClient.GetRequest<List<AccountViewModel>>($"api/account/getaccountlist?managerid={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void TransferUpdate(int transfer, int sum, int senderaccount, int recipientaccount)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (senderaccount == recipientaccount)
|
||||
{
|
||||
throw new Exception("Зачем в отправителе и получателе один и тот же счёт указали??? Думаете нам в банке заняться нечем?");
|
||||
}
|
||||
APIClient.PostRequest("api/transfer/updatetransfer", new TransferBindingModel
|
||||
{
|
||||
Id = transfer,
|
||||
Sum = sum,
|
||||
SenderAccountId = senderaccount,
|
||||
RecipientAccountId = recipientaccount,
|
||||
});
|
||||
Response.Redirect("Transfers");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public TransferViewModel? GetTransfer(int transferId)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
var result = APIClient.GetRequest<TransferViewModel>($"api/transfer/gettransfer?transferid={transferId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult TransferDelete()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Transfers = APIClient.GetRequest<List<TransferViewModel>>($"api/transfer/gettransferlist?managerid={APIClient.Client.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void TransferDelete(int transfer)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/transfer/deletetransfer", new TransferBindingModel
|
||||
{
|
||||
Id = transfer,
|
||||
});
|
||||
Response.Redirect("Transfers");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region//работа с выдачами
|
||||
@ -308,10 +384,10 @@ namespace BankManagersClientApp.Controllers
|
||||
}
|
||||
return View();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region//ошибка
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
#region//Error
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
|
@ -14,14 +14,14 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Номер счета отправителя:</div>
|
||||
<div class="col-8">
|
||||
<select name="sender-number" id="sender-number" class="form-control"
|
||||
<select name="senderaccount" id="senderaccount" class="form-control"
|
||||
asp-items="@(new SelectList(@ViewBag.Accounts, "Id", "Number"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Номер счета получателя:</div>
|
||||
<div class="col-8">
|
||||
<select name="recipient-number" id="recipient-number" class="form-control"
|
||||
<select name="recipientaccount" id="recipientaccount" class="form-control"
|
||||
asp-items="@(new SelectList(@ViewBag.Accounts, "Id", "Number"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -8,7 +8,12 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Перевод:</div>
|
||||
<div class="col-8">
|
||||
<select id="transfer" name="transfer" class="form-control" asp-items="@(new SelectList(@ViewBag.Transfers, "Id", "Id"))"></select>
|
||||
<select id="transfer" name="transfer" class="form-control">
|
||||
@foreach (var transfer in ViewBag.Transfers)
|
||||
{
|
||||
<option value="@transfer.Id">@transfer.Id: @transfer.TransferTime, @transfer.SenderAccountNumber -> @transfer.RecipientAccountNumber, @transfer.Sum рублей</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -8,7 +8,12 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Перевод:</div>
|
||||
<div class="col-8">
|
||||
<select id="transfer" name="transfer" class="form-control" asp-items="@(new SelectList(@ViewBag.Transfers, "Id", "Id"))"></select>
|
||||
<select id="transfer" name="transfer" class="form-control">
|
||||
@foreach (var transfer in ViewBag.Transfers)
|
||||
{
|
||||
<option value="@transfer.Id">@transfer.Id: @transfer.TransferTime, @transfer.SenderAccountNumber -> @transfer.RecipientAccountNumber, @transfer.Sum рублей</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -20,17 +25,42 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Отправитель:</div>
|
||||
<div class="col-8">
|
||||
<select id="sender-account" name="sender-account" class="form-control" asp-items="@(new SelectList(@ViewBag.Accounts, "Id", "Number"))"></select>
|
||||
<select id="senderaccount" name="senderaccount" class="form-control" asp-items="@(new SelectList(@ViewBag.Accounts, "Id", "Number"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Получатель:</div>
|
||||
<div class="col-8">
|
||||
<select id="recipient-account" name="recipient-account" class="form-control" asp-items="@(new SelectList(@ViewBag.Accounts, "Id", "Number"))"></select>
|
||||
<select id="recipientaccount" name="recipientaccount" class="form-control" asp-items="@(new SelectList(@ViewBag.Accounts, "Id", "Number"))"></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>
|
||||
</form>
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
<script>
|
||||
function check() {
|
||||
var transfer = $('#transfer').val();
|
||||
if (transfer) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetTransfer",
|
||||
data: { transferId: transfer },
|
||||
success: function (result) {
|
||||
$('#sum').val(result.sum);
|
||||
$('#senderaccount').val(result.senderAccountId);
|
||||
$('#recipientaccount').val(result.recipientAccountId);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#transfer').on('change', function () {
|
||||
check();
|
||||
});
|
||||
</script>
|
||||
}
|
@ -20,11 +20,14 @@ namespace BankRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<TransferViewModel>? getTransferList()
|
||||
public List<TransferViewModel>? getTransferList(int managerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
return _logic.ReadList(new TransferSearchModel
|
||||
{
|
||||
ManagerId = managerId,
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user