public ShippingAddressUserControlViewModel(ICheckoutDataRepository checkoutDataRepository, ILocationService locationService, IResourceLoader resourceLoader) { _address = new Address(); _checkoutDataRepository = checkoutDataRepository; _locationService = locationService; _resourceLoader = resourceLoader; }
public async Task<Order> CreateOrderAsync(string userId, ShoppingCart shoppingCart, Address shippingAddress, Address billingAddress, PaymentMethod paymentMethod, ShippingMethod shippingMethod) { Order order = new Order { UserId = userId, ShoppingCart = shoppingCart, ShippingAddress = shippingAddress, BillingAddress = billingAddress, PaymentMethod = paymentMethod, ShippingMethod = shippingMethod }; order.Id = await _orderService.CreateOrderAsync(order, _accountService.ServerCookieHeader); return order; }
private CheckoutDataViewModel CreateCheckoutData(Address address, string dataType) { return new CheckoutDataViewModel(address.Id, dataType == Constants.ShippingAddress ? _resourceLoader.GetString("ShippingAddress") : _resourceLoader.GetString("BillingAddress"), address.StreetAddress, string.Format(CultureInfo.CurrentUICulture, "{0}, {1} {2}", address.City, address.State, address.ZipCode), string.Format(CultureInfo.CurrentUICulture, "{0} {1}", address.FirstName, address.LastName), dataType == Constants.ShippingAddress ? new Uri(Constants.ShippingAddressLogo, UriKind.Absolute) : new Uri(Constants.BillingAddressLogo, UriKind.Absolute), dataType, address); }
public async Task CreateBasicOrderAsync(string userId, ShoppingCart shoppingCart, Address shippingAddress, Address billingAddress, PaymentMethod paymentMethod) { var basicShippingMethod = await _shippingMethodService.GetBasicShippingMethodAsync(); _currentOrder = await CreateOrderAsync(userId, shoppingCart, shippingAddress, billingAddress, paymentMethod, basicShippingMethod); _suspensionManagerState.SessionState[OrderKey] = _currentOrder; }
public void SetDefaultBillingAddress(Address address) { throw new NotImplementedException(); }
public async Task SettingUseShippingAddressToTrue_CopiesValuesFromShippingAddressToBilling() { var mockAddress = new Address() { FirstName = "TestFirstName", MiddleInitial = "TestMiddleInitial", LastName = "TestLastName", StreetAddress = "TestStreetAddress", OptionalAddress = "TestOptionalAddress", City = "TestCity", State = "TestState", ZipCode = "123456", Phone = "123456" }; var compareAddressesFunc = new Func<Address, Address, bool>((Address a1, Address a2) => { return a1.FirstName == a2.FirstName && a1.MiddleInitial == a2.MiddleInitial && a1.LastName == a2.LastName && a1.StreetAddress == a2.StreetAddress && a1.OptionalAddress == a2.OptionalAddress && a1.City == a2.City && a1.State == a2.State && a1.ZipCode == a2.ZipCode && a1.Phone == a2.Phone; }); var shippingAddressPageViewModel = new MockShippingAddressPageViewModel() { ValidateFormDelegate = () => true, ProcessFormDelegate = () => Task.Delay(0), Address = mockAddress }; var billingAddressPageViewModel = new MockBillingAddressPageViewModel() { ValidateFormDelegate = () => true }; billingAddressPageViewModel.ProcessFormDelegate = () => { // The Address have to be updated before the form is processed Assert.IsTrue(compareAddressesFunc(shippingAddressPageViewModel.Address, billingAddressPageViewModel.Address)); }; var paymentMethodPageViewModel = new MockPaymentMethodPageViewModel() { ValidateFormDelegate = () => true, ProcessFormDelegate = () => Task.Delay(0), }; var accountService = new MockAccountService() { GetSignedInUserAsyncDelegate = () => Task.FromResult(new UserInfo()) }; var orderRepository = new MockOrderRepository() { CreateBasicOrderAsyncDelegate = (userId, shoppingCart, shippingAddress, billingAddress, paymentMethod) => { // The Address information stored in the order must be the same Assert.IsTrue(compareAddressesFunc(shippingAddress, billingAddress)); return Task.FromResult<Order>(new Order()); } }; var shippingMethodService = new MockShippingMethodService() { GetBasicShippingMethodAsyncDelegate = () => Task.FromResult(new ShippingMethod()) }; var shoppingCartRepository = new MockShoppingCartRepository() { GetShoppingCartAsyncDelegate = () => Task.FromResult(new ShoppingCart(null)) }; var navigationService = new MockNavigationService() { NavigateDelegate = (a, b) => true }; var target = new CheckoutHubPageViewModel(navigationService, accountService, orderRepository, shoppingCartRepository, shippingAddressPageViewModel, billingAddressPageViewModel, paymentMethodPageViewModel, null, null, null); target.UseSameAddressAsShipping = true; await target.GoNextCommand.Execute(); }
public Address SaveBillingAddress(Address address) { throw new NotImplementedException(); }
public Task<Order> CreateOrderAsync(string userId, ShoppingCart shoppingCart, Address shippingAddress, Address billingAddress, PaymentMethod paymentMethod, ShippingMethod shippingMethod) { return CreateOrderAsyncDelegate(userId, shoppingCart, shippingAddress, billingAddress, paymentMethod, shippingMethod); }
private static bool IsMatchingAddress(Address firstAddress, Address secondAddress) { if (firstAddress.FirstName != secondAddress.FirstName) return false; if (firstAddress.MiddleInitial != secondAddress.MiddleInitial) return false; if (firstAddress.LastName != secondAddress.LastName) return false; if (firstAddress.StreetAddress != secondAddress.StreetAddress) return false; if (firstAddress.OptionalAddress != secondAddress.OptionalAddress) return false; if (firstAddress.City != secondAddress.City) return false; if (firstAddress.State != secondAddress.State) return false; if (firstAddress.ZipCode != secondAddress.ZipCode) return false; if (firstAddress.Phone != secondAddress.Phone) return false; return true; }
public void SetDefaultBillingAddress(Address address) { if (address == null) { throw new ArgumentNullException("address", "address is null"); } _settingsStoreService.SaveValue(Constants.Default, Constants.BillingAddress, address.Id); }
// <snippet502> public Address SaveBillingAddress(Address address) { address.Id = Guid.NewGuid().ToString(); Address savedAddress = GetAllBillingAddresses().FirstOrDefault(c => IsMatchingAddress(c, address)); if (savedAddress == null) { _billingAddresses.Add(address); _settingsStoreService.SaveEntity(Constants.BillingAddress, address.Id, address); savedAddress = address; } // If no default value is stored, use this one if (GetDefaultBillingAddress() == null) { SetDefaultBillingAddress(savedAddress); } return savedAddress; }