75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
using BankContracts.BindingModels.Cashier;
|
||
using BankContracts.StoragesModels;
|
||
using BankContracts.ViewModels.Cashier.ViewModels;
|
||
using BankDatabaseImplement.Models.ClientModels;
|
||
using BankDataModels.Models.Cashier;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace BankDatabaseImplement.Models.CashierModels
|
||
{
|
||
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]
|
||
public double Sum { get; set; }
|
||
|
||
[Required]
|
||
public DateTime DateWithdrawal { get; set; }
|
||
|
||
public static CashWithdrawal Create(BankDatabase context, CashWithdrawalBindingModel model)
|
||
{
|
||
return new CashWithdrawal()
|
||
{
|
||
Id = model.Id,
|
||
AccountId = model.AccountId,
|
||
Account = context.Accounts.First(x => x.Id == model.AccountId),
|
||
DebitingId = model.DebitingId,
|
||
Debiting = context.Debitings.First(x => x.Id == model.DebitingId),
|
||
CashierId = model.CashierId,
|
||
Cashier = context.Cashiers.First(x => x.Id == model.CashierId),
|
||
Sum = model.Sum,
|
||
DateWithdrawal = model.DateWithdrawal
|
||
};
|
||
}
|
||
|
||
public void Update(CashWithdrawalBindingModel model)
|
||
{
|
||
DateWithdrawal = model.DateWithdrawal;
|
||
}
|
||
|
||
public CashWithdrawalViewModel GetViewModel => new()
|
||
{
|
||
Id = Id,
|
||
AccountId = AccountId,
|
||
CashierId = CashierId,
|
||
DebitingId = DebitingId,
|
||
Sum = Sum,
|
||
DateWithdrawal = DateWithdrawal
|
||
};
|
||
}
|
||
}
|