PIbd-23_Elatomtsev_L.K._Cou.../Bank/BankDatabaseImplement/Models/Deposit.cs

43 lines
1.2 KiB
C#

using BankDataModels.Models;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using BankContracts.BindingModels;
using BankContracts.ViewModels;
namespace BankDatabaseImplement.Models
{
public class Deposit : IDepositModel
{
public int Id { get; set; }
[Required]
public double Sum { get; set; }
[Required]
public DateOnly OpeningDate { get; set; }
public virtual List<DepositCurrency> DepositCurrencies { get; set; } = null!;
public virtual List<ClientDeposit> ClientDeposits { get; set; } = null!;
public virtual List<Refill> Refills { get; set; } = null!;
public static Deposit? Create(DepositBindingModel model)
{
if (model == null)
return null;
return new Deposit
{
Id = model.Id,
Sum = model.Sum,
};
}
public void Update(DepositBindingModel model)
{
if (model == null)
return;
Id = model.Id;
Sum = model.Sum;
}
public DepositViewModel GetViewModel => new()
{
Id = Id,
Sum = Sum,
};
}
}