public static void Setup()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["DDDCinema"].ConnectionString;

            using (var movieContext = new CinemaContext(connectionString))
            using (var promotionsContext = new PromotionsContext(connectionString))
            using (var infrastructureContext = new InfrastructureContext(connectionString))
            {
                Database.SetInitializer(new MoviesDbInitializer());
                movieContext.Database.Initialize(true);

                Database.SetInitializer(new DropCreateDatabaseIfModelChanges<PromotionsContext>());
                promotionsContext.Database.Initialize(true);

                Database.SetInitializer(new DropCreateDatabaseIfModelChanges<InfrastructureContext>());
                infrastructureContext.Database.Initialize(true);
            }
        }
        public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
        {
            if (bundle.JobDetail.JobType == typeof(EmailSendingJob))
            {
                var context = new InfrastructureContext("DDDCinema");
                var notificationRepository = new EfNotificationRepository(context);
                var job = new EmailSendingJob(notificationRepository, new SmtpMailSender());
                return new TransactionalJob(job, context);
            }

            if (bundle.JobDetail.JobType == typeof(SmsSendingJob))
            {
                var context = new InfrastructureContext("DDDCinema");
                var notificationRepository = new EfNotificationRepository(context);
                var job = new SmsSendingJob(notificationRepository, new GateSmsSender());
                return new TransactionalJob(job, context);
            }

            throw new InvalidOperationException("Not supported job type");
        }
 public TransactionalJob(IJob job, InfrastructureContext context)
 {
     _innerJob = job;
     _context = context;
 }