Пример #1
0
        public async Task <IActionResult> GetForceUsers()
        {
            List <TestProject.NewApplication5.Application.DTOs.ForceUserQueryService_TestService.ForceUser> result = default(List <TestProject.NewApplication5.Application.DTOs.ForceUserQueryService_TestService.ForceUser>);
            var tso = new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            };

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, tso, TransactionScopeAsyncFlowOption.Enabled))
                {
                    var appServiceResult = await _appService.GetForceUsers();

                    result = appServiceResult;

                    await _dbContext.SaveChangesAsync();

                    ts.Complete();
                }
            }
            catch (Exception e)
            {
                return(StatusCode(500, e));
            }

            return(Ok(result));
        }
Пример #2
0
        public async Task <IActionResult> UpdateForceUser([FromBody] TestProject.NewApplication5.Application.DTOs.ForceUsers_TestService.UpdateForceUser updateForceUserDto)
        {
            var tso = new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            };

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, tso, TransactionScopeAsyncFlowOption.Enabled))
                {
                    await _appService.UpdateForceUser(updateForceUserDto);

                    await _dbContext.SaveChangesAsync();

                    ts.Complete();
                }
            }
            catch (Exception e)
            {
                return(StatusCode(500, e));
            }

            return(Ok());
        }
Пример #3
0
        public async Task <IActionResult> CreateAccount(string firstName, string lastName, string email, string password)
        {
            var tso = new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadCommitted
            };

            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, tso, TransactionScopeAsyncFlowOption.Enabled))
                {
                    await _appService.CreateAccount(firstName, lastName, email, password);

                    await _dbContext.SaveChangesAsync();

                    ts.Complete();
                }
            }
            catch (Exception e)
            {
                return(StatusCode(500, e));
            }

            return(Ok());
        }