CodeLiturgy.Dashboard/BlueWest.Data/Country/CountryCreate.cs

37 lines
909 B
C#

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MapTo;
namespace BlueWest.Data
{
[MapFrom( typeof(Country))]
public partial class CountryCreate
{
// ISO 3166-1 numeric code
public int Code { get; set; } // Primary key
public string StateName { get; set; }
public List<CurrencyUnique> CurrenciesToCreate { get; set; }
[MaxLength(2)] public string Alpha2Code { get; set; }
public string TLD { get; set; }
public CountryCreate() { }
public Country ToCountry()
{
var currencies = new List<Currency>();
foreach (var currencyCreate in CurrenciesToCreate)
{
currencies.Add(new Currency(currencyCreate, null));
}
return new Country(this, currencies);
}
}
}