/// <returns>A task that represents the asynchronous operation</returns> public override async Task <IActionResult> CategoryDelete(int id) { //ensure that Avalara tax provider is active if (!await _taxPluginManager.IsPluginActiveAsync(AvalaraTaxDefaults.SystemName)) { return(new NullJsonResult()); } if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } //try to get a tax category with the specified id var taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id); if (taxCategory == null) { throw new ArgumentException("No tax category found with the specified id"); } //delete generic attributes await _genericAttributeService.SaveAttributeAsync <string>(taxCategory, AvalaraTaxDefaults.TaxCodeDescriptionAttribute, null); await _genericAttributeService.SaveAttributeAsync <string>(taxCategory, AvalaraTaxDefaults.TaxCodeTypeAttribute, null); await _taxCategoryService.DeleteTaxCategoryAsync(taxCategory); return(new NullJsonResult()); }
/// <returns>A task that represents the asynchronous operation</returns> public virtual async Task <IActionResult> CategoryDelete(int id) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageTaxSettings)) { return(AccessDeniedView()); } //try to get a tax category with the specified id var taxCategory = await _taxCategoryService.GetTaxCategoryByIdAsync(id) ?? throw new ArgumentException("No tax category found with the specified id", nameof(id)); await _taxCategoryService.DeleteTaxCategoryAsync(taxCategory); return(new NullJsonResult()); }