public async Task <WorkflowResult> SaveAsync(string description) { using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { try { WorkflowResult workflowResult = await _decorated.SaveAsync(description); if (workflowResult.Success) { transactionScope.Complete(); } else { Transaction.Current.Rollback(); } return(workflowResult); } catch { Transaction.Current.Rollback(); throw; } } }
public async Task <ActionResult> OnPostAsync([FromServices] IProductComponentFactory productComponentFactory) { if (!ModelState.IsValid) { return(Page()); } IProductComponent product = productComponentFactory.New(); WorkflowResult result = await product.SaveAsync(Product.Description); if (!result.Success) { for (int i = 0; i < result.Errors.Length; i++) { ModelState.TryAddModelError("", result.Errors[i]); } return(Page()); } return(RedirectToPage("./Details", new { id = product.ProductId })); }