2023-04-01 20:27:26 +04:00
|
|
|
|
using BankYouBankruptContracts.BindingModels;
|
|
|
|
|
using BankYouBankruptContracts.ViewModels;
|
|
|
|
|
using BankYouBankruptDataModels.Models;
|
2023-04-01 15:33:39 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-04-01 20:27:26 +04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Diagnostics;
|
2023-04-01 15:33:39 +04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace BankYouBankruptDatabaseImplement.Models
|
|
|
|
|
{
|
|
|
|
|
public class CashWithdrawal : ICashWithdrawalModel
|
|
|
|
|
{
|
2023-04-01 20:27:26 +04:00
|
|
|
|
public int Id { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-05-14 15:28:22 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int DebitingId { get; set; }
|
|
|
|
|
|
|
|
|
|
//для передачи номера заявки
|
|
|
|
|
public virtual Debiting Debiting { get; set; }
|
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int AccountId { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-04-01 20:49:00 +04:00
|
|
|
|
//для передачи названия изделия
|
|
|
|
|
public virtual Account Account { get; set; }
|
|
|
|
|
|
2023-05-14 15:28:22 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int CashierId { get; set; }
|
|
|
|
|
|
|
|
|
|
//для передачи фамилии кассира
|
|
|
|
|
public virtual Cashier Cashier { get; set; }
|
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int Sum { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateOperation { get; set; }
|
|
|
|
|
|
|
|
|
|
public static CashWithdrawal Create(BankYouBancruptDatabase context, CashWithdrawalBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
return new CashWithdrawal()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
AccountId = model.AccountId,
|
2023-05-14 20:22:27 +04:00
|
|
|
|
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),
|
2023-04-01 20:27:26 +04:00
|
|
|
|
Sum = model.Sum,
|
|
|
|
|
DateOperation = model.DateOperation
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 23:04:09 +04:00
|
|
|
|
public void Update(CashWithdrawalBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
DateOperation = model.DateOperation;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
public CashWithdrawalViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
AccountId = AccountId,
|
2023-05-14 20:22:27 +04:00
|
|
|
|
CashierId = CashierId,
|
|
|
|
|
DebitingId = DebitingId,
|
|
|
|
|
AccountNumber = Account.AccountNumber,
|
|
|
|
|
SurmaneCashier = Cashier.Surname,
|
|
|
|
|
DebbitingNumber = Debiting.Id,
|
2023-04-01 20:27:26 +04:00
|
|
|
|
Sum = Sum,
|
|
|
|
|
DateOperation = DateOperation
|
|
|
|
|
};
|
|
|
|
|
}
|
2023-04-01 15:33:39 +04:00
|
|
|
|
}
|