Exemplo n.º 1
0
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            try
            {
                _dbContext.BeginTransaction();

                await next();

                await _dbContext.CommitTransactionAsync();
            }
            catch (Exception)
            {
                _dbContext.RollbackTransaction();
                throw;
            }
        }
Exemplo n.º 2
0
            public async Task Handle(Command message)
            {
                var scheduledForward =
                    new ScheduledForward {
                    TeamId = message.TeamId, PhoneNumber = message.PhoneNumber, When = message.When
                };

                db.BeginTransaction();
                db.ScheduledForwards.Add(scheduledForward);
                await db.SaveChangesAsync();

                scheduledForward.ScheduleId =
                    BackgroundJob.Schedule <IForwarder>(f => f.ApplyScheduledForward(scheduledForward.Id, null), message.When);

                await db.SaveChangesAsync();

                await db.CommitTransactionAsync();
            }