예제 #1
0
        public async Task <IActionResult> PublishWithTranscation()
        {
            using (var trans = _pgDbContext.Database.BeginTransaction(_capPublisher, true))
            {
                try
                {
                    var apiConfig = new ApiConfig
                    {
                        ApiName      = "111122",
                        ApiDesc      = "223",
                        ReturnType   = "1",
                        ReturnExpect = "1",
                        IsAsync      = true,
                        OperCode     = "999",
                        OperTime     = DateTime.Now
                    };

                    await _pgDbContext.ApiConfig.AddAsync(apiConfig);

                    await _pgDbContext.SaveChangesAsync();

                    _capPublisher.Publish("sample.rabbitmq.demo.transcation", apiConfig);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                }

                return(Ok());
            }
        }
예제 #2
0
 public async Task <int> PgComplete()
 {
     return(await _pgContext.SaveChangesAsync());
 }
예제 #3
0
 public async Task AddRangeAsync(IEnumerable <UserRole> userRoles)
 {
     dbContext.AddRange(userRoles);
     await dbContext.SaveChangesAsync().ConfigureAwait(false);
 }
 public async Task AddRangeAsync(IEnumerable <RolePermission> rolePermissions)
 {
     dbContext.AddRange(rolePermissions);
     await dbContext.SaveChangesAsync().ConfigureAwait(false);
 }
예제 #5
0
 public async Task SaveAsync()
 {
     await _context.SaveChangesAsync();
 }
 public async Task <int> SaveChanges()
 {
     return(await Db.SaveChangesAsync());
 }