change IWithdrawalModel

This commit is contained in:
Zakharov_Rostislav 2024-04-28 21:27:45 +04:00
parent c0a6ad9f08
commit db07c95d36
5 changed files with 11 additions and 7 deletions

View File

@ -12,7 +12,6 @@ namespace BankContracts.BindingModels
public int Id { get; set; }
public DateTime WithdrawalTime { get; set; } = DateTime.Now;
public int? RequestId { get; set; }
public Dictionary<int, IAccountModel> WithdrawalAccounts = new Dictionary<int, IAccountModel>();
public Dictionary<int, (IAccountModel, int)> WithdrawalAccounts { get; set; } = new();
}
}

View File

@ -16,6 +16,6 @@ namespace BankContracts.ViewModels
public DateTime WithdrawalTime { get; set; } = DateTime.Now;
[DisplayName("Номер заявки")]
public int? RequestId { get; set; }
public Dictionary<int, IAccountModel> WithdrawalAccounts { get; set; } = new();
public Dictionary<int, (IAccountModel, int)> WithdrawalAccounts { get; set; } = new();
}
}

View File

@ -10,6 +10,6 @@ namespace BankDataModels.Models
{
DateTime WithdrawalTime { get; set; }
int? RequestId { get; set; }
Dictionary<int, IAccountModel> WithdrawalAccounts { get; }
Dictionary<int, (IAccountModel, int)> WithdrawalAccounts { get; }
}
}

View File

@ -14,6 +14,8 @@ namespace BankDatabaseImplement.Models
public int AccountId { get; set; }
[Required]
public int WithdrawalId { get; set; }
[Required]
public int Sum { get; set; }
public virtual Account Account { get; set; } = new();
public virtual Withdrawal Withdrawal { get; set; } = new();
}

View File

@ -21,15 +21,18 @@ namespace BankDatabaseImplement.Models
public virtual Request? Request { get; set; } = null;
[ForeignKey("WithdrawalId")]
public virtual List<AccountWithdrawal> Accounts { get; set; } = new();
private Dictionary<int, IAccountModel>? _withdrawalAccounts { get; set; } = null;
private Dictionary<int, (IAccountModel, int)>? _withdrawalAccounts { get; set; } = null;
[NotMapped]
public Dictionary<int, IAccountModel> WithdrawalAccounts
public Dictionary<int, (IAccountModel, int)> WithdrawalAccounts
{
get
{
if (_withdrawalAccounts == null)
{
_withdrawalAccounts = Accounts.ToDictionary(x => x.AccountId, x => x.Account as IAccountModel);
_withdrawalAccounts = Accounts.ToDictionary(
x => x.AccountId,
x => (x.Account as IAccountModel, x.Sum)
);
}
return _withdrawalAccounts;
}