47 lines
1.4 KiB
C#
47 lines
1.4 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; }
|
|
public virtual List<DepositCurrency> DepositCurrencies { get; set; } = null!;
|
|
public virtual List<ProgramCurrency> ProgramCurrencies { get; set; } = null!;
|
|
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,
|
|
};
|
|
}
|
|
}
|
|
|