本文整理汇总了C#中ICountryService.GetCountryByTwoOrThreeLetterIsoCode方法的典型用法代码示例。如果您正苦于以下问题:C# ICountryService.GetCountryByTwoOrThreeLetterIsoCode方法的具体用法?C# ICountryService.GetCountryByTwoOrThreeLetterIsoCode怎么用?C# ICountryService.GetCountryByTwoOrThreeLetterIsoCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICountryService
的用法示例。
在下文中一共展示了ICountryService.GetCountryByTwoOrThreeLetterIsoCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToFormatedAddress
public static string ToFormatedAddress(this Address amazonAddress, ICountryService countryService, IStateProvinceService stateProvinceService)
{
var sb = new StringBuilder();
try
{
var city = (amazonAddress.IsSetCity() ? amazonAddress.City : null);
var zip = (amazonAddress.IsSetPostalCode() ? amazonAddress.PostalCode : null);
sb.AppendLine("");
if (amazonAddress.Name.HasValue())
sb.AppendLine(amazonAddress.Name);
if (amazonAddress.AddressLine1.HasValue())
sb.AppendLine(amazonAddress.AddressLine1);
if (amazonAddress.AddressLine2.HasValue())
sb.AppendLine(amazonAddress.AddressLine2);
if (amazonAddress.AddressLine3.HasValue())
sb.AppendLine(amazonAddress.AddressLine3);
sb.AppendLine(zip.Grow(city, " "));
if (amazonAddress.IsSetStateOrRegion())
{
var stateProvince = stateProvinceService.GetStateProvinceByAbbreviation(amazonAddress.StateOrRegion);
if (stateProvince == null)
sb.AppendLine(amazonAddress.StateOrRegion);
else
sb.AppendLine("{0} {1}".FormatWith(amazonAddress.StateOrRegion, stateProvince.GetLocalized(x => x.Name)));
}
if (amazonAddress.IsSetCountryCode())
{
var country = countryService.GetCountryByTwoOrThreeLetterIsoCode(amazonAddress.CountryCode);
if (country == null)
sb.AppendLine(amazonAddress.CountryCode);
else
sb.AppendLine("{0} {1}".FormatWith(amazonAddress.CountryCode, country.GetLocalized(x => x.Name)));
}
if (amazonAddress.Phone.HasValue())
{
sb.AppendLine(amazonAddress.Phone);
}
}
catch (Exception exc)
{
exc.Dump();
}
return sb.ToString();
}
示例2: ToAddress
public static void ToAddress(this Address amazonAddress, SmartStore.Core.Domain.Common.Address address, ICountryService countryService,
IStateProvinceService stateProvinceService, out bool countryAllowsShipping, out bool countryAllowsBilling)
{
countryAllowsShipping = countryAllowsBilling = true;
if (amazonAddress.IsSetName())
{
address.ToFirstAndLastName(amazonAddress.Name);
}
if (amazonAddress.IsSetAddressLine1())
{
address.Address1 = amazonAddress.AddressLine1.TrimSafe().Truncate(4000);
}
if (amazonAddress.IsSetAddressLine2())
{
address.Address2 = amazonAddress.AddressLine2.TrimSafe().Truncate(4000);
}
if (amazonAddress.IsSetAddressLine3())
{
address.Address2 = address.Address2.Grow(amazonAddress.AddressLine3.TrimSafe(), ", ").Truncate(4000);
}
// normalize
if (address.Address1.IsEmpty() && address.Address2.HasValue())
{
address.Address1 = address.Address2;
address.Address2 = null;
}
else if (address.Address1.HasValue() && address.Address1 == address.Address2)
{
address.Address2 = null;
}
if (amazonAddress.IsSetCity())
{
address.City = amazonAddress.City.TrimSafe().Truncate(4000);
}
if (amazonAddress.IsSetPostalCode())
{
address.ZipPostalCode = amazonAddress.PostalCode.TrimSafe().Truncate(4000);
}
if (amazonAddress.IsSetPhone())
{
address.PhoneNumber = amazonAddress.Phone.TrimSafe().Truncate(4000);
}
if (amazonAddress.IsSetCountryCode())
{
var country = countryService.GetCountryByTwoOrThreeLetterIsoCode(amazonAddress.CountryCode);
if (country != null)
{
address.CountryId = country.Id;
countryAllowsShipping = country.AllowsShipping;
countryAllowsBilling = country.AllowsBilling;
}
}
if (amazonAddress.IsSetStateOrRegion())
{
var stateProvince = stateProvinceService.GetStateProvinceByAbbreviation(amazonAddress.StateOrRegion);
if (stateProvince != null)
address.StateProvinceId = stateProvince.Id;
}
//amazonAddress.District, amazonAddress.County ??
if (address.CountryId == 0)
address.CountryId = null;
if (address.StateProvinceId == 0)
address.StateProvinceId = null;
}