Exemplo n.º 1
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public async Task <IActionResult> DeleteRateByCountryStateZip(int id)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTaxSettings))
            {
                return(Content("Access denied"));
            }

            var taxRate = await _abcTaxService.GetTaxRateByIdAsync(id);

            if (taxRate != null)
            {
                await _abcTaxService.DeleteTaxRateAsync(taxRate);
            }

            return(new NullJsonResult());
        }
Exemplo n.º 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);
            }
        }