CodeLiturgy.Dashboard/BlueWest.Data/Currency/CurrencyCreate.cs

31 lines
804 B
C#

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MapTo;
namespace BlueWest.Data
{
[MapFrom(typeof(Currency))]
public partial class CurrencyCreate
{
public int Num { get; set; } // Primary key
[MaxLength(3)] public string Code { get; set; }
public List<CountryUnique> CountriesToCreate { get; set; }
public CurrencyCreate() { }
public Currency ToCurrency()
{
List<Country> countries = new List<Country>();
foreach (var countryCreate in CountriesToCreate)
{
var newCountry = new Country(countryCreate, null, null);
countries.Add(newCountry);
}
return new Currency(this, countries);
}
}
}