public async Task <OperationResult <StaffTitle> > ReadAsync(Guid id)
        {
            try
            {
                var transactionOptions = new TransactionOptions
                {
                    IsolationLevel = IsolationLevel.ReadCommitted,
                    Timeout        = TimeSpan.FromSeconds(30)
                };
                using (var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var res = await _dao.ReadAsync(id);

                    transactionScope.Complete();
                    return(new OperationResult <StaffTitle>()
                    {
                        Success = true, Result = res
                    });
                }
            }
            catch (Exception e)
            {
                return(new OperationResult <StaffTitle>()
                {
                    Success = false, Exception = e
                });
            }
        }
Exemple #2
0
        public async virtual Task <OperationResult <StaffTitle> > ReadAsync(Guid id)
        {
            try
            {
                using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled);
                var result = await _dao.ReadAsync(id);

                transactionScope.Complete();
                return(new OperationResult <StaffTitle> {
                    Result = result, Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult <StaffTitle>()
                {
                    Success = false, Exception = e
                });
            }
        }
Exemple #3
0
        public async Task <OperationResult <StaffTitle> > ReadAsync(Guid id)
        {
            try
            {
                using (var ts = new TransactionScope(TransactionScopeOption.Required, opts, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var result = await _dao.ReadAsync(id);

                    ts.Complete();
                    return(new OperationResult <StaffTitle>()
                    {
                        Success = true, Result = result
                    });
                }
            }
            catch (Exception e)
            {
                return(new OperationResult <StaffTitle>()
                {
                    Success = false, Exception = e
                });
            }
        }