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 ProgramCurrencies { get; set; } = null!; public virtual List Clients { get; set; } = null!; public virtual List 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, }; } }