diff --git a/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs index 8420f5b..2103530 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/AccountLogic.cs @@ -16,7 +16,7 @@ namespace BankBusinessLogic.BusinessLogic { private readonly ILogger _logger; private readonly IAccountStorage _accountStorage; - public AccountLogic(ILogger logger, IAccountStorage accountStorage) + public AccountLogic(ILogger logger, IAccountStorage accountStorage) { _logger = logger; _accountStorage = accountStorage; diff --git a/Bank/BankBusinessLogic/BusinessLogic/ManagerLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/ManagerLogic.cs index 20b63a4..881abba 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/ManagerLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/ManagerLogic.cs @@ -17,7 +17,7 @@ namespace BankBusinessLogic.BusinessLogic private readonly ILogger _logger; private readonly IManagerStorage _managerStorage; - public ManagerLogic(ILogger logger, IManagerStorage managerStorage) + public ManagerLogic(ILogger logger, IManagerStorage managerStorage) { _logger = logger; _managerStorage = managerStorage; diff --git a/Bank/BankBusinessLogic/BusinessLogic/TransferLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/TransferLogic.cs index eece54e..f88ee9b 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/TransferLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/TransferLogic.cs @@ -16,7 +16,7 @@ namespace BankBusinessLogic.BusinessLogic { private readonly ILogger _logger; private readonly ITransferStorage _transferStorage; - public TransferLogic(ILogger logger, ITransferStorage transferStorage) + public TransferLogic(ILogger logger, ITransferStorage transferStorage) { _logger = logger; _transferStorage = transferStorage; diff --git a/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs index 4240ed3..619a1e0 100644 --- a/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs +++ b/Bank/BankBusinessLogic/BusinessLogic/WithdrawalLogic.cs @@ -17,7 +17,7 @@ namespace BankBusinessLogic.BusinessLogic { private readonly ILogger _logger; private readonly IWithdrawalStorage _withdrawalStorage; - public WithdrawalLogic(ILogger logger, IWithdrawalStorage withdrawalStorage) + public WithdrawalLogic(ILogger logger, IWithdrawalStorage withdrawalStorage) { _logger = logger; _withdrawalStorage = withdrawalStorage; diff --git a/Bank/BankRestApi/Controllers/CardController.cs b/Bank/BankRestApi/Controllers/CardController.cs new file mode 100644 index 0000000..fc644e1 --- /dev/null +++ b/Bank/BankRestApi/Controllers/CardController.cs @@ -0,0 +1,94 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace BankRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class CardController + { + private readonly ILogger _logger; + private readonly ICardLogic _logic; + + public CardController(ILogger logger, ICardLogic Card) + { + _logger = logger; + _logic = Card; + } + [HttpGet] + public List? GetCardList() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка менеджеров"); + throw; + } + } + + [HttpGet] + public CardViewModel? GetCard(int CardId) + { + try + { + return _logic.ReadElement(new CardSearchModel + { + Id = CardId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения менеджера по Id={Id}", CardId); + throw; + } + } + + [HttpPost] + public void CreateCard(CardBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания менеджера"); + throw; + } + } + + [HttpPut] + public void UpdateCard(CardBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления менеджера"); + throw; + } + } + + [HttpDelete] + public void DeleteCard(CardBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления менеджера"); + throw; + } + } + } +} diff --git a/Bank/BankRestApi/Controllers/ClientController.cs b/Bank/BankRestApi/Controllers/ClientController.cs new file mode 100644 index 0000000..83962a5 --- /dev/null +++ b/Bank/BankRestApi/Controllers/ClientController.cs @@ -0,0 +1,112 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace BankRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class ClientController : Controller + { + private readonly ILogger _logger; + private readonly IClientLogic _logic; + + public ClientController(ILogger logger, IClientLogic client) + { + _logger = logger; + _logic = client; + } + [HttpGet] + public List? GetClientList() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка клиентов"); + throw; + } + } + + [HttpGet] + public ClientViewModel? GetClient(int ClientId) + { + try + { + return _logic.ReadElement(new ClientSearchModel + { + Id = ClientId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения клиетна по Id={Id}", ClientId); + throw; + } + } + + [HttpGet] + public ClientViewModel? Login(string login, string password) + { + try + { + return _logic.ReadElement(new ClientSearchModel + { + Email = login, + Password = password + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка входа в систему"); + throw; + } + } + + [HttpPost] + public void Register(ClientBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания менеджера"); + throw; + } + } + + [HttpPut] + public void UpdateClient(ClientBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления менеджера"); + throw; + } + } + + [HttpDelete] + public void DeleteClient(ClientBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления менеджера"); + throw; + } + } + } +} diff --git a/Bank/BankRestApi/Controllers/MainController.cs b/Bank/BankRestApi/Controllers/MainController.cs deleted file mode 100644 index 1dfdd5d..0000000 --- a/Bank/BankRestApi/Controllers/MainController.cs +++ /dev/null @@ -1,306 +0,0 @@ -using BankContracts.BindingModels; -using BankContracts.BusinessLogicsContracts; -using BankContracts.SearchModels; -using BankContracts.ViewModels; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore.ChangeTracking; -using System.Diagnostics.Contracts; - -namespace BankRestApi.Controllers -{ - [Route("api/[controller]/[action]")] - [ApiController] - public class MainController : Controller - { - private readonly ILogger _logger; - private readonly IClientLogic _client; - private readonly ICardLogic _card; - private readonly IOperationLogic _operation; - private readonly IRequestLogic _request; - - public MainController(ILogger logger, IClientLogic client, ICardLogic card, IOperationLogic operation, IRequestLogic request) - { - _logger = logger; - _client = client; - _card = card; - _operation = operation; - _request = request; - } - - [HttpGet] - public List? GetClientList() - { - try - { - return _client.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка клиентов"); - throw; - } - } - [HttpGet] - public ClientViewModel? GetClient(int ClientId) - { - try - { - return _client.ReadElement(new ClientSearchModel - { - Id = ClientId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения клиента по Id={Id}", ClientId); - throw; - } - } - [HttpGet] - public List? GetCardList() - { - try - { - return _card.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка карт"); - throw; - } - } - [HttpGet] - public CardViewModel? GetCard(int CardId) - { - try - { - return _card.ReadElement(new CardSearchModel - { - Id = CardId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения карты по Id={Id}", CardId); - throw; - } - } - [HttpGet] - public List? getOperationList() - { - try - { - return _operation.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка операций"); - throw; - } - } - [HttpGet] - public OperationViewModel? GetOperation(int OperationId) - { - try - { - return _operation.ReadElement(new OperationSearchModel - { - Id = OperationId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения операции по Id={Id}", OperationId); - throw; - } - } - [HttpGet] - public List? GetRequestList() - { - try - { - return _request.ReadList(null); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения списка запросов"); - throw; - } - } - [HttpGet] - public RequestViewModel? GetRequest(int RequestId) - { - try - { - return _request.ReadElement(new RequestSearchModel - { - Id = RequestId - }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения запроса по Id={Id}", RequestId); - throw; - } - } - - [HttpPost] - public void CreateClient(ClientBindingModel model) - { - try - { - _client.Create(model); - } - catch(Exception ex) - { - _logger.LogError(ex, "Ошибка создания клиента"); - throw; - } - } - [HttpPost] - public void CreateCard(CardBindingModel model) - { - try - { - _card.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания карты"); - throw; - } - } - [HttpPost] - public void CreateOperation(OperationBindingModel model) - { - try - { - _operation.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания операции"); - throw; - } - } - [HttpPost] - public void CreateRequest(RequestBindingModel model) - { - try - { - _request.Create(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка создания запроса"); - throw; - } - } - - [HttpPut] - public void UpdateClient(ClientBindingModel model) - { - try - { - _client.Update(model); - } - catch(Exception ex) - { - _logger.LogError(ex, "Ошибка обновления клиента"); - throw; - } - } - [HttpPut] - public void UpdateCard(CardBindingModel model) - { - try - { - _card.Update(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка обновления карты"); - throw; - } - } - [HttpPut] - public void UpdateOperation(OperationBindingModel model) - { - try - { - _operation.Update(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка обновления операции"); - throw; - } - } - [HttpPut] - public void UpdateRequest(RequestBindingModel model) - { - try - { - _request.Update(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка обновления запроса"); - throw; - } - } - - [HttpDelete] - public void DeleteClient(ClientBindingModel model) - { - try - { - _client.Delete(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления клиента"); - throw; - } - } - [HttpDelete] - public void DeleteCard(CardBindingModel model) - { - try - { - _card.Delete(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления карты"); - throw; - } - } - [HttpDelete] - public void DeleteOperation(OperationBindingModel model) - { - try - { - _operation.Delete(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления операции"); - throw; - } - } - [HttpDelete] - public void DeleteRequest(RequestBindingModel model) - { - try - { - _request.Delete(model); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка удаления запроса"); - throw; - } - } - } -} diff --git a/Bank/BankRestApi/Controllers/OperationController.cs b/Bank/BankRestApi/Controllers/OperationController.cs new file mode 100644 index 0000000..e665db9 --- /dev/null +++ b/Bank/BankRestApi/Controllers/OperationController.cs @@ -0,0 +1,94 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace BankRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class OperationController + { + private readonly ILogger _logger; + private readonly IOperationLogic _logic; + + public OperationController(ILogger logger, IOperationLogic Operation) + { + _logger = logger; + _logic = Operation; + } + [HttpGet] + public List? GetOperationList() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка менеджеров"); + throw; + } + } + + [HttpGet] + public OperationViewModel? GetOperation(int OperationId) + { + try + { + return _logic.ReadElement(new OperationSearchModel + { + Id = OperationId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения менеджера по Id={Id}", OperationId); + throw; + } + } + + [HttpPost] + public void CreateOperation(OperationBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания менеджера"); + throw; + } + } + + [HttpPut] + public void UpdateOperation(OperationBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления менеджера"); + throw; + } + } + + [HttpDelete] + public void DeleteOperation(OperationBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления менеджера"); + throw; + } + } + } +} diff --git a/Bank/BankRestApi/Controllers/RequestController.cs b/Bank/BankRestApi/Controllers/RequestController.cs new file mode 100644 index 0000000..62689e6 --- /dev/null +++ b/Bank/BankRestApi/Controllers/RequestController.cs @@ -0,0 +1,94 @@ +using BankContracts.BindingModels; +using BankContracts.BusinessLogicsContracts; +using BankContracts.SearchModels; +using BankContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; + +namespace BankRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class RequestController + { + private readonly ILogger _logger; + private readonly IRequestLogic _logic; + + public RequestController(ILogger logger, IRequestLogic Request) + { + _logger = logger; + _logic = Request; + } + [HttpGet] + public List? GetRequestList() + { + try + { + return _logic.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка менеджеров"); + throw; + } + } + + [HttpGet] + public RequestViewModel? GetRequest(int RequestId) + { + try + { + return _logic.ReadElement(new RequestSearchModel + { + Id = RequestId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения менеджера по Id={Id}", RequestId); + throw; + } + } + + [HttpPost] + public void CreateRequest(RequestBindingModel model) + { + try + { + _logic.Create(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания менеджера"); + throw; + } + } + + [HttpPut] + public void UpdateRequest(RequestBindingModel model) + { + try + { + _logic.Update(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка обновления менеджера"); + throw; + } + } + + [HttpDelete] + public void DeleteRequest(RequestBindingModel model) + { + try + { + _logic.Delete(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления менеджера"); + throw; + } + } + } +}