Compare commits
2 Commits
080aeb4058
...
504469416d
Author | SHA1 | Date | |
---|---|---|---|
504469416d | |||
b9eac65ed4 |
@ -22,10 +22,10 @@ namespace BankBusinessLogic.BusinessLogic
|
||||
_operationStorage = operationStorage;
|
||||
}
|
||||
|
||||
public List<OperationViewModel>? ReadList(OperationSearchModel? model, int? clientId)
|
||||
public List<OperationViewModel>? ReadList(OperationSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
|
||||
var list = model == null ? _operationStorage.GetFullList(clientId) : _operationStorage.GetFilteredList(model);
|
||||
var list = model == null ? _operationStorage.GetFullList() : _operationStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
@ -74,8 +74,8 @@ namespace BankBusinessLogic.OfficePackage
|
||||
"Номер перевода",
|
||||
"Сумма",
|
||||
"Время перевода",
|
||||
"Карта отправителя",
|
||||
"Карта получателя"
|
||||
"Счет отправителя",
|
||||
"Счет получателя",
|
||||
},
|
||||
Columns = 6,
|
||||
RowText = table
|
||||
|
@ -248,7 +248,9 @@ namespace BankClientApp.Controllers
|
||||
}
|
||||
List<CardViewModel>? list = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={APIClient.Client.Id}");
|
||||
ViewBag.Cards = list;
|
||||
|
||||
ViewBag.SenderCards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={APIClient.Client.Id}");
|
||||
ViewBag.RecipientCards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={null}");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -279,7 +281,8 @@ namespace BankClientApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Operations = APIClient.GetRequest<List<OperationViewModel>>($"api/operation/getoperationlist?clientid={APIClient.Client.Id}");
|
||||
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={APIClient.Client.Id}");
|
||||
ViewBag.SenderCards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={APIClient.Client.Id}");
|
||||
ViewBag.RecipientCards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={null}");
|
||||
return View();
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,13 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Отправитель:</div>
|
||||
<div class="col-8">
|
||||
<select id="sendercard" name="sendercard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "Id", "Number"))"></select>
|
||||
<select id="sendercard" name="sendercard" class="form-control" asp-items="@(new SelectList(@ViewBag.SenderCards, "Id", "Number"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Получатель:</div>
|
||||
<div class="col-8">
|
||||
<select id="recipientcard" name="recipientcard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "Id", "Number"))"></select>
|
||||
<select id="recipientcard" name="recipientcard" class="form-control" asp-items="@(new SelectList(@ViewBag.RecipientCards, "Id", "Number"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -21,13 +21,13 @@
|
||||
<div class="row">
|
||||
<div class="col-4">Отправитель:</div>
|
||||
<div class="col-8">
|
||||
<select id="sendercard" name="sendercard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "Id", "Number"))"></select>
|
||||
<select id="sendercard" name="sendercard" class="form-control" asp-items="@(new SelectList(@ViewBag.SenderCards, "Id", "Number"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Получатель:</div>
|
||||
<div class="col-8">
|
||||
<select id="recipientcard" name="recipientcard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "Id", "Number"))"></select>
|
||||
<select id="recipientcard" name="recipientcard" class="form-control" asp-items="@(new SelectList(@ViewBag.RecipientCards, "Id", "Number"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -11,7 +11,7 @@ namespace BankContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IOperationLogic
|
||||
{
|
||||
List<OperationViewModel>? ReadList(OperationSearchModel? model, int? clientId);
|
||||
List<OperationViewModel>? ReadList(OperationSearchModel? model);
|
||||
OperationViewModel? ReadElement(OperationSearchModel model);
|
||||
bool LinkOperationTransfer(int operationId, int transferId);
|
||||
bool Create(OperationBindingModel model);
|
||||
|
@ -14,5 +14,6 @@ namespace BankContracts.SearchModels
|
||||
public int? SenderCardId { get; set; }
|
||||
public int? RecipientCardId { get; set; }
|
||||
public int? CardId { get; set; }
|
||||
public int? clientId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace BankContracts.StoragesContracts
|
||||
{
|
||||
public interface IOperationStorage
|
||||
{
|
||||
List<OperationViewModel> GetFullList(int? clientId = null);
|
||||
List<OperationViewModel> GetFullList();
|
||||
List<OperationViewModel> GetFilteredList(OperationSearchModel model);
|
||||
OperationViewModel? GetElement(OperationSearchModel model);
|
||||
OperationViewModel? Insert(OperationBindingModel model);
|
||||
|
@ -52,7 +52,7 @@ namespace BankDatabaseImplement.Implements
|
||||
CardNumber = t.Number,
|
||||
Transfers = context.Transfers
|
||||
.Include(c => c.Operation).Include(c => c.RecipientAccount).Include(c => c.SenderAccount)
|
||||
.Where(x => x.Operation == null || model.SelectedCardIds == null || model.SelectedCardIds.Contains((int)x.Operation.SenderCardId) || model.SelectedCardIds.Contains((int)x.Operation.RecipientCardId))
|
||||
.Where(x => (x.Operation == null || x.Operation.SenderCardId == t.Id || x.Operation.RecipientCardId == t.Id) && (x.OperationId != null))
|
||||
.Select(t => t.GetViewModel)
|
||||
.ToList()
|
||||
}).ToList();
|
||||
|
@ -14,15 +14,9 @@ namespace BankDatabaseImplement.Implements
|
||||
{
|
||||
public class OperationStorage : IOperationStorage
|
||||
{
|
||||
public List<OperationViewModel> GetFullList(int? clientId = null)
|
||||
public List<OperationViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BankDatabase();
|
||||
if (clientId != null) {
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard).Include(x => x.Transfer)
|
||||
//todo узнать у ростислава по поводу фильтрации
|
||||
.Where(x => (x.SenderCard != null && x.SenderCard.ClientId == clientId) || (x.RecipientCard != null && x.RecipientCard.ClientId == clientId))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard)
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
@ -33,7 +27,8 @@ namespace BankDatabaseImplement.Implements
|
||||
.Where(x => (
|
||||
(!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateFrom.HasValue || x.OperationTime >= model.DateFrom ) &&
|
||||
(!model.DateTo.HasValue || x.OperationTime <= model.DateTo)
|
||||
(!model.DateTo.HasValue || x.OperationTime <= model.DateTo) &&
|
||||
(x.SenderCard == null || x.SenderCard.ClientId == model.clientId)
|
||||
)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
public OperationViewModel? GetElement(OperationSearchModel model)
|
||||
|
@ -2,7 +2,7 @@
|
||||
ViewData["Title"] = "TransferCreate";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание счёта</h2>
|
||||
<h2 class="display-4">Создание перевода</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
|
@ -20,7 +20,7 @@ namespace BankRestApi.Controllers
|
||||
_logic = Card;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<CardViewModel>? GetCardList(int clientId)
|
||||
public List<CardViewModel>? GetCardList(int? clientId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -23,7 +23,10 @@ namespace BankRestApi.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null, clientId);
|
||||
return _logic.ReadList(new OperationSearchModel
|
||||
{
|
||||
clientId = clientId
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user