78 lines
2.0 KiB
C#
78 lines
2.0 KiB
C#
using BankYouBankruptContracts.BindingModels;
|
|
using BankYouBankruptContracts.ViewModels;
|
|
using BankYouBankruptDataModels.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BankYouBankruptDatabaseImplement.Models
|
|
{
|
|
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 int Sum { get; set; }
|
|
|
|
[Required]
|
|
public DateTime DateOperation { get; set; }
|
|
|
|
public static CashWithdrawal Create(BankYouBancruptDatabase 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,
|
|
DateOperation = model.DateOperation
|
|
};
|
|
}
|
|
|
|
public void Update(CashWithdrawalBindingModel model)
|
|
{
|
|
DateOperation = model.DateOperation;
|
|
}
|
|
|
|
public CashWithdrawalViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
AccountId = AccountId,
|
|
CashierId = CashierId,
|
|
DebitingId = DebitingId,
|
|
AccountNumber = Account.AccountNumber,
|
|
SurmaneCashier = Cashier.Surname,
|
|
DebbitingNumber = Debiting.Id,
|
|
DebitingStatus = Debiting.Status,
|
|
Sum = Sum,
|
|
DateOperation = DateOperation
|
|
};
|
|
}
|
|
}
|