public async Task <WorkflowResult> DeletePriceDetailAsync(int priceDetailId) { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { try { WorkflowResult workflowResult = await _decorated.DeletePriceDetailAsync(priceDetailId); if (workflowResult.Success) { transactionScope.Complete(); } else { Transaction.Current.Rollback(); } return(workflowResult); } catch { Transaction.Current.Rollback(); throw; } } }
public async Task <ActionResult> OnPostDeletePriceDetailAsync( [FromServices] IProductComponentFactory productComponentFactory, int priceDetailId) { try { ModelState.Clear(); if (priceDetailId <= 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.DeletePriceDetailAsync(priceDetailId); 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); } }