From 10d97c1ff81bc053b24e0ead3675c15a9105c7fd Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 14 May 2023 15:28:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=81?= =?UTF-8?q?=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B5=D0=B9=20"=D0=9A?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=B8=D1=80"=20=D0=B8=20"=D0=92=D1=8B=D0=B4?= =?UTF-8?q?=D0=B0=D1=87=D0=B0=20=D0=BD=D0=B0=D0=BB=D0=B8=D1=87=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D1=81=D0=BE=20=D1=81=D1=87=D1=91=D1=82=D0=B0".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BindingModels/CashWithdrawalBindingModel.cs | 4 ++++ .../SearchModels/CashWithdrawalSearchModel.cs | 4 ++++ .../ViewModels/CashWithdrawalViewModel.cs | 10 ++++++++++ .../Models/ICashWithdrawalModel.cs | 4 ++++ .../Implements/AccountStorage.cs | 2 ++ .../Implements/CardStorage.cs | 6 ++++-- .../Implements/CashWithdrawalStorage.cs | 16 ++++++++++++++++ .../Models/CashWithdrawal.cs | 13 ++++++++++++- .../Models/Cashier.cs | 4 ++++ 9 files changed, 60 insertions(+), 3 deletions(-) diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CashWithdrawalBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CashWithdrawalBindingModel.cs index b937e2e..8a409c8 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CashWithdrawalBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/CashWithdrawalBindingModel.cs @@ -11,8 +11,12 @@ namespace BankYouBankruptContracts.BindingModels { public int Id { get; set; } + public int DebitingId { get; set; } + public int AccountId { get; set; } + public int CashierId { get; set; } + public int Sum { get; set; } public DateTime DateOperation { get; set; } = DateTime.Now; diff --git a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs index eb6f703..5c5aeec 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/SearchModels/CashWithdrawalSearchModel.cs @@ -10,8 +10,12 @@ namespace BankYouBankruptContracts.SearchModels { public int? Id { get; set; } + public int? DebitingId { get; set; } + public int? AccountId { get; set; } + public int? CashierId { get; set; } + public int? Sum { get; set; } public DateTime? DateFrom { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CashWithdrawalViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CashWithdrawalViewModel.cs index d3aa12f..b39d5e4 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CashWithdrawalViewModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/CashWithdrawalViewModel.cs @@ -12,11 +12,21 @@ namespace BankYouBankruptContracts.ViewModels { public int Id { get; set; } + public int DebitingId { get; set; } + + [DisplayName("Номер заявки на снятие средств")] + public int DebbitingNumber { get; set; } + public int AccountId { get; set; } [DisplayName("Номер счёта")] public int AccountNumber { get; set; } + public int CashierId { get; set; } + + [DisplayName("Кассир")] + public string SurmaneCashier { get; set; } = string.Empty; + [DisplayName("Сумма выданных наличных")] public int Sum { get; set; } diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Models/ICashWithdrawalModel.cs b/BankYouBankrupt/BankYouBankruptDataModels/Models/ICashWithdrawalModel.cs index 2f77816..913ea15 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Models/ICashWithdrawalModel.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Models/ICashWithdrawalModel.cs @@ -9,8 +9,12 @@ namespace BankYouBankruptDataModels.Models //выдача наличных public interface ICashWithdrawalModel : IId { + int DebitingId { get; } + int AccountId { get; } + int CashierId { get; } + int Sum { get; } DateTime DateOperation { get; } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/AccountStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/AccountStorage.cs index d97227a..7bfad1b 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/AccountStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/AccountStorage.cs @@ -19,6 +19,7 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); return context.Accounts + .Include(x => x.Client) .Select(x => x.GetViewModel) .ToList(); } @@ -70,6 +71,7 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); 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; diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs index dd92aab..d1e384d 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CardStorage.cs @@ -37,7 +37,8 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); return context.Cards - .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Number) && x.Number == model.Number) || + .Include(x => x.Client) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.Number) && x.Number == model.Number) || (model.Id.HasValue && x.Id == model.Id)) ?.GetViewModel; } @@ -75,7 +76,8 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); return context.Cards - .Select(x => x.GetViewModel) + .Include(x => x.Client) + .Select(x => x.GetViewModel) .ToList(); } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs index 87f9bd4..70d2f92 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Implements/CashWithdrawalStorage.cs @@ -19,6 +19,8 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); return context.CashWithdrawals + .Include(x => x.Cashier) + .Include(x => x.Debiting) .Select(x => x.GetViewModel) .ToList(); } @@ -32,7 +34,19 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); + if (model.CashierId.HasValue) + { + return context.CashWithdrawals + .Include(x => x.Cashier) + .Include(x => x.Debiting) + .Where(x => x.CashierId == model.CashierId) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.CashWithdrawals + .Include(x => x.Cashier) + .Include(x => x.Debiting) .Where(x => x.AccountId == model.AccountId) .Select(x => x.GetViewModel) .ToList(); @@ -48,6 +62,8 @@ namespace BankYouBankruptDatabaseImplement.Implements using var context = new BankYouBancruptDatabase(); return context.CashWithdrawals + .Include(x => x.Cashier) + .Include(x => x.Debiting) .FirstOrDefault(x => (!(model.AccountId < 0) && x.AccountId == model.AccountId) || (model.Id.HasValue && x.Id == model.Id)) ?.GetViewModel; diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/CashWithdrawal.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/CashWithdrawal.cs index 331e694..8d96b14 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/CashWithdrawal.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/CashWithdrawal.cs @@ -15,12 +15,24 @@ namespace BankYouBankruptDatabaseImplement.Models { 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] public int Sum { get; set; } @@ -33,7 +45,6 @@ namespace BankYouBankruptDatabaseImplement.Models { Id = model.Id, AccountId = model.AccountId, - Account = context.Accounts.First(x => x.Id == model.AccountId), Sum = model.Sum, DateOperation = model.DateOperation }; diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Cashier.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Cashier.cs index 5332560..65b08d7 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Cashier.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/Cashier.cs @@ -38,6 +38,10 @@ namespace BankYouBankruptDatabaseImplement.Models [ForeignKey("CashierId")] public virtual List Accounts { get; set; } = new(); + //для реализации связи один ко многим с заявками на снятие наличных со счёта + [ForeignKey("CashierId")] + public virtual List CashWithdrawals { get; set; } = new(); + public static Cashier Create(BankYouBancruptDatabase context, CashierBindingModel model) { return new Cashier()