Ejemplo n.º 1
0
 private async Task SetCountryByAddressAsync(CartContext cartContext, Customers.Address address)
 {
     //Check if the country in the address is same as channel has.
     if (address != null && !string.IsNullOrEmpty(address.Country) && !address.Country.Equals(_requestModelAccessor.RequestModel.CountryModel.Country.Id, StringComparison.CurrentCultureIgnoreCase))
     {
         var country = _countryService.Get(address.Country);
         //Check if country is connected to the channel
         if (country != null && _requestModelAccessor.RequestModel.ChannelModel.Channel.CountryLinks.Any(x => x.CountrySystemId == country.SystemId))
         {
             // Set user's country to the channel
             await cartContext.SelectCountryAsync(new SelectCountryArgs { CountryCode = country.Id });
         }
     }
 }