From 206c85f876cfc9b670f5821dcc65ba3bd6669c6a Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Tue, 16 May 2023 20:51:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=81?= =?UTF-8?q?=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20"=D0=9F=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=20=D0=B4=D0=B5=D0=BD=D0=B5=D0=B3?= =?UTF-8?q?".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MoneyTransferBindingModel.cs | 6 +++- .../ViewModels/MoneyTransferViewModel.cs | 14 +++++++-- .../Models/IMoneyTransferModel.cs | 6 +++- .../Models/MoneyTransfer.cs | 29 +++++++++++++++---- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MoneyTransferBindingModel.cs b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MoneyTransferBindingModel.cs index e790f23..e3465fb 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MoneyTransferBindingModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/BindingModels/MoneyTransferBindingModel.cs @@ -13,10 +13,14 @@ namespace BankYouBankruptContracts.BindingModels public int Sum { get; set; } - public int AccountSenderId { get; set; } + public int? AccountSenderId { get; set; } public int AccountPayeeId { get; set; } public DateTime DateOperation { get; set; } = DateTime.Now; + + public int? CreditingId { get; set; } + + public int CashierId { get; set; } } } diff --git a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/MoneyTransferViewModel.cs b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/MoneyTransferViewModel.cs index 688e9f0..81e596c 100644 --- a/BankYouBankrupt/BankYouBankruptContracts/ViewModels/MoneyTransferViewModel.cs +++ b/BankYouBankrupt/BankYouBankruptContracts/ViewModels/MoneyTransferViewModel.cs @@ -15,17 +15,25 @@ namespace BankYouBankruptContracts.ViewModels [DisplayName("Сумма перевода")] public int Sum { get; set; } - public int AccountSenderId { get; set; } + public int? AccountSenderId { get; set; } [DisplayName("Номер счёта отп.")] - public int AccountSenderNumber { get; set; } + public string AccountSenderNumber { get; set; } = string.Empty; public int AccountPayeeId { get; set; } [DisplayName("Номер счёта получ.")] - public int AccountPayeeNumber { get; set; } + public string AccountPayeeNumber { get; set; } = string.Empty; [DisplayName("Дата операции")] public DateTime DateOperation { get; set; } = DateTime.Now; + + [DisplayName("Номер операции на пополнение")] + public int? CreditingId { get; set; } + + public int CashierId { get; set; } + + [DisplayName("Фамилия кассира")] + public string CashierSurname { get; set; } = string.Empty; } } diff --git a/BankYouBankrupt/BankYouBankruptDataModels/Models/IMoneyTransferModel.cs b/BankYouBankrupt/BankYouBankruptDataModels/Models/IMoneyTransferModel.cs index eef2f7f..8e4fd11 100644 --- a/BankYouBankrupt/BankYouBankruptDataModels/Models/IMoneyTransferModel.cs +++ b/BankYouBankrupt/BankYouBankruptDataModels/Models/IMoneyTransferModel.cs @@ -11,10 +11,14 @@ namespace BankYouBankruptDataModels.Models { int Sum { get; } - int AccountSenderId { get; } + int? AccountSenderId { get; } int AccountPayeeId { get; } DateTime DateOperation { get; } + + int? CreditingId { get; } + + int CashierId { get; } } } diff --git a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/MoneyTransfer.cs b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/MoneyTransfer.cs index 31610a1..452b61e 100644 --- a/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/MoneyTransfer.cs +++ b/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/MoneyTransfer.cs @@ -11,15 +11,15 @@ using System.Threading.Tasks; namespace BankYouBankruptDatabaseImplement.Models { - public class MoneyTransfer : IMoneyTransferModel - { + public class MoneyTransfer : IMoneyTransferModel + { public int Id { get; set; } - [Required] + [Required] public int Sum { get; set; } [Required] - public int AccountSenderId { get; set; } + public int? AccountSenderId { get; set; } [Required] public int AccountPayeeId { get; set; } @@ -27,12 +27,26 @@ namespace BankYouBankruptDatabaseImplement.Models [Required] public DateTime DateOperation { get; set; } + [Required] + public int? CreditingId { get; set; } + + public int CashierId { get; set; } + + public virtual Cashier Cashier { get; set; } + + public virtual Account AccountSender { get; set; } + + public virtual Account AccountPayeer { get; set; } + public static MoneyTransfer Create(BankYouBancruptDatabase context, MoneyTransferBindingModel model) { return new MoneyTransfer() { Id = model.Id, Sum = model.Sum, + Cashier = context.Cashiers.First(x => x.Id == model.CashierId), + AccountSender = context.Accounts.First(x => x.Id == model.AccountSenderId), + AccountPayeer = context.Accounts.First(x => x.Id == model.AccountPayeeId), AccountSenderId = model.AccountSenderId, AccountPayeeId = model.AccountPayeeId, DateOperation = model.DateOperation @@ -50,8 +64,13 @@ namespace BankYouBankruptDatabaseImplement.Models Id = Id, AccountPayeeId = AccountPayeeId, AccountSenderId = AccountSenderId, + AccountPayeeNumber = AccountPayeer.AccountNumber, + AccountSenderNumber = AccountSender.AccountNumber, DateOperation = DateOperation, - Sum = Sum + Sum = Sum, + CreditingId = CreditingId, + CashierId = CashierId, + CashierSurname = Cashier.Surname }; } }