public async Task <WorkflowResult> DeletePriceCategoryAsync(int categoryId) { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { try { WorkflowResult workflowResult = await _decorated.DeletePriceCategoryAsync(categoryId); if (workflowResult.Success) { transactionScope.Complete(); } else { Transaction.Current.Rollback(); } return(workflowResult); } catch { Transaction.Current.Rollback(); throw; } } }
public async Task <ActionResult> OnPostDeletePriceCategoryAsync( [FromServices] IProductComponentFactory productComponentFactory, int priceCategoryId) { try { ModelState.Clear(); if (priceCategoryId <= 0) { ModelState.TryAddModelError("", "Acción Invalida"); return(Page()); } Option <IProductComponent> productResult = await productComponentFactory.CurrentAsync(Id); if (!productResult.Any()) { ModelState.TryAddModelError("", "Error, registro no existe en bd"); } IProductComponent product = productResult.Single(); WorkflowResult result = await product.DeletePriceCategoryAsync(priceCategoryId); if (!result.Success) { for (int i = 0; i < result.Errors.Length; i++) { ModelState.TryAddModelError("", result.Errors[i]); } } return(Page()); } finally { AditionalService = new AddAditionalServiceRequest(); Product = await _productQueryComponent.ProductAsync(Id); } }