本文整理汇总了C#中Nop.Core.Domain.Common.Address类的典型用法代码示例。如果您正苦于以下问题:C# Address类的具体用法?C# Address怎么用?C# Address使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Address类属于Nop.Core.Domain.Common命名空间,在下文中一共展示了Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPickupPoints
/// <summary>
/// Get pickup points for the address
/// </summary>
/// <param name="address">Address</param>
/// <returns>Represents a response of getting pickup points</returns>
public GetPickupPointsResponse GetPickupPoints(Address address)
{
var result = new GetPickupPointsResponse();
foreach (var point in _storePickupPointService.GetAllStorePickupPoints(_storeContext.CurrentStore.Id))
{
var pointAddress = _addressService.GetAddressById(point.AddressId);
if (pointAddress != null)
result.PickupPoints.Add(new PickupPoint
{
Id = point.Id.ToString(),
Name = point.Name,
Description = point.Description,
Address = pointAddress.Address1,
City = pointAddress.City,
CountryCode = pointAddress.Country != null ? pointAddress.Country.TwoLetterIsoCode : string.Empty,
ZipPostalCode = pointAddress.ZipPostalCode,
OpeningHours = point.OpeningHours,
PickupFee = point.PickupFee,
ProviderSystemName = PluginDescriptor.SystemName
});
}
if (result.PickupPoints.Count == 0)
result.AddError(_localizationService.GetResource("Plugins.Pickup.PickupInStore.NoPickupPoints"));
return result;
}
示例2: Can_save_and_load_address_with_stateProvince
public void Can_save_and_load_address_with_stateProvince()
{
var address = new Address
{
FirstName = "FirstName 1",
LastName = "LastName 1",
Email = "Email 1",
Company = "Company 1",
City = "City 1",
Address1 = "Address1",
Address2 = "Address2",
ZipPostalCode = "ZipPostalCode 1",
PhoneNumber = "PhoneNumber 1",
FaxNumber = "FaxNumber 1",
CreatedOnUtc = new DateTime(2010, 01, 01),
Country = GetTestCountry(),
StateProvince = GetTestStateProvince(),
};
var fromDb = SaveAndLoadEntity(address);
fromDb.ShouldNotBeNull();
fromDb.StateProvince.ShouldNotBeNull();
fromDb.StateProvince.Name.ShouldEqual("California");
}
示例3: ToEntity
public static Address ToEntity(this AddressModel model)
{
if (model == null)
return null;
var entity = new Address();
return ToEntity(model, entity);
}
示例4: Can_add_address
public void Can_add_address()
{
var customer = new Customer();
var address = new Address { Id = 1 };
customer.Addresses.Add(address);
customer.Addresses.Count.ShouldEqual(1);
customer.Addresses.First().Id.ShouldEqual(1);
}
示例5: DeleteAddress
/// <summary>
/// Deletes an address
/// </summary>
/// <param name="address">Address</param>
public virtual void DeleteAddress(Address address)
{
if (address == null)
throw new ArgumentNullException("address");
_addressRepository.Delete(address);
//event notification
_eventPublisher.EntityDeleted(address);
}
示例6: DeleteAddress
/// <summary>
/// Deletes an address
/// </summary>
/// <param name="address">Address</param>
public virtual void DeleteAddress(Address address)
{
if (address == null)
throw new ArgumentNullException("address");
_addressRepository.Delete(address);
//cache
_cacheManager.RemoveByPattern(ADDRESSES_PATTERN_KEY);
//event notification
_eventPublisher.EntityDeleted(address);
}
示例7: Can_remove_address_assigned_as_billing_address
public void Can_remove_address_assigned_as_billing_address()
{
var customer = new Customer();
var address = new Address { Id = 1 };
customer.Addresses.Add(address);
customer.BillingAddress = address;
customer.BillingAddress.ShouldBeTheSameAs(customer.Addresses.First());
customer.RemoveAddress(address);
customer.Addresses.Count.ShouldEqual(0);
customer.BillingAddress.ShouldBeNull();
}
示例8: Can_not_add_duplicate_addresses
public void Can_not_add_duplicate_addresses()
{
var customer = new Customer();
var address = new Address { Id = 1 };
var address2 = new Address { Id = 2 };
customer.AddAddress(address);
customer.AddAddress(address); // should not add
customer.AddAddress(address2);
customer.Addresses.Count.ShouldEqual(2);
var addresses = customer.Addresses.ToList();
addresses[0].Id.ShouldEqual(1);
addresses[1].Id.ShouldEqual(2);
}
示例9: CreateShippingOptionRequest
/// <summary>
/// Create shipment package from shopping cart
/// </summary>
/// <param name="cart">Shopping cart</param>
/// <param name="shippingAddress">Shipping address</param>
/// <returns>Shipment package</returns>
public virtual GetShippingOptionRequest CreateShippingOptionRequest(IList<ShoppingCartItem> cart,
Address shippingAddress)
{
var request = new GetShippingOptionRequest();
request.Customer = cart.GetCustomer();
request.Items = new List<ShoppingCartItem>();
foreach (var sc in cart)
if (sc.IsShipEnabled)
request.Items.Add(sc);
request.ShippingAddress = shippingAddress;
//TODO set values from warehouses or shipping origin
request.CountryFrom = null;
request.StateProvinceFrom = null;
request.ZipPostalCodeFrom = string.Empty;
return request;
}
示例10: Can_clone_address
public void Can_clone_address()
{
var address = new Address
{
Id = 1,
FirstName = "FirstName 1",
LastName = "LastName 1",
Email = "Email 1",
Company = "Company 1",
CountryId = 3,
Country = new Country() { Id = 3, Name = "United States" },
StateProvinceId = 4,
StateProvince = new StateProvince() { Id = 4, Name = "LA" },
City = "City 1",
Address1 = "Address1",
Address2 = "Address2",
ZipPostalCode = "ZipPostalCode 1",
PhoneNumber = "PhoneNumber 1",
FaxNumber = "FaxNumber 1",
CreatedOnUtc = new DateTime(2010, 01, 01),
};
var newAddress = address.Clone() as Address;
newAddress.ShouldNotBeNull();
newAddress.Id.ShouldEqual(0);
newAddress.FirstName.ShouldEqual("FirstName 1");
newAddress.LastName.ShouldEqual("LastName 1");
newAddress.Email.ShouldEqual("Email 1");
newAddress.Company.ShouldEqual("Company 1");
newAddress.City.ShouldEqual("City 1");
newAddress.Address1.ShouldEqual("Address1");
newAddress.Address2.ShouldEqual("Address2");
newAddress.ZipPostalCode.ShouldEqual("ZipPostalCode 1");
newAddress.PhoneNumber.ShouldEqual("PhoneNumber 1");
newAddress.FaxNumber.ShouldEqual("FaxNumber 1");
newAddress.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
newAddress.Country.ShouldNotBeNull();
newAddress.CountryId.ShouldEqual(3);
newAddress.Country.Name.ShouldEqual("United States");
newAddress.StateProvince.ShouldNotBeNull();
newAddress.StateProvinceId.ShouldEqual(4);
newAddress.StateProvince.Name.ShouldEqual("LA");
}
示例11: Can_save_and_load_customer_with_address
public void Can_save_and_load_customer_with_address()
{
var customer = GetTestCustomer();
var address = new Address
{
FirstName = "Test",
Country = GetTestCountry(),
CreatedOnUtc = new DateTime(2010, 01, 01),
};
customer.AddAddress(address);
var fromDb = SaveAndLoadEntity(customer);
fromDb.ShouldNotBeNull();
fromDb.Addresses.Count.ShouldEqual(1);
fromDb.Addresses.First().FirstName.ShouldEqual("Test");
}
示例12: Can_remove_a_customer_address
public void Can_remove_a_customer_address()
{
var customer = GetTestCustomer();
var address = new Address { FirstName = "Test", Country = GetTestCountry(), CreatedOnUtc = new DateTime(2010, 01, 01) };
customer.AddAddress(address);
customer.SetBillingAddress(address);
var fromDb = SaveAndLoadEntity(customer);
fromDb.ShouldNotBeNull();
fromDb.Addresses.Count.ShouldEqual(1);
fromDb.BillingAddress.ShouldNotBeNull();
fromDb.RemoveAddress(address);
context.SaveChanges();
fromDb.Addresses.Count.ShouldEqual(0);
fromDb.BillingAddress.ShouldBeNull();
}
示例13: Can_save_and_load_address
public void Can_save_and_load_address()
{
var address = new Address
{
FirstName = "FirstName 1",
LastName = "LastName 1",
Email = "Email 1",
Company = "Company 1",
City = "City 1",
Address1 = "Address1",
Address2 = "Address2",
ZipPostalCode = "ZipPostalCode 1",
PhoneNumber = "PhoneNumber 1",
FaxNumber = "FaxNumber 1",
CustomAttributes = "CustomAttributes 1",
CreatedOnUtc = new DateTime(2010, 01, 01),
Country = GetTestCountry()
};
var fromDb = SaveAndLoadEntity(address);
fromDb.ShouldNotBeNull();
fromDb.FirstName.ShouldEqual("FirstName 1");
fromDb.LastName.ShouldEqual("LastName 1");
fromDb.Email.ShouldEqual("Email 1");
fromDb.Company.ShouldEqual("Company 1");
fromDb.City.ShouldEqual("City 1");
fromDb.Address1.ShouldEqual("Address1");
fromDb.Address2.ShouldEqual("Address2");
fromDb.ZipPostalCode.ShouldEqual("ZipPostalCode 1");
fromDb.PhoneNumber.ShouldEqual("PhoneNumber 1");
fromDb.FaxNumber.ShouldEqual("FaxNumber 1");
fromDb.CustomAttributes.ShouldEqual("CustomAttributes 1");
fromDb.CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
fromDb.Country.ShouldNotBeNull();
fromDb.Country.Name.ShouldEqual("United States");
}
示例14: GetEstimateShipping
public ActionResult GetEstimateShipping(EstimateShippingModel shippingModel, FormCollection form)
{
var cart = _workContext.CurrentCustomer.ShoppingCartItems
.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart)
.LimitPerStore(_storeContext.CurrentStore.Id)
.ToList();
//parse and save checkout attributes
ParseAndSaveCheckoutAttributes(cart, form);
var model = new ShoppingCartModel();
model.EstimateShipping.CountryId = shippingModel.CountryId;
model.EstimateShipping.StateProvinceId = shippingModel.StateProvinceId;
model.EstimateShipping.ZipPostalCode = shippingModel.ZipPostalCode;
PrepareShoppingCartModel(model, cart,setEstimateShippingDefaultAddress: false);
if (cart.RequiresShipping())
{
var address = new Address()
{
CountryId = shippingModel.CountryId,
Country = shippingModel.CountryId.HasValue ? _countryService.GetCountryById(shippingModel.CountryId.Value) : null,
StateProvinceId = shippingModel.StateProvinceId,
StateProvince = shippingModel.StateProvinceId.HasValue ? _stateProvinceService.GetStateProvinceById(shippingModel.StateProvinceId.Value) : null,
ZipPostalCode = shippingModel.ZipPostalCode,
};
GetShippingOptionResponse getShippingOptionResponse = _shippingService
.GetShippingOptions(cart, address, "", _storeContext.CurrentStore.Id);
if (!getShippingOptionResponse.Success)
{
foreach (var error in getShippingOptionResponse.Errors)
model.EstimateShipping.Warnings.Add(error);
}
else
{
if (getShippingOptionResponse.ShippingOptions.Count > 0)
{
foreach (var shippingOption in getShippingOptionResponse.ShippingOptions)
{
var soModel = new EstimateShippingModel.ShippingOptionModel()
{
Name = shippingOption.Name,
Description = shippingOption.Description,
};
//calculate discounted and taxed rate
Discount appliedDiscount = null;
decimal shippingTotal = _orderTotalCalculationService.AdjustShippingRate(shippingOption.Rate,
cart, out appliedDiscount);
decimal rateBase = _taxService.GetShippingPrice(shippingTotal, _workContext.CurrentCustomer);
decimal rate = _currencyService.ConvertFromPrimaryStoreCurrency(rateBase, _workContext.WorkingCurrency);
soModel.Price = _priceFormatter.FormatShippingPrice(rate, true);
model.EstimateShipping.ShippingOptions.Add(soModel);
}
//pickup in store?
if (_shippingSettings.AllowPickUpInStore)
{
var soModel = new EstimateShippingModel.ShippingOptionModel()
{
Name = _localizationService.GetResource("Checkout.PickUpInStore"),
Description = _localizationService.GetResource("Checkout.PickUpInStore.Description"),
Price = _priceFormatter.FormatShippingPrice(decimal.Zero, true)
};
model.EstimateShipping.ShippingOptions.Add(soModel);
}
}
else
{
model.EstimateShipping.Warnings.Add(_localizationService.GetResource("Checkout.ShippingIsNotAllowed"));
}
}
}
return View(model);
}
示例15: UpdateAddress
/// <summary>
/// Updates the address
/// </summary>
/// <param name="address">Address</param>
public virtual void UpdateAddress(Address address)
{
if (address == null)
throw new ArgumentNullException("address");
//some validation
if (address.CountryId == 0)
address.CountryId = null;
if (address.StateProvinceId == 0)
address.StateProvinceId = null;
_addressRepository.Update(address);
//event notification
_eventPublisher.EntityUpdated(address);
}