private async Task<Action> ResolveNavigationActionAsync()
{
Action navigateAction = null;
var navigationServiceReference = _navigationService;
// Retrieve the default information for the Order
var defaultShippingAddress = await _checkoutDataRepository.GetDefaultShippingAddressAsync();
var defaultBillingAddress = await _checkoutDataRepository.GetDefaultBillingAddressAsync();
var defaultPaymentMethod = await _checkoutDataRepository.GetDefaultPaymentMethodAsync();
if (defaultShippingAddress == null || defaultBillingAddress == null || defaultPaymentMethod == null)
{
// Navigate to the CheckoutHubPage to fill the missing default information
navigateAction = () => navigationServiceReference.Navigate("CheckoutHub", null);
}
else
{
// Create the Order with the current information. Then navigate to the CheckoutSummaryPage
var shoppingCartReference = _shoppingCart;
var orderRepositoryReference = _orderRepository;
var accountServiceReference = _accountService;
navigateAction = async () =>
{
var user = accountServiceReference.SignedInUser;
await orderRepositoryReference.CreateBasicOrderAsync(user.UserName,
shoppingCartReference,
defaultShippingAddress,
defaultBillingAddress,
defaultPaymentMethod);
navigationServiceReference.Navigate("CheckoutSummary", null);
};
}
return navigateAction;
}