Правки сущностей "Кассир" и "Выдача наличных со счёта".

This commit is contained in:
Programmist73 2023-05-14 15:28:22 +04:00
parent dbeaf0e380
commit 10d97c1ff8
9 changed files with 60 additions and 3 deletions

View File

@ -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;

View File

@ -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; }

View File

@ -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; }

View File

@ -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; }

View File

@ -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;

View File

@ -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();
}

View File

@ -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;

View File

@ -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
};

View File

@ -38,6 +38,10 @@ namespace BankYouBankruptDatabaseImplement.Models
[ForeignKey("CashierId")]
public virtual List<Account> Accounts { get; set; } = new();
//для реализации связи один ко многим с заявками на снятие наличных со счёта
[ForeignKey("CashierId")]
public virtual List<CashWithdrawal> CashWithdrawals { get; set; } = new();
public static Cashier Create(BankYouBancruptDatabase context, CashierBindingModel model)
{
return new Cashier()