protected virtual async Task UpdateShippingAddress(Overture.ServiceModel.Orders.Cart cart, AddressViewModel addressViewModel) { if (addressViewModel == null) { return; } var shipment = cart.Shipments.FirstOrDefault(); if (shipment == null) { return; } var newAddress = CreateAddressFromViewModel(addressViewModel); var isShippingChanged = shipment.Address == null || !IsEqual(shipment.Address, newAddress); shipment.Address = newAddress; await ShippingMethodViewService.EstimateShippingAsync(new EstimateShippingParam { Cart = cart, CultureInfo = CultureInfo.GetCultureInfo(cart.CultureName), //TODO: Fix me ForceUpdate = isShippingChanged }).ConfigureAwait(false); }
protected virtual async Task UpdateRegisteredShippingAddress(Overture.ServiceModel.Orders.Cart cart, RegisteredShippingAddressViewModel registeredShippingAddressViewModel) { if (registeredShippingAddressViewModel == null) { return; } if (registeredShippingAddressViewModel.ShippingAddressId == Guid.Empty) { return; } var shipment = cart.Shipments.FirstOrDefault(); if (shipment == null) { return; } var newAddress = await AddressRepository.GetAddressByIdAsync(registeredShippingAddressViewModel.ShippingAddressId).ConfigureAwait(false); var isShippingChanged = shipment.Address == null || !IsEqual(shipment.Address, newAddress); if (isShippingChanged) { shipment.Address = newAddress; shipment.Address.PropertyBag[AddressBookIdPropertyBagKey] = newAddress.Id; shipment.Address.Id = Guid.Empty; } //In the case the user didn't do estimate shipping before await ShippingMethodViewService.EstimateShippingAsync(new EstimateShippingParam { Cart = cart, CultureInfo = CultureInfo.GetCultureInfo(cart.CultureName), //TODO: Fix me ForceUpdate = isShippingChanged }).ConfigureAwait(false); }