2024-05-02 00:46:24 +04:00
|
|
|
|
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; }
|
2024-05-27 01:09:39 +04:00
|
|
|
|
public virtual List<DepositCurrency> DepositCurrencies { get; set; } = null!;
|
|
|
|
|
public virtual List<ProgramCurrency> ProgramCurrencies { get; set; } = null!;
|
2024-05-02 00:46:24 +04:00
|
|
|
|
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,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|