From 9b793348bfb4760e0f04802dda9bd1bc1189b9f0 Mon Sep 17 00:00:00 2001 From: shadowik Date: Thu, 6 Apr 2023 22:32:43 +0400 Subject: [PATCH] Fix --- .../BusinessLogics/CardLogic.cs | 10 +++++++++- .../BusinessLogics/ClientLogic.cs | 5 +---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CardLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CardLogic.cs index de7d462..b254ac3 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CardLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/CardLogic.cs @@ -108,7 +108,15 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics { throw new ArgumentNullException("Нет периода действия", nameof(model.Period)); } - + var element = _cardStorage.GetElement(new CardSearchModel + { + Number = model.Number, + }); + + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Карта с таким ноиером уже есть"); + } _logger.LogInformation("Card. Number:{Number}.CVC:{CVC}.ClientId:{ClientID}.Patronymic:{Period}.Id:{Id}", model.Number, model.CVC, model.Period.ToString(), model.ClientID, model.Id); } diff --git a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ClientLogic.cs b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ClientLogic.cs index 65e7c00..7673514 100644 --- a/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ClientLogic.cs +++ b/BankYouBankrupt/BankYouBankruptBusinessLogic/BusinessLogics/ClientLogic.cs @@ -124,14 +124,11 @@ namespace BankYouBankruptBusinessLogic.BusinessLogics model.Name, model.Surname, model.Patronymic, model.Email, model.Password, model.Telephone, model.Id); var element = _clientStorage.GetElement(new ClientSearchModel { - Name = model.Name, - Surname = model.Surname, - Patronymic = model.Surname, Email = model.Email, }); if (element != null && element.Id != model.Id) { - throw new InvalidOperationException("Клиент с таким именем уже есть"); + throw new InvalidOperationException("Клиент с такой почтой уже есть"); } } }