Beispiel #1
0
        public async Task <WorkflowResult> AddPaymentAsync(decimal amount, Guid userId)
        {
            using (TransactionScope transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                try
                {
                    WorkflowResult workflowResult = await _decorated.AddPaymentAsync(amount, userId);

                    if (workflowResult.Success)
                    {
                        transactionScope.Complete();
                    }
                    else
                    {
                        Transaction.Current.Rollback();
                    }
                    return(workflowResult);
                }
                catch (Exception ex)
                {
                    Transaction.Current.Rollback();
                    int errorId = await _applicationLog.LogExceptionAsync(ex);

                    return(new WorkflowResult(
                               new[] {
                        Resources.Resource.InternalServerErrorMessage,
                        string.Format(Resources.Resource.GeneratedErrorIdMessage, errorId)
                    }));
                }
            }
        }