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

37 lines
909 B
C#
Raw Normal View History

2022-08-18 22:59:13 +03:00
using System.Collections.Generic;
2022-08-17 23:21:00 +03:00
using System.ComponentModel.DataAnnotations;
using MapTo;
2022-08-17 23:17:37 +03:00
2022-08-17 23:21:00 +03:00
namespace BlueWest.Data
2022-08-17 23:17:37 +03:00
{
2022-08-18 22:59:13 +03:00
[MapFrom( typeof(Country))]
2022-08-17 23:21:00 +03:00
public partial class CountryCreate
{
// ISO 3166-1 numeric code
public int Code { get; set; } // Primary key
public string StateName { get; set; }
2022-08-18 22:59:13 +03:00
public List<CurrencyCreate> CurrenciesToCreate { get; set; }
2022-08-17 23:21:00 +03:00
[MaxLength(2)] public string Alpha2Code { get; set; }
2022-08-18 22:59:13 +03:00
2022-08-17 23:21:00 +03:00
public string TLD { get; set; }
2022-08-18 22:59:13 +03:00
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);
}
2022-08-17 23:21:00 +03:00
}
}