本文整理汇总了C#中Nop.Core.Domain.Directory.Country类的典型用法代码示例。如果您正苦于以下问题:C# Country类的具体用法?C# Country怎么用?C# Country使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Country类属于Nop.Core.Domain.Directory命名空间,在下文中一共展示了Country类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_save_and_load_country
public void Can_save_and_load_country()
{
var country = new Country
{
Name = "United States",
AllowsBilling = true,
AllowsShipping = true,
TwoLetterIsoCode = "US",
ThreeLetterIsoCode = "USA",
NumericIsoCode = 1,
SubjectToVat = true,
Published = true,
DisplayOrder = 1,
LimitedToStores = true
};
var fromDb = SaveAndLoadEntity(country);
fromDb.ShouldNotBeNull();
fromDb.Name.ShouldEqual("United States");
fromDb.AllowsBilling.ShouldEqual(true);
fromDb.AllowsShipping.ShouldEqual(true);
fromDb.TwoLetterIsoCode.ShouldEqual("US");
fromDb.ThreeLetterIsoCode.ShouldEqual("USA");
fromDb.NumericIsoCode.ShouldEqual(1);
fromDb.SubjectToVat.ShouldEqual(true);
fromDb.Published.ShouldEqual(true);
fromDb.DisplayOrder.ShouldEqual(1);
fromDb.LimitedToStores.ShouldEqual(true);
}
示例2: Can_save_and_load_country_with_states
public void Can_save_and_load_country_with_states()
{
var country = new Country
{
Name = "United States",
AllowsBilling = true,
AllowsShipping = true,
TwoLetterIsoCode = "US",
ThreeLetterIsoCode = "USA",
NumericIsoCode = 1,
SubjectToVat = true,
Published = true,
DisplayOrder = 1
};
country.StateProvinces.Add
(
new StateProvince()
{
Name = "California",
Abbreviation = "CA",
DisplayOrder = 1
}
);
var fromDb = SaveAndLoadEntity(country);
fromDb.ShouldNotBeNull();
fromDb.Name.ShouldEqual("United States");
fromDb.StateProvinces.ShouldNotBeNull();
(fromDb.StateProvinces.Count == 1).ShouldBeTrue();
fromDb.StateProvinces.First().Name.ShouldEqual("California");
}
示例3: Can_save_and_load_country_with_restrictions
public void Can_save_and_load_country_with_restrictions()
{
var country = new Country
{
Name = "United States",
AllowsBilling = true,
AllowsShipping = true,
TwoLetterIsoCode = "US",
ThreeLetterIsoCode = "USA",
NumericIsoCode = 1,
SubjectToVat = true,
Published = true,
DisplayOrder = 1
};
country.RestrictedShippingMethods.Add
(
new ShippingMethod()
{
Name = "By train",
}
);
var fromDb = SaveAndLoadEntity(country);
fromDb.ShouldNotBeNull();
fromDb.Name.ShouldEqual("United States");
fromDb.RestrictedShippingMethods.ShouldNotBeNull();
(fromDb.RestrictedShippingMethods.Count == 1).ShouldBeTrue();
fromDb.RestrictedShippingMethods.First().Name.ShouldEqual("By train");
}
示例4: UpdateLocales
protected void UpdateLocales(Country country, CountryModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(country,
x => x.Name,
localized.Name,
localized.LanguageId);
}
}
示例5: GetPaypalCountryCodeType
/// <summary>
/// Get Paypal country code
/// </summary>
/// <param name="country">Country</param>
/// <returns>Paypal country code</returns>
protected CountryCodeType GetPaypalCountryCodeType(Country country)
{
CountryCodeType payerCountry = CountryCodeType.US;
try
{
payerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country.TwoLetterIsoCode);
}
catch
{
}
return payerCountry;
}
示例6: DeleteCountry
/// <summary>
/// Deletes a country
/// </summary>
/// <param name="country">Country</param>
public virtual void DeleteCountry(Country country)
{
if (country == null)
throw new ArgumentNullException("country");
_countryRepository.Delete(country);
_cacheManager.RemoveByPattern(COUNTRIES_PATTERN_KEY);
//event notification
_eventPublisher.EntityDeleted(country);
}
示例7: GetPaypalCountryCodeType
/// <summary>
/// Get Paypal country code
/// </summary>
/// <param name="country">Country</param>
/// <returns>Paypal country code</returns>
protected CountryCodeType GetPaypalCountryCodeType(Country country)
{
var payerCountry = CountryCodeType.US;
try
{
payerCountry = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), country.TwoLetterIsoCode.ToUpperInvariant());
}
catch
{
}
return payerCountry;
}
示例8: ToEntity
public static Country ToEntity(this CountryModel model, Country destination)
{
return Mapper.Map(model, destination);
}
示例9: PrepareStoresMappingModel
private void PrepareStoresMappingModel(CountryModel model, Country country, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (country != null)
{
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(country);
}
else
{
model.SelectedStoreIds = new int[0];
}
}
}
示例10: SaveStoreMappings
protected void SaveStoreMappings(Country country, CountryModel model)
{
var existingStoreMappings = _storeMappingService.GetStoreMappings(country);
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.Id))
{
//new role
if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0)
_storeMappingService.InsertStoreMapping(country, store.Id);
}
else
{
//removed role
var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id);
if (storeMappingToDelete != null)
_storeMappingService.DeleteStoreMapping(storeMappingToDelete);
}
}
}
示例11: InstallCountriesAndStates
protected virtual void InstallCountriesAndStates()
{
var cUsa = new Country
{
Id = 1,
_id = ObjectId.GenerateNewId().ToString(),
Name = "United States",
AllowsBilling = true,
AllowsShipping = true,
TwoLetterIsoCode = "US",
ThreeLetterIsoCode = "USA",
NumericIsoCode = 840,
SubjectToVat = false,
DisplayOrder = 1,
Published = true,
};
var states = new List<StateProvince>();
_countryRepository.Insert(cUsa);
states.Add(new StateProvince
{
CountryId = 1,
Name = "AA (Armed Forces Americas)",
Abbreviation = "AA",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "AE (Armed Forces Europe)",
Abbreviation = "AE",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "Alabama",
Abbreviation = "AL",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "Alaska",
Abbreviation = "AK",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "American Samoa",
Abbreviation = "AS",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "AP (Armed Forces Pacific)",
Abbreviation = "AP",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "Arizona",
Abbreviation = "AZ",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "Arkansas",
Abbreviation = "AR",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "California",
Abbreviation = "CA",
Published = true,
DisplayOrder = 1,
});
states.Add(new StateProvince
{
CountryId = 1,
Name = "Colorado",
Abbreviation = "CO",
Published = true,
DisplayOrder = 1,
});
//.........这里部分代码省略.........
示例12: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(CountryModel model, Country country, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && country != null)
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(country).ToList();
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
model.AvailableStores.Add(new SelectListItem
{
Text = store.Name,
Value = store.Id.ToString(),
Selected = model.SelectedStoreIds.Contains(store.Id)
});
}
}
示例13: UpdateLocales
protected virtual List<LocalizedProperty> UpdateLocales(Country country, CountryModel model)
{
List<LocalizedProperty> localized = new List<LocalizedProperty>();
foreach (var local in model.Locales)
{
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "Name",
LocaleValue = local.Name
});
}
return localized;
}
示例14: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(CountryModel model, Country country, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (country != null)
{
model.SelectedStoreIds = country.Stores.ToArray();
}
}
}
示例15: CityList
public ActionResult CityList(DataSourceRequest command, int productId)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
return AccessDeniedView();
var product = _productService.GetProductById(productId);
if (product == null)
throw new ArgumentException("No product found with the specified id");
//a vendor should have access only to his products
if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id)
return Content("This is not your product");
var Cities = _productCitiesService.GetProductsCitiesByProductId(productId);
List<ProductModel.CityModel> citymodel = new List<ProductModel.CityModel>();
foreach (var c in Cities)
{
if (c != null)
{
ProductModel.CityModel city = new ProductModel.CityModel();
string countryName;
var state = new StateProvince();
var country = new Country();
var cty = new City();
if (c.CityID > 0)
{
cty = _cityService.GetCityById(c.CityID);
state = _stateProvinceService.GetStateProvinceById(cty.StateID);
country = _countryService.GetCountryById(state.Id);
countryName = country != null ? country.Name : "Deleted";
}
else
{
countryName = _localizationService.GetResource("Admin.Catalog.Products.City.Fields.Country.All");
}
city.Id = c.Id;
city.CityId = c.CityID;
city.City = cty.CityName;
city.CountryId = country != null ? country.Id : 0;
city.Country = country != null ? country.Name : "Deleted";
city.StateId = state != null ? state.Id : 0;
city.State = state != null ? state.Name : "Deleted";
city.ProductId = c.ProductID;
citymodel.Add(city);
}
}
var gridModel = new DataSourceResult
{
Data = citymodel,
Total = citymodel.Count
};
return Json(gridModel);
}