Example #1
0
        public virtual async Task <TaxDisplayType> SetTaxDisplayType(TaxDisplayType taxDisplayType)
        {
            //whether customers are allowed to select tax display type
            if (!_taxSettings.AllowCustomersToSelectTaxDisplayType)
            {
                return(await Task.FromResult(taxDisplayType));
            }

            //save passed value
            await _userFieldService.SaveField(CurrentCustomer,
                                              SystemCustomerFieldNames.TaxDisplayTypeId, (int)taxDisplayType, CurrentStore.Id);

            //then reset the cache value
            _cachedTaxDisplayType = taxDisplayType;
            return(taxDisplayType);
        }
        public virtual async Task <TaxDisplayType> SetTaxDisplayType(TaxDisplayType taxDisplayType)
        {
            //whether customers are allowed to select tax display type
            if (!_taxSettings.AllowCustomersToSelectTaxDisplayType)
            {
                return(await Task.FromResult(taxDisplayType));
            }

            //save passed value
            await _genericAttributeService.SaveAttribute(this.CurrentCustomer,
                                                         SystemCustomerAttributeNames.TaxDisplayTypeId, (int)taxDisplayType, _storeContext.CurrentStore.Id);

            //then reset the cache value
            _cachedTaxDisplayType = taxDisplayType;
            return(taxDisplayType);
        }
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task SetTaxDisplayTypeAsync(TaxDisplayType taxDisplayType)
        {
            //whether customers are allowed to select tax display type
            if (!_taxSettings.AllowCustomersToSelectTaxDisplayType)
            {
                return;
            }

            //save passed value
            var customer = await GetCurrentCustomerAsync();

            var store = await _storeContext.GetCurrentStoreAsync();

            await _genericAttributeService
            .SaveAttributeAsync(customer, NopCustomerDefaults.TaxDisplayTypeIdAttribute, (int)taxDisplayType, store.Id);

            //then reset the cached value
            _cachedTaxDisplayType = null;
        }
Example #4
0
        public virtual async Task <TaxDisplayType> SetTaxDisplayType(Customer customer)
        {
            TaxDisplayType taxDisplayType;

            if (_taxSettings.AllowCustomersToSelectTaxDisplayType && customer != null)
            {
                var taxDisplayTypeId = customer.GetUserFieldFromEntity <int>(SystemCustomerFieldNames.TaxDisplayTypeId, CurrentStore.Id);
                taxDisplayType = (TaxDisplayType)taxDisplayTypeId;
            }
            else
            {
                //or get the default tax display type
                taxDisplayType = _taxSettings.TaxDisplayType;
            }
            //cache the value
            _cachedTaxDisplayType = taxDisplayType;

            return(await Task.FromResult(_cachedTaxDisplayType));
        }
Example #5
0
        public virtual async Task <TaxDisplayType> SetTaxDisplayType(Customer customer)
        {
            TaxDisplayType taxDisplayType;

            //whether customers are allowed to select tax display type
            if (_taxSettings.AllowCustomersToSelectTaxDisplayType && customer != null)
            {
                //try to get previously saved tax display type
                var taxDisplayTypeId = customer.GetAttributeFromEntity <int>(SystemCustomerAttributeNames.TaxDisplayTypeId, _storeContext.CurrentStore.Id);
                taxDisplayType = (TaxDisplayType)taxDisplayTypeId;
            }
            else
            {
                //or get the default tax display type
                taxDisplayType = _taxSettings.TaxDisplayType;
            }

            //cache the value
            _cachedTaxDisplayType = taxDisplayType;

            return(await Task.FromResult(_cachedTaxDisplayType));
        }