コード例 #1
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public async Task <IActionResult> RatesByCountryStateZipList(ConfigurationModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTaxSettings))
            {
                return(await AccessDeniedDataTablesJson());
            }

            var records = await _abcTaxService.GetAllTaxRatesAsync(searchModel.Page - 1, searchModel.PageSize);

            var gridModel = await new CountryStateZipListModel().PrepareToGridAsync(searchModel, records, () =>
            {
                return(records.SelectAwait(async record => new CountryStateZipModel
                {
                    Id = record.Id,
                    StoreId = record.StoreId,
                    StoreName = (await _storeService.GetStoreByIdAsync(record.StoreId))?.Name ?? "*",
                    TaxCategoryId = record.TaxCategoryId,
                    TaxCategoryName = (await _taxCategoryService.GetTaxCategoryByIdAsync(record.TaxCategoryId))?.Name ?? string.Empty,
                    CountryId = record.CountryId,
                    CountryName = (await _countryService.GetCountryByIdAsync(record.CountryId))?.Name ?? "Unavailable",
                    StateProvinceId = record.StateProvinceId,
                    StateProvinceName = (await _stateProvinceService.GetStateProvinceByIdAsync(record.StateProvinceId))?.Name ?? "*",

                    Zip = !string.IsNullOrEmpty(record.Zip) ? record.Zip : "*",
                    Percentage = record.Percentage,
                    IsTaxJarEnabled = record.IsTaxJarEnabled
                }));
            });

            return(Json(gridModel));
        }
コード例 #2
0
        /// <summary>
        /// Handle tax category deleted event
        /// </summary>
        /// <param name="eventMessage">Event message</param>
        /// <returns>A task that represents the asynchronous operation</returns>
        public async Task HandleEventAsync(EntityDeletedEvent <TaxCategory> eventMessage)
        {
            var taxCategory = eventMessage?.Entity;

            if (taxCategory == null)
            {
                return;
            }

            //delete an appropriate record when tax category is deleted
            var recordsToDelete = (await _abcTaxService.GetAllTaxRatesAsync()).Where(taxRate => taxRate.TaxCategoryId == taxCategory.Id).ToList();

            foreach (var taxRate in recordsToDelete)
            {
                await _abcTaxService.DeleteTaxRateAsync(taxRate);
            }
        }