From cba97408278790ffde53ab653fbccd0cf7a6589d Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Wed, 1 May 2024 01:54:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D1=81=D0=BC=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20Database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CashierImplements/AccountStorage.cs | 7 +- .../CashWithdrawalStorage.cs | 8 +- .../CashierImplements/CashierStorage.cs | 8 +- .../CashierImplements/MoneyTransferStorage.cs | 5 +- .../ClientImplements/CardStorage.cs | 218 +++++++++--------- .../ClientImplements/ClientStorage.cs | 50 ++-- .../ClientImplements/CreditingStorage.cs | 76 +++--- .../ClientImplements/DebitingStorage.cs | 75 +++--- .../Models/CashierModels/Account.cs | 12 +- .../Models/CashierModels/CashWithdrawal.cs | 9 +- .../Models/CashierModels/Cashier.cs | 3 +- .../Models/CashierModels/MoneyTransfer.cs | 3 +- .../Models/ClientModels/Card.cs | 9 +- .../Models/ClientModels/Client.cs | 6 +- .../Models/ClientModels/Crediting.cs | 5 +- .../Models/ClientModels/Debiting.cs | 8 +- 16 files changed, 269 insertions(+), 233 deletions(-) diff --git a/Bank/BankDatabaseImplement/Implements/CashierImplements/AccountStorage.cs b/Bank/BankDatabaseImplement/Implements/CashierImplements/AccountStorage.cs index 0ec1513..11b0fae 100644 --- a/Bank/BankDatabaseImplement/Implements/CashierImplements/AccountStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CashierImplements/AccountStorage.cs @@ -12,7 +12,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.CashierImplements { - public class AccountStorage : IAccountStorage + // Реализация интерфейса хранилища для сущности "Счёт" + public class AccountStorage : IAccountStorage { public List GetFullList() { @@ -73,8 +74,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements return context.Accounts .Include(x => x.Client) .FirstOrDefault(x => (!string.IsNullOrEmpty(model.AccountNumber) && x.AccountNumber == model.AccountNumber) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; + (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } public AccountViewModel? Insert(AccountBindingModel model) @@ -127,6 +127,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements public AccountViewModel? Delete(AccountBindingModel model) { using var context = new BankDatabase(); + var element = context.Accounts .Include(x => x.AccountNumber) .FirstOrDefault(rec => rec.Id == model.Id); diff --git a/Bank/BankDatabaseImplement/Implements/CashierImplements/CashWithdrawalStorage.cs b/Bank/BankDatabaseImplement/Implements/CashierImplements/CashWithdrawalStorage.cs index 876ad2f..102e1a9 100644 --- a/Bank/BankDatabaseImplement/Implements/CashierImplements/CashWithdrawalStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CashierImplements/CashWithdrawalStorage.cs @@ -12,7 +12,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.CashierImplements { - public class CashWithdrawalStorage : ICashWithdrawalStorage + // Реализация интерфейса хранилища для сущности "Снятие наличных" + public class CashWithdrawalStorage : ICashWithdrawalStorage { public List GetFullList() { @@ -29,6 +30,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements public List GetFilteredList(CashWithdrawalSearchModel model) { using var context = new BankDatabase(); + var result = context.CashWithdrawals.Include(x => x.Cashier) .Include(x => x.Debiting) .Include(x => x.Account) @@ -54,8 +56,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements .Include(x => x.Debiting) .Include(x => x.Account) .FirstOrDefault(x => (!(model.AccountId < 0) && x.AccountId == model.AccountId) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; + (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } public CashWithdrawalViewModel? Insert(CashWithdrawalBindingModel model) @@ -105,6 +106,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements public CashWithdrawalViewModel? Delete(CashWithdrawalBindingModel model) { using var context = new BankDatabase(); + var element = context.CashWithdrawals .Include(x => x.AccountId) .FirstOrDefault(rec => rec.Id == model.Id); diff --git a/Bank/BankDatabaseImplement/Implements/CashierImplements/CashierStorage.cs b/Bank/BankDatabaseImplement/Implements/CashierImplements/CashierStorage.cs index 393d299..0ec9a4f 100644 --- a/Bank/BankDatabaseImplement/Implements/CashierImplements/CashierStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CashierImplements/CashierStorage.cs @@ -11,7 +11,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.CashierImplements { - public class CashierStorage : ICashierStorage + // Реализация интерфейса хранилища для сущности "Кассир" + public class CashierStorage : ICashierStorage { public List GetFullList() { @@ -48,8 +49,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements return context.Cashiers .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; + (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } public CashierViewModel? Insert(CashierBindingModel model) @@ -72,6 +72,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements public CashierViewModel? Update(CashierBindingModel model) { using var context = new BankDatabase(); + var cashier = context.Cashiers.FirstOrDefault(x => x.Id == model.Id); if (cashier == null) @@ -88,6 +89,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements public CashierViewModel? Delete(CashierBindingModel model) { using var context = new BankDatabase(); + var element = context.Cashiers.FirstOrDefault(rec => rec.Id == model.Id); if (element != null) diff --git a/Bank/BankDatabaseImplement/Implements/CashierImplements/MoneyTransferStorage.cs b/Bank/BankDatabaseImplement/Implements/CashierImplements/MoneyTransferStorage.cs index fa294fd..5e2c13e 100644 --- a/Bank/BankDatabaseImplement/Implements/CashierImplements/MoneyTransferStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/CashierImplements/MoneyTransferStorage.cs @@ -12,7 +12,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.CashierImplements { - public class MoneyTransferStorage : IMoneyTransferStorage + // Реализация интерфейса хранилища для сущности "Перевод денег" + public class MoneyTransferStorage : IMoneyTransferStorage { public List GetFullList() { @@ -29,6 +30,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements public List GetFilteredList(MoneyTransferSearchModel model) { using var context = new BankDatabase(); + var result = context.MoneyTransfers.Include(x => x.Cashier) .Include(x => x.AccountPayeer) .Include(x => x.AccountSender) @@ -124,6 +126,7 @@ namespace BankDatabaseImplement.Implements.CashierImplements public MoneyTransferViewModel? Delete(MoneyTransferBindingModel model) { using var context = new BankDatabase(); + var element = context.MoneyTransfers .Include(x => x.AccountPayeeId) .Include(x => x.AccountSenderId) diff --git a/Bank/BankDatabaseImplement/Implements/ClientImplements/CardStorage.cs b/Bank/BankDatabaseImplement/Implements/ClientImplements/CardStorage.cs index 582f434..800803d 100644 --- a/Bank/BankDatabaseImplement/Implements/ClientImplements/CardStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/ClientImplements/CardStorage.cs @@ -12,132 +12,134 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.ClientImplements { - public class CardStorage : ICardStorage - { - public CardViewModel? Delete(CardBindingModel model) - { - using var context = new BankDatabase(); - var element = context.Cards.FirstOrDefault(rec => rec.Id == model.Id); - if (element != null) - { - context.Cards.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } + // Реализация интерфейса хранилища для сущности "Банковская карта" + public class CardStorage : ICardStorage + { + public CardViewModel? GetElement(CardSearchModel model) + { + if (string.IsNullOrEmpty(model.Number) && !model.Id.HasValue) + { + return null; + } - public CardViewModel? GetElement(CardSearchModel model) - { - if (string.IsNullOrEmpty(model.Number) && !model.Id.HasValue) - { - return null; - } + using var context = new BankDatabase(); - using var context = new BankDatabase(); + return context.Cards + .Include(x => x.Client) + .Include(x => x.Account) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Number) && x.Number == model.Number) || + (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } - return context.Cards - .Include(x => x.Client) - .Include(x => x.Account) - .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Number) && x.Number == model.Number) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; - } + public List GetFilteredList(CardSearchModel model) + { + using var context = new BankDatabase(); - public List GetFilteredList(CardSearchModel model) - { - using var context = new BankDatabase(); + if (!string.IsNullOrEmpty(model.Number)) + { + return context.Cards + .Include(x => x.Client) + .Include(x => x.Account) + .Where(x => x.Number.Contains(model.Number)) + .Select(x => x.GetViewModel) + .ToList(); + } - if (!string.IsNullOrEmpty(model.Number)) - { - return context.Cards - .Include(x => x.Client) - .Include(x => x.Account) - .Where(x => x.Number.Contains(model.Number)) - .Select(x => x.GetViewModel) - .ToList(); - } + if (model.ClientID.HasValue) + { + return context.Cards + .Include(x => x.Client) + .Include(x => x.Account) + .Where(x => x.ClientId == model.ClientID) + .Select(x => x.GetViewModel) + .ToList(); + } - if (model.ClientID.HasValue) - { - return context.Cards - .Include(x => x.Client) - .Include(x => x.Account) - .Where(x => x.ClientId == model.ClientID) - .Select(x => x.GetViewModel) - .ToList(); - } + if (model.AccountId.HasValue) + { + return context.Cards + .Include(x => x.Client) + .Include(x => x.Account) + .Where(x => x.AccountId == model.AccountId) + .Select(x => x.GetViewModel) + .ToList(); + } - if (model.AccountId.HasValue) - { - return context.Cards - .Include(x => x.Client) - .Include(x => x.Account) - .Where(x => x.AccountId == model.AccountId) - .Select(x => x.GetViewModel) - .ToList(); - } + return context.Cards + .Include(x => x.Client) + .Include(x => x.Account) + .Select(x => x.GetViewModel) + .ToList(); + } - return context.Cards - .Include(x => x.Client) - .Include(x => x.Account) - .Select(x => x.GetViewModel) - .ToList(); - } + public List GetFullList() + { + using var context = new BankDatabase(); - public List GetFullList() - { - using var context = new BankDatabase(); + return context.Cards + .Include(x => x.Client) + .Include(x => x.Account) + .Select(x => x.GetViewModel) + .ToList(); + } - return context.Cards - .Include(x => x.Client) - .Include(x => x.Account) - .Select(x => x.GetViewModel) - .ToList(); - } + public CardViewModel? Insert(CardBindingModel model) + { + using var context = new BankDatabase(); - public CardViewModel? Insert(CardBindingModel model) - { - using var context = new BankDatabase(); + var newCard = Card.Create(context, model); - var newCard = Card.Create(context, model); + if (newCard == null) + { + return null; + } - if (newCard == null) - { - return null; - } + context.Cards.Add(newCard); + context.SaveChanges(); - context.Cards.Add(newCard); - context.SaveChanges(); + return newCard.GetViewModel; + } - return newCard.GetViewModel; - } + public CardViewModel? Update(CardBindingModel model) + { + using var context = new BankDatabase(); + using var transaction = context.Database.BeginTransaction(); - public CardViewModel? Update(CardBindingModel model) - { - using var context = new BankDatabase(); - using var transaction = context.Database.BeginTransaction(); + try + { + var card = context.Cards.FirstOrDefault(rec => rec.Id == model.Id); - try - { - var card = context.Cards.FirstOrDefault(rec => rec.Id == model.Id); + if (card == null) + { + return null; + } - if (card == null) - { - return null; - } + card.Update(model); + context.SaveChanges(); + transaction.Commit(); - card.Update(model); - context.SaveChanges(); - transaction.Commit(); + return card.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } - return card.GetViewModel; - } - catch - { - transaction.Rollback(); - throw; - } - } - } + public CardViewModel? Delete(CardBindingModel model) + { + using var context = new BankDatabase(); + var element = context.Cards.FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Cards.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + + return null; + } + } } diff --git a/Bank/BankDatabaseImplement/Implements/ClientImplements/ClientStorage.cs b/Bank/BankDatabaseImplement/Implements/ClientImplements/ClientStorage.cs index b8be733..64a7f92 100644 --- a/Bank/BankDatabaseImplement/Implements/ClientImplements/ClientStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/ClientImplements/ClientStorage.cs @@ -11,21 +11,9 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.ClientImplements { - public class ClientStorage : IClientStorage + // Реализация интерфейса хранилища для сущности "Клиент" + public class ClientStorage : IClientStorage { - public ClientViewModel? Delete(ClientBindingModel model) - { - using var context = new BankDatabase(); - var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id); - if (element != null) - { - context.Clients.Remove(element); - context.SaveChanges(); - return element.GetViewModel; - } - return null; - } - public ClientViewModel? GetElement(ClientSearchModel model) { if (string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue) @@ -35,16 +23,14 @@ namespace BankDatabaseImplement.Implements.ClientImplements using var context = new BankDatabase(); - //сработает для поиска почты для отправки файла + // Для поиска почты для отправки файла if (model.Id.HasValue && string.IsNullOrEmpty(model.Password)) { return context.Clients.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel; } - return context.Clients.FirstOrDefault(x => - (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email && !string.IsNullOrEmpty(model.Password) && x.Password == model.Password) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; + return context.Clients.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Email) && x.Email == model.Email + && !string.IsNullOrEmpty(model.Password) && x.Password == model.Password) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; } public List GetFilteredList(ClientSearchModel model) @@ -53,6 +39,7 @@ namespace BankDatabaseImplement.Implements.ClientImplements { return new(); } + using var context = new BankDatabase(); return context.Clients.Where(x => x.Name.Contains(model.Name)).Select(x => x.GetViewModel).ToList(); } @@ -60,17 +47,21 @@ namespace BankDatabaseImplement.Implements.ClientImplements public List GetFullList() { using var context = new BankDatabase(); + return context.Clients.Select(x => x.GetViewModel).ToList(); } public ClientViewModel? Insert(ClientBindingModel model) { var newComponent = Client.Create(model); + if (newComponent == null) { return null; } + using var context = new BankDatabase(); + context.Clients.Add(newComponent); context.SaveChanges(); return newComponent.GetViewModel; @@ -79,14 +70,33 @@ namespace BankDatabaseImplement.Implements.ClientImplements public ClientViewModel? Update(ClientBindingModel model) { using var context = new BankDatabase(); + var component = context.Clients.FirstOrDefault(x => x.Id == model.Id); + if (component == null) { return null; } + component.Update(model); context.SaveChanges(); return component.GetViewModel; } - } + + public ClientViewModel? Delete(ClientBindingModel model) + { + using var context = new BankDatabase(); + + var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id); + + if (element != null) + { + context.Clients.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + + return null; + } + } } diff --git a/Bank/BankDatabaseImplement/Implements/ClientImplements/CreditingStorage.cs b/Bank/BankDatabaseImplement/Implements/ClientImplements/CreditingStorage.cs index 681f33c..aac594d 100644 --- a/Bank/BankDatabaseImplement/Implements/ClientImplements/CreditingStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/ClientImplements/CreditingStorage.cs @@ -12,9 +12,44 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.ClientImplements { - public class CreditingStorage : ICreditingStorage + // Реализация интерфейса хранилища для сущности "Пополнение карты" + public class CreditingStorage : ICreditingStorage { - public List GetFullList() + public CreditingViewModel? GetElement(CreditingSearchModel model) + { + if (model.CardId < 0 && !model.Id.HasValue) + { + return null; + } + + using var context = new BankDatabase(); + + return context.Creditings + .Include(x => x.Card) + .FirstOrDefault(x => x.Id == model.Id) + ?.GetViewModel; + } + + public List GetFilteredList(CreditingSearchModel model) + { + using var context = new BankDatabase(); + + var result = context.Creditings.Include(x => x.Card).ToList(); + + if (model.CardId.HasValue) result = result.Where(x => x.CardId == model.CardId).ToList(); + + if (model.ClientId.HasValue) + { + List cards = context.Cards.Where(x => x.ClientId == model.ClientId).Select(x => x.Id).ToList(); + result = result.Where(x => cards.Contains(x.CardId)).ToList(); + } + + if (model.DateCrediting.HasValue) result = result.Where(x => x.DateCredit >= model.DateCrediting).ToList(); + + return result.Select(x => x.GetViewModel).ToList(); + } + + public List GetFullList() { using var context = new BankDatabase(); @@ -22,40 +57,7 @@ namespace BankDatabaseImplement.Implements.ClientImplements .Include(x => x.Card) .Select(x => x.GetViewModel) .ToList(); - } - - public List GetFilteredList(CreditingSearchModel model) - { - using var context = new BankDatabase(); - var result = context.Creditings.Include(x => x.Card).ToList(); - - - if (model.CardId.HasValue) result = result.Where(x => x.CardId == model.CardId).ToList(); - - if (model.ClientId.HasValue) - { - List cards = context.Cards.Where(x => x.ClientId == model.ClientId).Select(x => x.Id).ToList(); - result = result.Where(x => cards.Contains(x.CardId)).ToList(); - } - if (model.DateCrediting.HasValue) result = result.Where(x => x.DateCredit >= model.DateCrediting).ToList(); - - return result.Select(x => x.GetViewModel).ToList(); - } - - public CreditingViewModel? GetElement(CreditingSearchModel model) - { - if (model.CardId < 0 && !model.Id.HasValue) - { - return null; - } - - using var context = new BankDatabase(); - - return context.Creditings - .Include(x => x.Card) - .FirstOrDefault(x => x.Id == model.Id) - ?.GetViewModel; - } + } public CreditingViewModel? Insert(CreditingBindingModel model) { @@ -77,6 +79,7 @@ namespace BankDatabaseImplement.Implements.ClientImplements public CreditingViewModel? Update(CreditingBindingModel model) { using var context = new BankDatabase(); + using var transaction = context.Database.BeginTransaction(); try @@ -107,6 +110,7 @@ namespace BankDatabaseImplement.Implements.ClientImplements public CreditingViewModel? Delete(CreditingBindingModel model) { using var context = new BankDatabase(); + var element = context.Creditings .Include(x => x.CardId) .FirstOrDefault(rec => rec.Id == model.Id); diff --git a/Bank/BankDatabaseImplement/Implements/ClientImplements/DebitingStorage.cs b/Bank/BankDatabaseImplement/Implements/ClientImplements/DebitingStorage.cs index 7bee161..54a8ee1 100644 --- a/Bank/BankDatabaseImplement/Implements/ClientImplements/DebitingStorage.cs +++ b/Bank/BankDatabaseImplement/Implements/ClientImplements/DebitingStorage.cs @@ -12,9 +12,45 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Implements.ClientImplements { - public class DebitingStorage : IDebitingStorage + // Реализация интерфейса хранилища для сущности "Снятие с карты" + public class DebitingStorage : IDebitingStorage { - public List GetFullList() + public DebitingViewModel? GetElement(DebitingSearchModel model) + { + if (model.CardId < 0 && !model.Id.HasValue) + { + return null; + } + + using var context = new BankDatabase(); + + return context.Debitings + .Include(x => x.Card) + .FirstOrDefault(x => (!(model.CardId < 0) && x.CardId == model.CardId) || + (model.Id.HasValue && x.Id == model.Id)) + ?.GetViewModel; + } + + public List GetFilteredList(DebitingSearchModel model) + { + using var context = new BankDatabase(); + + var result = context.Debitings.Include(x => x.Card).ToList(); + + // Для получения всех заявок на стнятие + + if (model.CardId.HasValue) result = result.Where(x => x.CardId == model.CardId).ToList(); + + if (model.ClientId.HasValue) + { + List cards = context.Cards.Where(x => x.ClientId == model.ClientId).Select(x => x.Id).ToList(); + result = result.Where(x => cards.Contains(x.CardId)).ToList(); + } + + return result.Select(x => x.GetViewModel).ToList(); + } + + public List GetFullList() { using var context = new BankDatabase(); @@ -24,41 +60,6 @@ namespace BankDatabaseImplement.Implements.ClientImplements .ToList(); } - public List GetFilteredList(DebitingSearchModel model) - { - using var context = new BankDatabase(); - - var result = context.Debitings.Include(x => x.Card).ToList(); - - //для получения всех заявок на стнятие - - if (model.CardId.HasValue) result = result.Where(x => x.CardId == model.CardId).ToList(); - - if (model.ClientId.HasValue) - { - List cards = context.Cards.Where(x => x.ClientId == model.ClientId).Select(x => x.Id).ToList(); - result = result.Where(x => cards.Contains(x.CardId)).ToList(); - } - - return result.Select(x => x.GetViewModel).ToList(); - } - - public DebitingViewModel? GetElement(DebitingSearchModel model) - { - if (model.CardId < 0 && !model.Id.HasValue) - { - return null; - } - - using var context = new BankDatabase(); - - return context.Debitings - .Include(x => x.Card) - .FirstOrDefault(x => (!(model.CardId < 0) && x.CardId == model.CardId) || - (model.Id.HasValue && x.Id == model.Id)) - ?.GetViewModel; - } - public DebitingViewModel? Insert(DebitingBindingModel model) { using var context = new BankDatabase(); diff --git a/Bank/BankDatabaseImplement/Models/CashierModels/Account.cs b/Bank/BankDatabaseImplement/Models/CashierModels/Account.cs index fa29e3b..aac97ea 100644 --- a/Bank/BankDatabaseImplement/Models/CashierModels/Account.cs +++ b/Bank/BankDatabaseImplement/Models/CashierModels/Account.cs @@ -13,8 +13,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Models.CashierModels { - //реализация аккаунта - public class Account : IAccountModel + // Класс, реализующий интерфейс модели счёта + public class Account : IAccountModel { public int Id { get; set; } @@ -27,7 +27,7 @@ namespace BankDatabaseImplement.Models.CashierModels [Required] public int ClientId { get; set; } - //для передачи ФИО клиента + // Для передачи ФИО клиента public virtual Client Client { get; set; } [Required] @@ -39,11 +39,11 @@ namespace BankDatabaseImplement.Models.CashierModels [Required] public StatusAccount StatusAccount { get; set; } = StatusAccount.Открыт; - //для реализации связи один ко многим со Снятием наличных + // Для реализации связи один-ко-многим со Снятием наличных [ForeignKey("AccountId")] public virtual List CashWithdrawals { get; set; } = new(); - //для реализации связи один ко многим с Переводом денег + // Для реализации связи один-ко-многим с Переводом денег [NotMapped] [ForeignKey("AccountSenderId")] public virtual List MoneyTransferSenders { get; set; } = new(); @@ -52,7 +52,7 @@ namespace BankDatabaseImplement.Models.CashierModels [ForeignKey("AccountPayeeId")] public virtual List MoneyTransferPayees { get; set; } = new(); - //для реализации связи один ко многим с Картами + // Для реализации связи один-ко-многим с Картами [ForeignKey("AccountId")] public virtual List Cards { get; set; } = new(); diff --git a/Bank/BankDatabaseImplement/Models/CashierModels/CashWithdrawal.cs b/Bank/BankDatabaseImplement/Models/CashierModels/CashWithdrawal.cs index 123a3c7..d0961d9 100644 --- a/Bank/BankDatabaseImplement/Models/CashierModels/CashWithdrawal.cs +++ b/Bank/BankDatabaseImplement/Models/CashierModels/CashWithdrawal.cs @@ -12,26 +12,27 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Models.CashierModels { - public class CashWithdrawal : ICashWithdrawalModel + // Класс, реализующий интерфейс модели снятие наличных + public class CashWithdrawal : ICashWithdrawalModel { public int Id { get; set; } [Required] public int DebitingId { get; set; } - //для передачи номера заявки + // Для передачи номера заявки public virtual Debiting Debiting { get; set; } [Required] public int AccountId { get; set; } - //для передачи номера счета + // Для передачи номера счета public virtual Account Account { get; set; } [Required] public int CashierId { get; set; } - //для передачи данных о кассире + // Для передачи данных о кассире public virtual Cashier Cashier { get; set; } [Required] diff --git a/Bank/BankDatabaseImplement/Models/CashierModels/Cashier.cs b/Bank/BankDatabaseImplement/Models/CashierModels/Cashier.cs index de53129..5cfc609 100644 --- a/Bank/BankDatabaseImplement/Models/CashierModels/Cashier.cs +++ b/Bank/BankDatabaseImplement/Models/CashierModels/Cashier.cs @@ -11,7 +11,8 @@ using BankDataModels.Models.Cashier; namespace BankDatabaseImplement.Models.CashierModels { - public class Cashier : ICashierModel + // Класс, реализующий интерфейс модели кассира + public class Cashier : ICashierModel { public int Id { get; set; } diff --git a/Bank/BankDatabaseImplement/Models/CashierModels/MoneyTransfer.cs b/Bank/BankDatabaseImplement/Models/CashierModels/MoneyTransfer.cs index f41f3e4..27b3692 100644 --- a/Bank/BankDatabaseImplement/Models/CashierModels/MoneyTransfer.cs +++ b/Bank/BankDatabaseImplement/Models/CashierModels/MoneyTransfer.cs @@ -10,7 +10,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Models.CashierModels { - public class MoneyTransfer : IMoneyTransferModel + // Класс, реализующий интерфейс модели перевода денег + public class MoneyTransfer : IMoneyTransferModel { public int Id { get; set; } diff --git a/Bank/BankDatabaseImplement/Models/ClientModels/Card.cs b/Bank/BankDatabaseImplement/Models/ClientModels/Card.cs index 5df923b..684f1fd 100644 --- a/Bank/BankDatabaseImplement/Models/ClientModels/Card.cs +++ b/Bank/BankDatabaseImplement/Models/ClientModels/Card.cs @@ -14,7 +14,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Models.ClientModels { - public class Card : ICardModel + // Класс, реализующий интерфейс модели банковской карты + public class Card : ICardModel { public int Id { get; set; } @@ -43,10 +44,12 @@ namespace BankDatabaseImplement.Models.ClientModels [Required] public string? ClientSurname { get; set; } - [ForeignKey("Cardid")] + // Для реализации связи один-ко-многим с пополнением карты + [ForeignKey("CardId")] public virtual List creditings { get; set; } = new(); - [ForeignKey("Cardid")] + // Для реализации связи один-ко-многим со снятием наличных с карты + [ForeignKey("CardId")] public virtual List debitings { get; set; } = new(); public CardViewModel GetViewModel => new() diff --git a/Bank/BankDatabaseImplement/Models/ClientModels/Client.cs b/Bank/BankDatabaseImplement/Models/ClientModels/Client.cs index 36bdd41..07f7706 100644 --- a/Bank/BankDatabaseImplement/Models/ClientModels/Client.cs +++ b/Bank/BankDatabaseImplement/Models/ClientModels/Client.cs @@ -11,7 +11,8 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Models.ClientModels { - public class Client : IClientModel + // Класс, реализующий интерфейс модели клиента + public class Client : IClientModel { public int Id { get; set; } @@ -33,7 +34,8 @@ namespace BankDatabaseImplement.Models.ClientModels [Required] public string MobilePhone { get; set; } = string.Empty; - [ForeignKey("ClientId")] + // Для реализации связи один-ко-многим с банковскими картами + [ForeignKey("ClientId")] public virtual List Cards { get; set; } = new(); public ClientViewModel GetViewModel => new() diff --git a/Bank/BankDatabaseImplement/Models/ClientModels/Crediting.cs b/Bank/BankDatabaseImplement/Models/ClientModels/Crediting.cs index 88ba168..9eec619 100644 --- a/Bank/BankDatabaseImplement/Models/ClientModels/Crediting.cs +++ b/Bank/BankDatabaseImplement/Models/ClientModels/Crediting.cs @@ -12,7 +12,8 @@ using BankDatabaseImplement.Models.CashierModels; namespace BankDatabaseImplement.Models.ClientModels { - public class Crediting : ICreditingModel + // Класс, реализующий интерфейс модели пополнения карты + public class Crediting : ICreditingModel { public int Id { get; set; } @@ -29,7 +30,7 @@ namespace BankDatabaseImplement.Models.ClientModels [Required] public DateTime DateCredit { get; set; } = DateTime.Now; - //для реализации связи один ко многим с переводом денег + // Для реализации связи один-ко-многим с переводом денег [ForeignKey("CreditingId")] public virtual List MoneyTransfers { get; set; } = new(); diff --git a/Bank/BankDatabaseImplement/Models/ClientModels/Debiting.cs b/Bank/BankDatabaseImplement/Models/ClientModels/Debiting.cs index ebcafe3..f796f55 100644 --- a/Bank/BankDatabaseImplement/Models/ClientModels/Debiting.cs +++ b/Bank/BankDatabaseImplement/Models/ClientModels/Debiting.cs @@ -10,10 +10,11 @@ using System.Threading.Tasks; namespace BankDatabaseImplement.Models.ClientModels { - public class Debiting : IDebitingModel + // Класс, реализующий интерфейс модели снятие с карты + public class Debiting : IDebitingModel { - //реализация операции на пополнение public int Id { get; set; } + [Required] public int CardId { get; set; } @@ -21,6 +22,7 @@ namespace BankDatabaseImplement.Models.ClientModels [Required] public double Sum { get; set; } + [Required] public DateTime DateDebit { get; set; } = DateTime.Now; @@ -45,7 +47,7 @@ namespace BankDatabaseImplement.Models.ClientModels DateDebit = model.DateDebit, }; } - //вот тут хз, надо ли обновлять эту операцию, если судить чисто логически, то не надо ОБДУМАТЬ!!!!!!!! + // вот тут надо ли обновлять эту операцию..., если судить чисто логически, то не надо ОБДУМАТЬ!!!!!!!! По идее лишним не будет, а может и будет public void Update(DebitingBindingModel model) { DateDebit = model.DateDebit;