protected async Task <Guid> GetOrCreateDefaultCustomerId()
        {
            var customer = await _userContext.GetCurrentContact();

            if (customer == null)
            {
                return(Guid.NewGuid());
            }
            return(customer.ContactId);
        }
Exemple #2
0
        public async Task GetOrCreateDefaultShippingAddress(CartView cart)
        {
            if (!HasShippingAddressSelected(cart))
            {
                var shipping = GetOrCreateDefaultShipping(cart);
                shipping.ShippingAddress = new AddressView();
                var currentContact = await _userContext.GetCurrentContact();

                if (currentContact != null)
                {
                    var selectedContact = currentContact.ShippingAddress != null ? currentContact.ShippingAddress : currentContact.BillingAddress;
                    if (selectedContact != null)
                    {
                        shipping.ShippingAddress = new AddressView()
                        {
                            CityOrTownOrVillage = selectedContact.CityOrTownOrVillage,
                            CountryCode         = string.Empty,
                            CountryName         = string.Empty,
                            Email                = selectedContact.Email,
                            FirstName            = selectedContact.FirstName,
                            LastName             = selectedContact.LastName,
                            PhoneNumber          = selectedContact.PhoneNumber,
                            PostCode             = selectedContact.PostCode,
                            Prefecture           = selectedContact.Prefecture,
                            StreetAndHouseNumber = selectedContact.StreetAndHouseNumber
                        };
                    }
                }
            }
        }