本文整理汇总了C#中SmartStore.Core.Domain.Customers.Customer.RemoveAddress方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.RemoveAddress方法的具体用法?C# Customer.RemoveAddress怎么用?C# Customer.RemoveAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartStore.Core.Domain.Customers.Customer
的用法示例。
在下文中一共展示了Customer.RemoveAddress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: FindAndApplyAddress
public bool FindAndApplyAddress(OrderReferenceDetails details, Customer customer, bool isShippable, bool forceToTakeAmazonAddress)
{
// PlaceOrder requires billing address but we don't get one from Amazon here. so use shipping address instead until we get it from amazon.
bool countryAllowsShipping, countryAllowsBilling;
var amazonAddress = new SmartStore.Core.Domain.Common.Address()
{
CreatedOnUtc = DateTime.UtcNow
};
details.ToAddress(amazonAddress, _countryService, _stateProvinceService, out countryAllowsShipping, out countryAllowsBilling);
if (isShippable && !countryAllowsShipping)
return false;
if (amazonAddress.Email.IsEmpty())
amazonAddress.Email = customer.Email;
if (forceToTakeAmazonAddress)
{
// first time to get in touch with an amazon address
var existingAddress = customer.Addresses.ToList().FindAddress(amazonAddress, true);
if (existingAddress == null)
{
customer.Addresses.Add(amazonAddress);
customer.BillingAddress = amazonAddress;
}
else
{
customer.BillingAddress = existingAddress;
}
}
else
{
if (customer.BillingAddress == null)
{
customer.Addresses.Add(amazonAddress);
customer.BillingAddress = amazonAddress;
}
// we already have the address but it is uncomplete, so just complete it
details.ToAddress(customer.BillingAddress, _countryService, _stateProvinceService, out countryAllowsShipping, out countryAllowsBilling);
// but now we could have dublicates
int newAddressId = customer.BillingAddress.Id;
var addresses = customer.Addresses.Where(x => x.Id != newAddressId).ToList();
var existingAddress = addresses.FindAddress(customer.BillingAddress, false);
if (existingAddress != null)
{
// remove the new and take the old one
customer.RemoveAddress(customer.BillingAddress);
customer.BillingAddress = existingAddress;
try
{
_addressService.DeleteAddress(newAddressId);
}
catch (Exception exc)
{
exc.Dump();
}
}
}
customer.ShippingAddress = (isShippable ? customer.BillingAddress : null);
return true;
}