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

32 lines
807 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<CountryCreate> 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);
countries.Add(newCountry);
}
return new Currency(this, countries);
}
}
}