Compare commits

..

No commits in common. "504469416d04b75b244c36b9527ccfe4cc432158" and "080aeb4058003f2c2746e4e251303cb6797c130b" have entirely different histories.

13 changed files with 24 additions and 26 deletions

View File

@ -22,10 +22,10 @@ namespace BankBusinessLogic.BusinessLogic
_operationStorage = operationStorage;
}
public List<OperationViewModel>? ReadList(OperationSearchModel? model)
public List<OperationViewModel>? ReadList(OperationSearchModel? model, int? clientId)
{
_logger.LogInformation("ReadList. Id: {Id}", model?.Id);
var list = model == null ? _operationStorage.GetFullList() : _operationStorage.GetFilteredList(model);
var list = model == null ? _operationStorage.GetFullList(clientId) : _operationStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");

View File

@ -74,8 +74,8 @@ namespace BankBusinessLogic.OfficePackage
"Номер перевода",
"Сумма",
"Время перевода",
"Счет отправителя",
"Счет получателя",
"Карта отправителя",
"Карта получателя"
},
Columns = 6,
RowText = table

View File

@ -248,9 +248,7 @@ 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();
}
@ -281,8 +279,7 @@ namespace BankClientApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Operations = APIClient.GetRequest<List<OperationViewModel>>($"api/operation/getoperationlist?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}");
ViewBag.Cards = APIClient.GetRequest<List<CardViewModel>>($"api/card/getcardlist?clientid={APIClient.Client.Id}");
return View();
}

View File

@ -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.SenderCards, "Id", "Number"))"></select>
<select id="sendercard" name="sendercard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "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.RecipientCards, "Id", "Number"))"></select>
<select id="recipientcard" name="recipientcard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "Id", "Number"))"></select>
</div>
</div>
<div class="row">

View File

@ -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.SenderCards, "Id", "Number"))"></select>
<select id="sendercard" name="sendercard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "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.RecipientCards, "Id", "Number"))"></select>
<select id="recipientcard" name="recipientcard" class="form-control" asp-items="@(new SelectList(@ViewBag.Cards, "Id", "Number"))"></select>
</div>
</div>
<div class="row">

View File

@ -11,7 +11,7 @@ namespace BankContracts.BusinessLogicsContracts
{
public interface IOperationLogic
{
List<OperationViewModel>? ReadList(OperationSearchModel? model);
List<OperationViewModel>? ReadList(OperationSearchModel? model, int? clientId);
OperationViewModel? ReadElement(OperationSearchModel model);
bool LinkOperationTransfer(int operationId, int transferId);
bool Create(OperationBindingModel model);

View File

@ -14,6 +14,5 @@ namespace BankContracts.SearchModels
public int? SenderCardId { get; set; }
public int? RecipientCardId { get; set; }
public int? CardId { get; set; }
public int? clientId { get; set; }
}
}

View File

@ -11,7 +11,7 @@ namespace BankContracts.StoragesContracts
{
public interface IOperationStorage
{
List<OperationViewModel> GetFullList();
List<OperationViewModel> GetFullList(int? clientId = null);
List<OperationViewModel> GetFilteredList(OperationSearchModel model);
OperationViewModel? GetElement(OperationSearchModel model);
OperationViewModel? Insert(OperationBindingModel model);

View File

@ -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 || x.Operation.SenderCardId == t.Id || x.Operation.RecipientCardId == t.Id) && (x.OperationId != null))
.Where(x => x.Operation == null || model.SelectedCardIds == null || model.SelectedCardIds.Contains((int)x.Operation.SenderCardId) || model.SelectedCardIds.Contains((int)x.Operation.RecipientCardId))
.Select(t => t.GetViewModel)
.ToList()
}).ToList();

View File

@ -14,9 +14,15 @@ namespace BankDatabaseImplement.Implements
{
public class OperationStorage : IOperationStorage
{
public List<OperationViewModel> GetFullList()
public List<OperationViewModel> GetFullList(int? clientId = null)
{
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();
}
@ -27,8 +33,7 @@ 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) &&
(x.SenderCard == null || x.SenderCard.ClientId == model.clientId)
(!model.DateTo.HasValue || x.OperationTime <= model.DateTo)
)).Select(x => x.GetViewModel).ToList();
}
public OperationViewModel? GetElement(OperationSearchModel model)

View File

@ -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">

View File

@ -20,7 +20,7 @@ namespace BankRestApi.Controllers
_logic = Card;
}
[HttpGet]
public List<CardViewModel>? GetCardList(int? clientId)
public List<CardViewModel>? GetCardList(int clientId)
{
try
{

View File

@ -23,10 +23,7 @@ namespace BankRestApi.Controllers
{
try
{
return _logic.ReadList(new OperationSearchModel
{
clientId = clientId
});
return _logic.ReadList(null, clientId);
}
catch (Exception ex)
{