diff --git a/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs index 9e51658..b76ddd6 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) + public List? 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"); diff --git a/Bank/BankClientApp/Controllers/HomeController.cs b/Bank/BankClientApp/Controllers/HomeController.cs index e59fb67..0be97d2 100644 --- a/Bank/BankClientApp/Controllers/HomeController.cs +++ b/Bank/BankClientApp/Controllers/HomeController.cs @@ -228,10 +228,31 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Cards = new List(); + List? list = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); + ViewBag.Cards = list; + return View(); } + [HttpPost] + public void OperationCreate(int sum, int? sendercard, int recipientcard) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (sendercard == recipientcard) + throw new Exception("Зачем в отправителе и получателе одну и ту же карту указали??? Думаете нам в банке заняться нечем?"); + APIClient.PostRequest("api/operation/createoperation", new + OperationBindingModel + { + Sum = sum, + SenderCardId = sendercard, + RecipientCardId = recipientcard, + }); + Response.Redirect("Operation"); + } + [HttpGet] public IActionResult OperationUpdate() { @@ -239,11 +260,48 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Operations = new List(); - ViewBag.Cards = new List(); + ViewBag.Operations = APIClient.GetRequest>($"api/operation/getoperationlist?clientid={APIClient.Client.Id}"); + ViewBag.Cards = APIClient.GetRequest>($"api/card/getcardlist?clientid={APIClient.Client.Id}"); return View(); } + [HttpPost] + public void OperationUpdate(int operation, int sum, int? sendercard, int recipientcard) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (sendercard == recipientcard) + { + throw new Exception("Зачем в отправителе и получателе одну и ту же карту указали??? Думаете нам в банке заняться нечем?"); + } + APIClient.PostRequest("api/operation/updateoperation", new + OperationBindingModel + { + Id = operation, + Sum = sum, + SenderCardId = sendercard, + RecipientCardId = recipientcard, + }); + Response.Redirect("Operation"); + } + + [HttpGet] + public OperationViewModel? GetOperation(int operationId) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + var result = APIClient.GetRequest($"api/operation/getoperation?operationid={operationId}"); + if (result == null) + { + return default; + } + return result; + } + [HttpGet] public IActionResult OperationDelete() { @@ -251,10 +309,25 @@ namespace BankClientApp.Controllers { return Redirect("~/Home/Enter"); } - ViewBag.Operations = new List(); + ViewBag.Operations = APIClient.GetRequest>($"api/operation/getoperationlist?clientid={APIClient.Client.Id}"); return View(); } + [HttpPost] + public void OperationDelete(int operation) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest("api/operation/deleteoperation", new + OperationBindingModel + { + Id = operation, + }); + Response.Redirect("Operation"); + } + [HttpGet] public IActionResult OperationTransfer() { @@ -264,6 +337,12 @@ namespace BankClientApp.Controllers } return View(); } + + [HttpPost] + public void OperationTransfer(int operation, int transfer) + { + + } #endregion #region//работа с заявками diff --git a/Bank/BankClientApp/Views/Home/Operation.cshtml b/Bank/BankClientApp/Views/Home/Operation.cshtml index 4191ff1..0312f69 100644 --- a/Bank/BankClientApp/Views/Home/Operation.cshtml +++ b/Bank/BankClientApp/Views/Home/Operation.cshtml @@ -36,6 +36,9 @@ Получатель + + Номер перевода + @@ -62,6 +65,10 @@ @Html.DisplayFor(modelItem => item.RecipientCardNumber) + + @Html.DisplayFor(modelItem => + item.TransferId) + } diff --git a/Bank/BankClientApp/Views/Home/OperationCreate.cshtml b/Bank/BankClientApp/Views/Home/OperationCreate.cshtml index f76e07c..34bae3c 100644 --- a/Bank/BankClientApp/Views/Home/OperationCreate.cshtml +++ b/Bank/BankClientApp/Views/Home/OperationCreate.cshtml @@ -8,7 +8,7 @@
Сумма:
- +
diff --git a/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml b/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml index c99667b..c87241c 100644 --- a/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml +++ b/Bank/BankClientApp/Views/Home/OperationUpdate.cshtml @@ -9,7 +9,7 @@
Операция:
- +
@@ -34,4 +34,29 @@
- \ No newline at end of file + + +@section Scripts + { + +} \ No newline at end of file diff --git a/Bank/BankContracts/BusinessLogicsContracts/IOperationLogic.cs b/Bank/BankContracts/BusinessLogicsContracts/IOperationLogic.cs index f46604e..7762b0f 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); + List? ReadList(OperationSearchModel? model, int? clientId); OperationViewModel? ReadElement(OperationSearchModel model); bool Create(OperationBindingModel model); bool Update(OperationBindingModel model); diff --git a/Bank/BankContracts/StoragesContracts/IOperationStorage.cs b/Bank/BankContracts/StoragesContracts/IOperationStorage.cs index cd47eec..7f705e5 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(); + List GetFullList(int? clientId = null); List GetFilteredList(OperationSearchModel model); OperationViewModel? GetElement(OperationSearchModel model); OperationViewModel? Insert(OperationBindingModel model); diff --git a/Bank/BankContracts/ViewModels/OperationViewModel.cs b/Bank/BankContracts/ViewModels/OperationViewModel.cs index 0658d95..e719561 100644 --- a/Bank/BankContracts/ViewModels/OperationViewModel.cs +++ b/Bank/BankContracts/ViewModels/OperationViewModel.cs @@ -22,5 +22,6 @@ namespace BankContracts.ViewModels public int RecipientCardId { get; set; } [DisplayName("Номер карты получателя")] public string RecipientCardNumber { get; set; } = string.Empty; + public int? TransferId { get; set; } } } diff --git a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs index 9273b47..a269f03 100644 --- a/Bank/BankDatabaseImplement/Implements/OperationStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/OperationStorage.cs @@ -14,11 +14,17 @@ namespace BankDatabaseImplement.Implements { public class OperationStorage : IOperationStorage { - public List GetFullList() + public List GetFullList(int? clientId = null) { using var context = new BankDatabase(); + if (clientId != null) { + return context.Operations.Include(x => x.SenderCard).Include(x => x.RecipientCard) + //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(); + .Select(x => x.GetViewModel).ToList(); } public List GetFilteredList(OperationSearchModel model) { diff --git a/Bank/BankDatabaseImplement/Models/Operation.cs b/Bank/BankDatabaseImplement/Models/Operation.cs index d446926..99cb305 100644 --- a/Bank/BankDatabaseImplement/Models/Operation.cs +++ b/Bank/BankDatabaseImplement/Models/Operation.cs @@ -44,7 +44,6 @@ namespace BankDatabaseImplement.Models { if (model == null) return; Sum = model.Sum; - OperationTime = model.OperationTime; SenderCardId = model.SenderCardId; RecipientCardId = model.RecipientCardId; } diff --git a/Bank/BankDatabaseImplement/Models/Request.cs b/Bank/BankDatabaseImplement/Models/Request.cs index 757b414..b631568 100644 --- a/Bank/BankDatabaseImplement/Models/Request.cs +++ b/Bank/BankDatabaseImplement/Models/Request.cs @@ -55,7 +55,6 @@ namespace BankDatabaseImplement.Models public void Update(RequestBindingModel model) { Sum = model.Sum; - RequestTime = model.RequestTime; Status = model.Status; } diff --git a/Bank/BankRestApi/Controllers/OperationController.cs b/Bank/BankRestApi/Controllers/OperationController.cs index cacfcbe..955a867 100644 --- a/Bank/BankRestApi/Controllers/OperationController.cs +++ b/Bank/BankRestApi/Controllers/OperationController.cs @@ -19,11 +19,11 @@ namespace BankRestApi.Controllers _logic = Operation; } [HttpGet] - public List? GetOperationList() + public List? GetOperationList(int clientId) { try { - return _logic.ReadList(null); + return _logic.ReadList(null, clientId); } catch (Exception ex) {