CourseWork_BankYouBankrupt/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/MoneyTransfer.cs

60 lines
1.6 KiB
C#
Raw Normal View History

using BankYouBankruptContracts.BindingModels;
using BankYouBankruptContracts.ViewModels;
using BankYouBankruptDataModels.Models;
2023-04-01 15:33:39 +04:00
using System;
using System.Collections.Generic;
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 MoneyTransfer : IMoneyTransferModel
{
public int Id { get; set; }
2023-04-01 15:33:39 +04:00
[Required]
public int Sum { get; set; }
2023-04-01 15:33:39 +04:00
[Required]
public int AccountSenderId { get; set; }
2023-04-01 15:33:39 +04:00
//для передачи номера счёта отправителя
//public virtual Account AccountSender { get; set; }
[Required]
public int AccountPayeeId { get; set; }
2023-04-01 15:33:39 +04:00
//для передачи номера счёта получателя
//public virtual Account AccountPayee { get; set; }
[Required]
public DateTime DateOperation { get; set; }
public static MoneyTransfer Create(BankYouBancruptDatabase context, MoneyTransferBindingModel model)
{
return new MoneyTransfer()
{
Id = model.Id,
Sum = model.Sum,
AccountSenderId = model.AccountSenderId,
AccountPayeeId = model.AccountPayeeId,
DateOperation = model.DateOperation,
//AccountSender = context.Accounts.First(x => x.Id == model.AccountSenderId),
//AccountPayee = context.Accounts.First(x => x.Id == model.AccountPayeeId)
};
}
public MoneyTransferViewModel GetViewModel => new()
{
Id = Id,
AccountPayeeId = AccountPayeeId,
AccountSenderId = AccountSenderId,
DateOperation = DateOperation,
Sum = Sum
};
}
2023-04-01 15:33:39 +04:00
}