diff --git a/Bank/BankBusinessLogic/BankBusinessLogic.csproj b/Bank/BankBusinessLogic/BankBusinessLogic.csproj
index ba96647..0112389 100644
--- a/Bank/BankBusinessLogic/BankBusinessLogic.csproj
+++ b/Bank/BankBusinessLogic/BankBusinessLogic.csproj
@@ -6,10 +6,6 @@
enable
-
-
-
-
diff --git a/Bank/BankBusinessLogic/BusinessLogic/CardLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/CardLogic.cs
new file mode 100644
index 0000000..ba1951f
--- /dev/null
+++ b/Bank/BankBusinessLogic/BusinessLogic/CardLogic.cs
@@ -0,0 +1,100 @@
+using BankContracts.BindingModels;
+using BankContracts.BusinessLogicsContracts;
+using BankContracts.SearchModels;
+using BankContracts.StoragesContracts;
+using BankContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankBusinessLogic.BusinessLogic
+{
+ public class CardLogic : ICardLogic
+ {
+ private readonly ILogger _logger;
+ private readonly ICardStorage _cardStorage;
+ public CardLogic(ILogger logger, ICardStorage cardStorage)
+ {
+ _logger = logger;
+ _cardStorage = cardStorage;
+ }
+
+ public List? ReadList(CardSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Number: {Number}, Id: {Id}", model?.Number, model?.Id);
+ var list = model == null ? _cardStorage.GetFullList() : _cardStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("readList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList Count: {Count}", list.Count);
+ return list;
+ }
+ public CardViewModel? ReadElement(CardSearchModel model)
+ {
+ if (model == null) throw new ArgumentNullException(nameof(model));
+ _logger.LogInformation("ReadElement Number: {Number}, Id: {Id}", model?.Number, model?.Id);
+ var element = _cardStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find Id:{ Id}", element.Id);
+ return element;
+ }
+ public bool Create(CardBindingModel model)
+ {
+ CheckModel(model);
+ if (_cardStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("Insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(CardBindingModel model)
+ {
+ CheckModel(model);
+ if (_cardStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(CardBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_cardStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(CardBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ throw new ArgumentNullException(nameof(model));
+ if (!withParams)
+ return;
+ if (string.IsNullOrEmpty(model.Number))
+ throw new ArgumentNullException("Нет номера карты", nameof(model.Number));
+ if (string.IsNullOrEmpty(model.Cvv))
+ throw new ArgumentNullException("Нет cvv карты", nameof(model.Cvv));
+ if (string.IsNullOrEmpty(model.Pin))
+ throw new ArgumentNullException("Нет pin карты", nameof(model.Pin));
+ _logger.LogInformation("Card. Number:{Number}." +
+ "Cvv:{ Cvv}. Pin:{ Pin}. Id: { Id} ", model.Number, model.Cvv, model.Pin, model.Id);
+ var element = _cardStorage.GetElement(new CardSearchModel { Number = model.Number });
+ if (element != null && element.Id == model.Id)
+ throw new InvalidOperationException("Карта с таким номером уже есть");
+ }
+ }
+}
diff --git a/Bank/BankBusinessLogic/BusinessLogic/ClientLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/ClientLogic.cs
new file mode 100644
index 0000000..4a1d194
--- /dev/null
+++ b/Bank/BankBusinessLogic/BusinessLogic/ClientLogic.cs
@@ -0,0 +1,101 @@
+using BankContracts.BindingModels;
+using BankContracts.BusinessLogicsContracts;
+using BankContracts.SearchModels;
+using BankContracts.StoragesContracts;
+using BankContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using PdfSharp.Drawing.BarCodes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankBusinessLogic.BusinessLogic
+{
+ public class ClientLogic : IClientLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IClientStorage _clientStorage;
+ public ClientLogic(ILogger logger, IClientStorage clientStorage)
+ {
+ _logger = logger;
+ _clientStorage = clientStorage;
+ }
+
+ public List? ReadList(ClientSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Fio:{ Fio}. Id: {Id}", model?.Fio, model?.Id);
+ var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList Count: {Count}", list.Count);
+ return list;
+ }
+ public ClientViewModel? ReadElement(ClientSearchModel model)
+ {
+ if (model == null) throw new ArgumentNullException(nameof(model));
+ _logger.LogInformation("ReadElement. Fio: {Fio}. Id: {Id}", model?.Fio, model?.Id);
+ var element = _clientStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
+ return element;
+ }
+ public bool Create(ClientBindingModel model)
+ {
+ CheckModel(model);
+ if (_clientStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(ClientBindingModel model)
+ {
+ CheckModel(model);
+ if (_clientStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(ClientBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_clientStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(ClientBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ throw new ArgumentNullException(nameof(model));
+ if (!withParams)
+ return;
+ if (string.IsNullOrEmpty(model.Fio))
+ throw new ArgumentNullException("Нет ФИО клиента", nameof(model.Fio));
+ if (string.IsNullOrEmpty(model.Email))
+ throw new ArgumentNullException("Нет email клиента", nameof(model.Email));
+ if (string.IsNullOrEmpty(model.Password))
+ throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password));
+ _logger.LogInformation("Client. ClientFIO:{ClientFIO}." +
+ "Email:{ Email}. Password:{ Password}. Id: { Id} ", model.Fio, model.Email, model.Password, model.Id);
+ var element = _clientStorage.GetElement(new ClientSearchModel { Email = model.Email });
+ if (element != null && element.Id == model.Id)
+ throw new InvalidOperationException("Клиент с таким логином уже есть");
+ }
+ }
+}
diff --git a/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs
new file mode 100644
index 0000000..22ed10e
--- /dev/null
+++ b/Bank/BankBusinessLogic/BusinessLogic/OperationLogic.cs
@@ -0,0 +1,92 @@
+using BankContracts.BindingModels;
+using BankContracts.BusinessLogicsContracts;
+using BankContracts.SearchModels;
+using BankContracts.StoragesContracts;
+using BankContracts.ViewModels;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankBusinessLogic.BusinessLogic
+{
+ public class OperationLogic : IOperationLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IOperationStorage _operationStorage;
+ public OperationLogic(ILogger logger, IOperationStorage operationStorage)
+ {
+ _logger = logger;
+ _operationStorage = operationStorage;
+ }
+
+ public List? ReadList(OperationSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Id: {Id}", model?.Id);
+ var list = model == null ? _operationStorage.GetFullList() : _operationStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList Count: {Count}", list.Count);
+ return list;
+ }
+ public OperationViewModel? ReadElement(OperationSearchModel model)
+ {
+ if (model == null) throw new ArgumentNullException(nameof(model));
+ _logger.LogInformation("ReadElement. Id: {Id}", model?.Id);
+ var element = _operationStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
+ return element;
+ }
+ public bool Create(OperationBindingModel model)
+ {
+ CheckModel(model);
+ if (_operationStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(OperationBindingModel model)
+ {
+ CheckModel(model);
+ if (_operationStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(OperationBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_operationStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+
+ private void CheckModel(OperationBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ throw new ArgumentNullException(nameof(model));
+ if (!withParams)
+ return;
+ if (model.Sum <= 0)
+ throw new ArgumentNullException("Неверная сумма", nameof(model.Sum));
+ _logger.LogInformation("Operation. Sum:{Sum}. Id: { Id} ", model.Sum, model.Id);
+ }
+ }
+}
diff --git a/Bank/BankBusinessLogic/BusinessLogic/RequestLogic.cs b/Bank/BankBusinessLogic/BusinessLogic/RequestLogic.cs
new file mode 100644
index 0000000..04585a1
--- /dev/null
+++ b/Bank/BankBusinessLogic/BusinessLogic/RequestLogic.cs
@@ -0,0 +1,111 @@
+using BankContracts.BindingModels;
+using BankContracts.BusinessLogicsContracts;
+using BankContracts.SearchModels;
+using BankContracts.StoragesContracts;
+using BankContracts.ViewModels;
+using BankDataModels.Models;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BankBusinessLogic.BusinessLogic
+{
+ public class RequestLogic : IRequestLogic
+ {
+ private readonly ILogger _logger;
+ private readonly IRequestStorage _requestStorage;
+ public RequestLogic(ILogger logger, IRequestStorage requestStorage)
+ {
+ _logger = logger;
+ _requestStorage = requestStorage;
+ }
+
+ public List? ReadList(RequestSearchModel? model)
+ {
+ _logger.LogInformation("ReadList. Id: {Id}", model?.Id);
+ var list = model == null ? _requestStorage.GetFullList() : _requestStorage.GetFilteredList(model);
+ if (list == null)
+ {
+ _logger.LogWarning("ReadList return null list");
+ return null;
+ }
+ _logger.LogInformation("ReadList Count: {Count}", list.Count);
+ return list;
+ }
+ public RequestViewModel? ReadElement(RequestSearchModel model)
+ {
+ if (model == null) throw new ArgumentNullException(nameof(model));
+ _logger.LogInformation("ReadElement. Id: {Id}", model?.Id);
+ var element = _requestStorage.GetElement(model);
+ if (element == null)
+ {
+ _logger.LogWarning("ReadElement element not found");
+ return null;
+ }
+ _logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
+ return element;
+ }
+ public bool Create(RequestBindingModel model)
+ {
+ CheckModel(model);
+ if (model.Status != RequestStatus.Неизвестен) return false;
+ model.Status = RequestStatus.Принята;
+ if (_requestStorage.Insert(model) == null)
+ {
+ _logger.LogWarning("insert operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Update(RequestBindingModel model)
+ {
+ CheckModel(model);
+ if (_requestStorage.Update(model) == null)
+ {
+ _logger.LogWarning("Update operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool Delete(RequestBindingModel model)
+ {
+ CheckModel(model, false);
+ if (_requestStorage.Delete(model) == null)
+ {
+ _logger.LogWarning("Delete operation failed");
+ return false;
+ }
+ return true;
+ }
+ public bool DeclineRequest(RequestBindingModel model)
+ {
+ return ChangeStatus(model, RequestStatus.Выполнена);
+ }
+ public bool SatisfyRequest(RequestBindingModel model)
+ {
+ return ChangeStatus(model, RequestStatus.Отклонена);
+ }
+
+ private void CheckModel(RequestBindingModel model, bool withParams = true)
+ {
+ if (model == null)
+ throw new ArgumentNullException(nameof(model));
+ if (!withParams)
+ return;
+ if (model.Sum <= 0)
+ throw new ArgumentNullException("Неверная сумма", nameof(model.Sum));
+ _logger.LogInformation("Request. Sum:{Sum}. Id: { Id} ", model.Sum, model.Id);
+ }
+
+ private bool ChangeStatus(RequestBindingModel model, RequestStatus status)
+ {
+ //поменять
+ model.Status = status;
+ _requestStorage.Update(model);
+ return true;
+ }
+ }
+}