本文整理汇总了C#中Nop.Web.Models.Common.AddressModel.PrepareModel方法的典型用法代码示例。如果您正苦于以下问题:C# AddressModel.PrepareModel方法的具体用法?C# AddressModel.PrepareModel怎么用?C# AddressModel.PrepareModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nop.Web.Models.Common.AddressModel
的用法示例。
在下文中一共展示了AddressModel.PrepareModel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Addresses
public ActionResult Addresses()
{
if (!_workContext.CurrentCustomer.IsRegistered())
return new HttpUnauthorizedResult();
var customer = _workContext.CurrentCustomer;
var model = new CustomerAddressListModel();
var addresses = customer.Addresses
//enabled for the current store
.Where(a => a.Country == null || _storeMappingService.Authorize(a.Country))
.ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(
address: address,
excludeProperties: false,
addressSettings: _addressSettings,
localizationService: _localizationService,
stateProvinceService: _stateProvinceService,
addressAttributeFormatter: _addressAttributeFormatter,
loadCountries: () => _countryService.GetAllCountries(_workContext.WorkingLanguage.Id));
model.Addresses.Add(addressModel);
}
return View(model);
}
示例2: Addresses
public ActionResult Addresses()
{
if (!IsCurrentUserRegistered())
return new HttpUnauthorizedResult();
var customer = _workContext.CurrentCustomer;
var model = new CustomerAddressListModel();
model.NavigationModel = GetCustomerNavigationModel(customer);
model.NavigationModel.SelectedTab = CustomerNavigationEnum.Addresses;
foreach (var address in customer.Addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(address, false, _addressSettings, _localizationService,
_stateProvinceService, () => _countryService.GetAllCountries());
model.Addresses.Add(addressModel);
}
return View(model);
}
示例3: PrepareShippingAddressModel
protected CheckoutShippingAddressModel PrepareShippingAddressModel(int? selectedCountryId = null)
{
var model = new CheckoutShippingAddressModel();
//existing addresses
var addresses = _workContext.CurrentCustomer.Addresses.Where(a => a.Country == null || a.Country.AllowsShipping).ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(address,
false,
_addressSettings);
model.ExistingAddresses.Add(addressModel);
}
//new address
model.NewAddress.CountryId = selectedCountryId;
model.NewAddress.PrepareModel(null,
false,
_addressSettings,
_localizationService,
_stateProvinceService,
() => _countryService.GetAllCountriesForShipping());
return model;
}
示例4: Addresses
public ActionResult Addresses()
{
if (!_workContext.CurrentCustomer.IsRegistered())
return new HttpUnauthorizedResult();
var customer = _workContext.CurrentCustomer;
var model = new CustomerAddressListModel();
model.NavigationModel = GetCustomerNavigationModel(customer);
model.NavigationModel.SelectedTab = CustomerNavigationEnum.Addresses;
var addresses = customer.Addresses
//enabled for the current store
.Where(a => a.Country == null || _storeMappingService.Authorize(a.Country))
.ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(address, false, _addressSettings, _localizationService,
_stateProvinceService, () => _countryService.GetAllCountries());
model.Addresses.Add(addressModel);
}
return View(model);
}
示例5: PrepareShippingAddressModel
protected CheckoutShippingAddressModel PrepareShippingAddressModel(int? selectedCountryId = null,
bool prePopulateNewAddressWithCustomerFields = false)
{
var model = new CheckoutShippingAddressModel();
//existing addresses
var addresses = _workContext.CurrentCustomer.Addresses
//allow shipping
.Where(a => a.Country == null || a.Country.AllowsShipping)
//enabled for the current store
.Where(a => a.Country == null || _storeMappingService.Authorize(a.Country))
.ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(address,
false,
_addressSettings);
model.ExistingAddresses.Add(addressModel);
}
//new address
model.NewAddress.CountryId = selectedCountryId;
model.NewAddress.PrepareModel(null,
false,
_addressSettings,
_localizationService,
_stateProvinceService,
() => _countryService.GetAllCountriesForShipping(),
prePopulateNewAddressWithCustomerFields,
_workContext.CurrentCustomer);
return model;
}
示例6: PrepareShippingAddressModel
protected virtual CheckoutShippingAddressModel PrepareShippingAddressModel(int? selectedCountryId = null,
bool prePopulateNewAddressWithCustomerFields = false)
{
var model = new CheckoutShippingAddressModel();
//allow pickup in store?
model.AllowPickUpInStore = _shippingSettings.AllowPickUpInStore;
if (model.AllowPickUpInStore && _shippingSettings.PickUpInStoreFee > 0)
{
decimal shippingTotal = _shippingSettings.PickUpInStoreFee;
decimal rateBase = _taxService.GetShippingPrice(shippingTotal, _workContext.CurrentCustomer);
decimal rate = _currencyService.ConvertFromPrimaryStoreCurrency(rateBase, _workContext.WorkingCurrency);
model.PickUpInStoreFee = _priceFormatter.FormatShippingPrice(rate, true);
}
//existing addresses
var addresses = _workContext.CurrentCustomer.Addresses
//allow shipping
.Where(a => a.Country == null || a.Country.AllowsShipping)
//enabled for the current store
.Where(a => a.Country == null || _storeMappingService.Authorize(a.Country))
.ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(
address: address,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
model.ExistingAddresses.Add(addressModel);
}
//new address
model.NewAddress.CountryId = selectedCountryId;
model.NewAddress.PrepareModel(
address: null,
excludeProperties: false,
addressSettings: _addressSettings,
localizationService: _localizationService,
stateProvinceService: _stateProvinceService,
addressAttributeService: _addressAttributeService,
addressAttributeParser: _addressAttributeParser,
loadCountries: () => _countryService.GetAllCountriesForShipping(),
prePopulateWithCustomerFields: prePopulateNewAddressWithCustomerFields,
customer: _workContext.CurrentCustomer);
return model;
}
示例7: PrepareBillingAddressModel
protected virtual CheckoutBillingAddressModel PrepareBillingAddressModel(int? selectedCountryId = null,
bool prePopulateNewAddressWithCustomerFields = false)
{
var model = new CheckoutBillingAddressModel();
//existing addresses
var addresses = _workContext.CurrentCustomer.Addresses
//allow billing
.Where(a => a.Country == null || a.Country.AllowsBilling)
//enabled for the current store
.Where(a => a.Country == null || _storeMappingService.Authorize(a.Country))
.ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(
address: address,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
model.ExistingAddresses.Add(addressModel);
}
//new address
model.NewAddress.CountryId = selectedCountryId;
model.NewAddress.PrepareModel(address:
null,
excludeProperties: false,
addressSettings: _addressSettings,
localizationService: _localizationService,
stateProvinceService: _stateProvinceService,
addressAttributeService: _addressAttributeService,
addressAttributeParser: _addressAttributeParser,
loadCountries: () => _countryService.GetAllCountriesForBilling(),
prePopulateWithCustomerFields: prePopulateNewAddressWithCustomerFields,
customer: _workContext.CurrentCustomer);
return model;
}
示例8: PrepareShippingAddressModel
protected virtual CheckoutShippingAddressModel PrepareShippingAddressModel(int? selectedCountryId = null,
bool prePopulateNewAddressWithCustomerFields = false, string overrideAttributesXml = "")
{
var model = new CheckoutShippingAddressModel();
//allow pickup in store?
model.AllowPickUpInStore = _shippingSettings.AllowPickUpInStore;
if (model.AllowPickUpInStore)
{
model.DisplayPickupPointsOnMap = _shippingSettings.DisplayPickupPointsOnMap;
model.GoogleMapsApiKey = _shippingSettings.GoogleMapsApiKey;
var pickupPointProviders = _shippingService.LoadActivePickupPointProviders(_storeContext.CurrentStore.Id);
if (pickupPointProviders.Any())
{
var pickupPointsResponse = _shippingService.GetPickupPoints(_workContext.CurrentCustomer.BillingAddress, null, _storeContext.CurrentStore.Id);
if (pickupPointsResponse.Success)
model.PickupPoints = pickupPointsResponse.PickupPoints.Select(x =>
{
var country = _countryService.GetCountryByTwoLetterIsoCode(x.CountryCode);
var pickupPointModel = new CheckoutPickupPointModel
{
Id = x.Id,
Name = x.Name,
Description = x.Description,
ProviderSystemName = x.ProviderSystemName,
Address = x.Address,
City = x.City,
CountryName = country != null ? country.Name : string.Empty,
ZipPostalCode = x.ZipPostalCode,
Latitude = x.Latitude,
Longitude = x.Longitude,
OpeningHours = x.OpeningHours
};
if (x.PickupFee > 0)
{
var amount = _taxService.GetShippingPrice(x.PickupFee, _workContext.CurrentCustomer);
amount = _currencyService.ConvertFromPrimaryStoreCurrency(amount, _workContext.WorkingCurrency);
pickupPointModel.PickupFee = _priceFormatter.FormatShippingPrice(amount, true);
}
return pickupPointModel;
}).ToList();
else
foreach (var error in pickupPointsResponse.Errors)
model.Warnings.Add(error);
}
//only available pickup points
if (!_shippingService.LoadActiveShippingRateComputationMethods(_storeContext.CurrentStore.Id).Any())
{
if (!pickupPointProviders.Any())
{
model.Warnings.Add(_localizationService.GetResource("Checkout.ShippingIsNotAllowed"));
model.Warnings.Add(_localizationService.GetResource("Checkout.PickupPoints.NotAvailable"));
}
model.PickUpInStoreOnly = true;
model.PickUpInStore = true;
return model;
}
}
//existing addresses
var addresses = _workContext.CurrentCustomer.Addresses
.Where(a => a.Country == null ||
(//published
a.Country.Published &&
//allow shipping
a.Country.AllowsShipping &&
//enabled for the current store
_storeMappingService.Authorize(a.Country)))
.ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(
address: address,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
model.ExistingAddresses.Add(addressModel);
}
//new address
model.NewAddress.CountryId = selectedCountryId;
model.NewAddress.PrepareModel(
address: null,
excludeProperties: false,
addressSettings: _addressSettings,
localizationService: _localizationService,
stateProvinceService: _stateProvinceService,
addressAttributeService: _addressAttributeService,
addressAttributeParser: _addressAttributeParser,
loadCountries: () => _countryService.GetAllCountriesForShipping(_workContext.WorkingLanguage.Id),
prePopulateWithCustomerFields: prePopulateNewAddressWithCustomerFields,
customer: _workContext.CurrentCustomer,
overrideAttributesXml: overrideAttributesXml);
return model;
}
示例9: PrepareBillingAddressModel
protected virtual CheckoutBillingAddressModel PrepareBillingAddressModel(IList<ShoppingCartItem> cart,
int? selectedCountryId = null,
bool prePopulateNewAddressWithCustomerFields = false,
string overrideAttributesXml = "")
{
var model = new CheckoutBillingAddressModel();
model.ShipToSameAddressAllowed = _shippingSettings.ShipToSameAddress && cart.RequiresShipping();
model.ShipToSameAddress = true;
//existing addresses
var addresses = _workContext.CurrentCustomer.Addresses
.Where(a => a.Country == null ||
(//published
a.Country.Published &&
//allow billing
a.Country.AllowsBilling &&
//enabled for the current store
_storeMappingService.Authorize(a.Country)))
.ToList();
foreach (var address in addresses)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(
address: address,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
model.ExistingAddresses.Add(addressModel);
}
//new address
model.NewAddress.CountryId = selectedCountryId;
model.NewAddress.PrepareModel(address:
null,
excludeProperties: false,
addressSettings: _addressSettings,
localizationService: _localizationService,
stateProvinceService: _stateProvinceService,
addressAttributeService: _addressAttributeService,
addressAttributeParser: _addressAttributeParser,
loadCountries: () => _countryService.GetAllCountriesForBilling(_workContext.WorkingLanguage.Id),
prePopulateWithCustomerFields: prePopulateNewAddressWithCustomerFields,
customer: _workContext.CurrentCustomer,
overrideAttributesXml: overrideAttributesXml);
return model;
}
示例10: PrepareConfirmAddressModel
protected virtual CheckoutConfirmAddressModel PrepareConfirmAddressModel()
{
var model = new CheckoutConfirmAddressModel();
var BillingAddress = _workContext.CurrentCustomer.BillingAddress;
if (BillingAddress != null)
{
var addressModel = new AddressModel();
addressModel.PrepareModel(
address: BillingAddress,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
model.BillingAddress = addressModel;
}
var shippingAddress = _workContext.CurrentCustomer.ShippingAddress;
if (shippingAddress != null)
{
var ShippingAddressModel = new AddressModel();
ShippingAddressModel.PrepareModel(
address: shippingAddress,
excludeProperties: false,
addressSettings: _addressSettings,
addressAttributeFormatter: _addressAttributeFormatter);
model.ShippingAddress = ShippingAddressModel;
}
return model;
}