CourseWork_BankYouBankrupt/BankYouBankrupt/BankYouBankruptDatabaseImplement/Models/MoneyTransfer.cs

58 lines
1.3 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
[Required]
public int AccountPayeeId { get; set; }
2023-04-01 15:33:39 +04:00
[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
};
}
public void Update(MoneyTransferBindingModel model)
{
Id = model.Id;
DateOperation = model.DateOperation;
}
public MoneyTransferViewModel GetViewModel => new()
{
Id = Id,
AccountPayeeId = AccountPayeeId,
AccountSenderId = AccountSenderId,
DateOperation = DateOperation,
Sum = Sum
};
}
2023-04-01 15:33:39 +04:00
}