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
|
|
|
|
|
{
|
2023-05-16 20:51:29 +04:00
|
|
|
|
public class MoneyTransfer : IMoneyTransferModel
|
|
|
|
|
{
|
2023-04-01 20:27:26 +04:00
|
|
|
|
public int Id { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-05-16 20:51:29 +04:00
|
|
|
|
[Required]
|
2023-04-01 20:27:26 +04:00
|
|
|
|
public int Sum { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-05-16 20:51:29 +04:00
|
|
|
|
public int? AccountSenderId { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public int AccountPayeeId { get; set; }
|
2023-04-01 15:33:39 +04:00
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
[Required]
|
|
|
|
|
public DateTime DateOperation { get; set; }
|
|
|
|
|
|
2023-05-16 20:51:29 +04:00
|
|
|
|
public int? CreditingId { get; set; }
|
|
|
|
|
|
|
|
|
|
public int CashierId { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual Cashier Cashier { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual Account AccountSender { get; set; }
|
|
|
|
|
|
|
|
|
|
public virtual Account AccountPayeer { get; set; }
|
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
public static MoneyTransfer Create(BankYouBancruptDatabase context, MoneyTransferBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
return new MoneyTransfer()
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id,
|
|
|
|
|
Sum = model.Sum,
|
2023-05-16 20:51:29 +04:00
|
|
|
|
Cashier = context.Cashiers.First(x => x.Id == model.CashierId),
|
2023-05-16 21:55:36 +04:00
|
|
|
|
AccountSender = model.AccountSenderId == null ? null : context.Accounts.First(x => x.Id == model.AccountSenderId),
|
2023-05-16 20:51:29 +04:00
|
|
|
|
AccountPayeer = context.Accounts.First(x => x.Id == model.AccountPayeeId),
|
2023-04-01 20:27:26 +04:00
|
|
|
|
AccountSenderId = model.AccountSenderId,
|
|
|
|
|
AccountPayeeId = model.AccountPayeeId,
|
2023-05-16 21:55:36 +04:00
|
|
|
|
DateOperation = model.DateOperation,
|
|
|
|
|
CreditingId = model.CreditingId,
|
|
|
|
|
CashierId = model.CashierId
|
2023-04-01 20:27:26 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 22:54:15 +04:00
|
|
|
|
public void Update(MoneyTransferBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
Id = model.Id;
|
|
|
|
|
DateOperation = model.DateOperation;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-01 20:27:26 +04:00
|
|
|
|
public MoneyTransferViewModel GetViewModel => new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
AccountPayeeId = AccountPayeeId,
|
|
|
|
|
AccountSenderId = AccountSenderId,
|
2023-05-16 20:51:29 +04:00
|
|
|
|
AccountPayeeNumber = AccountPayeer.AccountNumber,
|
2023-05-16 21:55:36 +04:00
|
|
|
|
AccountSenderNumber = AccountSenderId == null ? null : AccountSender.AccountNumber,
|
2023-04-01 20:27:26 +04:00
|
|
|
|
DateOperation = DateOperation,
|
2023-05-16 20:51:29 +04:00
|
|
|
|
Sum = Sum,
|
|
|
|
|
CreditingId = CreditingId,
|
|
|
|
|
CashierId = CashierId,
|
|
|
|
|
CashierSurname = Cashier.Surname
|
2023-04-01 20:27:26 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
2023-04-01 15:33:39 +04:00
|
|
|
|
}
|