46 lines
1.4 KiB
C#
46 lines
1.4 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 Program : IProgramModel
|
|
{
|
|
public int Id { get; set; }
|
|
[Required]
|
|
public string ProgramName { get; set; } = string.Empty;
|
|
[Required]
|
|
public double InterestRate { get; set; }
|
|
public virtual List<ProgramCurrency> ProgramCurrencies { get; set; } = null!;
|
|
public virtual List<ClientProgram> Clients { get; set; } = null!;
|
|
public virtual List<Term> Terms { get; set; } = null!;
|
|
public static Program? Create(ProgramBindingModel model)
|
|
{
|
|
if (model == null)
|
|
return null;
|
|
return new Program
|
|
{
|
|
Id = model.Id,
|
|
ProgramName = model.ProgramName,
|
|
InterestRate = model.InterestRate,
|
|
};
|
|
}
|
|
public void Update(ProgramBindingModel model)
|
|
{
|
|
if (model == null)
|
|
return;
|
|
Id = model.Id;
|
|
ProgramName = model.ProgramName;
|
|
InterestRate = model.InterestRate;
|
|
}
|
|
public ProgramViewModel GetViewModel => new()
|
|
{
|
|
Id = Id,
|
|
ProgramName = ProgramName,
|
|
InterestRate = InterestRate,
|
|
};
|
|
}
|
|
}
|