public async Task <decimal> GetTaxJarRateAsync(Address address) { var zip = address.ZipPostalCode?.Trim() ?? string.Empty; var street = address.Address1; var city = address.City; var country = (await _countryService.GetCountryByIdAsync(address.CountryId.Value))?.TwoLetterIsoCode; var cacheKey = _staticCacheManager.PrepareKeyForDefaultCache( AbcTaxTaxjarRateKey, zip, street, city, country ); return(await _staticCacheManager.GetAsync(cacheKey, () => { var taxjarApi = new TaxjarApi(_abcTaxSettings.TaxJarAPIToken); var rates = taxjarApi.RatesForLocation(zip, new { street = street, city = city, country = country }); // if US or Canada, CountryName will be populated return !string.IsNullOrWhiteSpace(rates.Country) ? rates.CombinedRate * 100 : rates.StandardRate * 100; })); }
public Task <Unit> Handle(CreateUpdateAddressCommand request, CancellationToken cancellationToken) { Nop.Core.Domain.Common.Address address = null; if (!request.Id.HasValue) { address = _addressService.Insert( AutoMapperConfiguration.Mapper.Map <Nop.Core.Domain.Common.Address>(request)); } else { address = _addressService.GetAddress(request.Id.Value); var addrToUpdate = AutoMapperConfiguration.Mapper.Map(request, address); _addressService.Update(addrToUpdate); } var customerAddress = _customerService.GetAddressesByCustomerId(request.UserId).FirstOrDefault(a => a.Id == address?.Id); var customer = _customerService.GetCustomer(request.UserId); try { if (customerAddress is null) { _customerService.InsertCustomerAddress(customer, address); } } catch (ArgumentNullException ex) { throw new ResourcesNotFoundException("Not found required resources.", ex); } return(Unit.Task); }
public void Delete(Nop.Core.Domain.Common.Address address) { _addressRepository.Delete(address); }
public void Update(Nop.Core.Domain.Common.Address address) { _addressRepository.Update(address); }
public Nop.Core.Domain.Common.Address Insert(Nop.Core.Domain.Common.Address address) { _addressRepository.Insert(address); return(_addressRepository.GetById(address.Id)); }