diff --git a/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs index 21af877..46130f6 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs @@ -22,10 +22,10 @@ namespace BankBusinessLogic.BusinessLogic _operationStorage = operationStorage; } - public List? ReadList(OperationSearchModel? model, int? clientId) + public List? 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"); diff --git a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 214744b..9995a25 100644 --- a/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Bank/BankBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -74,8 +74,8 @@ namespace BankBusinessLogic.OfficePackage "Номер перевода", "Сумма", "Время перевода", - "Карта отправителя", - "Карта получателя" + "Счет отправителя", + "Счет получателя", }, Columns = 6, RowText = table diff --git a/Bank/BankClientApp/Controllers/HomeController.cs b/Bank/BankClientApp/Controllers/HomeController.cs index 3e8fc3a..bc77f42 100644 --- a/Bank/BankClientApp/Controllers/HomeController.cs +++ b/Bank/BankClientApp/Controllers/HomeController.cs @@ -248,7 +248,9 @@ namespace BankClientApp.Controllers } List? list = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); ViewBag.Cards = list; - + ViewBag.SenderCards = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); + ViewBag.RecipientCards = APIClient.GetRequest>($"api/card/getcardlist?clientid={null}"); + return View(); } @@ -279,7 +281,8 @@ namespace BankClientApp.Controllers return Redirect("~/Home/Enter"); } ViewBag.Operations = APIClient.GetRequest>($"api/operation/getoperationlist?clientid={APIClient.Client.Id}"); - ViewBag.Cards = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); + ViewBag.SenderCards = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); + ViewBag.RecipientCards = APIClient.GetRequest>($"api/card/getcardlist?clientid={null}"); return View(); } diff --git a/Bank/BankClientApp/Views/Home/OperationCreate.cshtml b/Bank/BankClientApp/Views/Home/OperationCreate.cshtml index 34bae3c..07315a6 100644 --- a/Bank/BankClientApp/Views/Home/OperationCreate.cshtml +++ b/Bank/BankClientApp/Views/Home/OperationCreate.cshtml @@ -14,13 +14,13 @@
Отправитель:
- +
Получатель:
- +
diff --git a/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml b/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml index e7d452d..e37ec10 100644 --- a/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml +++ b/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml @@ -21,13 +21,13 @@
Отправитель:
- +
Получатель:
- +
diff --git a/Bank/BankContracts/BusinessLogicsContracts/IOperationLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IOperationLogic.cs index d357a4a..acb98d8 100644 --- a/Bank/BankContracts/BusinessLogicsContracts/IOperationLogic.cs +++ b/Bank/BankContracts/BusinessLogicsContracts/IOperationLogic.cs @@ -11,7 +11,7 @@ namespace BankContracts.BusinessLogicsContracts { public interface IOperationLogic { - List? ReadList(OperationSearchModel? model, int? clientId); + List? ReadList(OperationSearchModel? model); OperationViewModel? ReadElement(OperationSearchModel model); bool LinkOperationTransfer(int operationId, int transferId); bool Create(OperationBindingModel model); diff --git a/Bank/BankContracts/SearchModels/OperationSearchModel.cs b/Bank/BankContracts/SearchModels/OperationSearchModel.cs index 8f45f47..b50b56a 100644 --- a/Bank/BankContracts/SearchModels/OperationSearchModel.cs +++ b/Bank/BankContracts/SearchModels/OperationSearchModel.cs @@ -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; } } } diff --git a/Bank/BankContracts/StoragesContracts/IOperationStorage.cs b/Bank/BankContracts/StoragesContracts/IOperationStorage.cs index 8420195..1772c3e 100644 --- a/Bank/BankContracts/StoragesContracts/IOperationStorage.cs +++ b/Bank/BankContracts/StoragesContracts/IOperationStorage.cs @@ -11,7 +11,7 @@ namespace BankContracts.StoragesContracts { public interface IOperationStorage { - List GetFullList(int? clientId = null); + List GetFullList(); List GetFilteredList(OperationSearchModel model); OperationViewModel? GetElement(OperationSearchModel model); OperationViewModel? Insert(OperationBindingModel model); diff --git a/Bank/BankDatabaseImplement/Implements/CardStorage.cs b/Bank/BankDatabaseImplement/Implements/CardStorage.cs index 1f5770a..ba740b4 100644 --- a/Bank/BankDatabaseImplement/Implements/CardStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CardStorage.cs @@ -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(); diff --git a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs index ad611fc..07e5085 100644 --- a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs @@ -14,15 +14,9 @@ namespace BankDatabaseImplement.Implements { public class OperationStorage : IOperationStorage { - public List GetFullList(int? clientId = null) + public List 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) diff --git a/Bank/BankManagersClientApp/Views/Home/TransferCreate.cshtml b/Bank/BankManagersClientApp/Views/Home/TransferCreate.cshtml index 78ea932..fe43531 100644 --- a/Bank/BankManagersClientApp/Views/Home/TransferCreate.cshtml +++ b/Bank/BankManagersClientApp/Views/Home/TransferCreate.cshtml @@ -2,7 +2,7 @@ ViewData["Title"] = "TransferCreate"; }
-

Создание счёта

+

Создание перевода

diff --git a/Bank/BankRestApi/Controllers/CardController.cs b/Bank/BankRestApi/Controllers/CardController.cs index abdf994..8a0a861 100644 --- a/Bank/BankRestApi/Controllers/CardController.cs +++ b/Bank/BankRestApi/Controllers/CardController.cs @@ -20,7 +20,7 @@ namespace BankRestApi.Controllers _logic = Card; } [HttpGet] - public List? GetCardList(int clientId) + public List? GetCardList(int? clientId) { try { diff --git a/Bank/BankRestApi/Controllers/OperationController.cs b/Bank/BankRestApi/Controllers/OperationController.cs index 6bf8fc7..4da20d5 100644 --- a/Bank/BankRestApi/Controllers/OperationController.cs +++ b/Bank/BankRestApi/Controllers/OperationController.cs @@ -23,7 +23,10 @@ namespace BankRestApi.Controllers { try { - return _logic.ReadList(null, clientId); + return _logic.ReadList(new OperationSearchModel + { + clientId = clientId + }); } catch (Exception ex) {