49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
|
using BankDataModels.Models;
|
|||
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
using System.ComponentModel.DataAnnotations;
|
|||
|
using BankContracts.BindingModels;
|
|||
|
using BankContracts.ViewModels;
|
|||
|
using Microsoft.EntityFrameworkCore;
|
|||
|
using System.Numerics;
|
|||
|
|
|||
|
namespace BankDatabaseImplement.Models
|
|||
|
{
|
|||
|
public class Currency : ICurrencyModel
|
|||
|
{
|
|||
|
public int Id { get; set; }
|
|||
|
[Required]
|
|||
|
public string CurrencyName { get; set; } = string.Empty;
|
|||
|
[Required]
|
|||
|
public double Course { get; set; }
|
|||
|
[ForeignKey("CurrencyId")]
|
|||
|
public virtual List<DepositCurrency> Deposits { get; set; } = new();
|
|||
|
[ForeignKey("CurrencyId")]
|
|||
|
public virtual List<ProgramCurrency> Programs { get; set; } = new();
|
|||
|
public static Currency? Create(CurrencyBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
return null;
|
|||
|
return new Currency
|
|||
|
{
|
|||
|
Id = model.Id,
|
|||
|
CurrencyName = model.CurrencyName,
|
|||
|
Course = model.Course,
|
|||
|
};
|
|||
|
}
|
|||
|
public void Update(CurrencyBindingModel model)
|
|||
|
{
|
|||
|
if (model == null)
|
|||
|
return;
|
|||
|
Id = model.Id;
|
|||
|
CurrencyName = model.CurrencyName;
|
|||
|
Course = model.Course;
|
|||
|
}
|
|||
|
public CurrencyViewModel GetViewModel => new()
|
|||
|
{
|
|||
|
Id = Id,
|
|||
|
CurrencyName = CurrencyName,
|
|||
|
Course = Course,
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
|