Example #1
0
 public VmTicketHistoryRepository(
     IRepository <VmTicketHistory> repository,
     AppVersionContext context,
     IApiIdentity apiIdentity) : base(context, apiIdentity)
 {
     _repository = repository;
     _context    = context;
 }
Example #2
0
        public VmTicketRepository(
            IAzureVmManagementService azureVmManagementService,
            IRepository <VmTicket> repository,
            AppVersionContext context,
            IVmSdkService vmSdkService,
            IConfiguration configuration,
            IApiIdentity apiIdentity) : base(context, apiIdentity)
        {
            _azureVmManagementService = azureVmManagementService;
            _repository    = repository;
            _context       = context;
            _vmSdkService  = vmSdkService;
            _configuration = configuration;
            _userId        = ApiIdentity.GetUserName();

            VmRebootDelay = configuration.GetValue <int>("VmRebootDelay");
        }
Example #3
0
 public AppVersionController(AppVersionContext _context)
 {
     context = _context;
 }
Example #4
0
        public static void Main(string[] args)
        {
            //CreateHostBuilder(args).Build().Run();

            var host = CreateHostBuilder(args).Build();

            // migrate the database.  Best practice = in Main, using service scope
            using (var scope = host.Services.CreateScope())
            {
                ILogger <Program> logger     = null;
                AppVersionContext context    = null;
                TokenCacheContext tokenCache = null;

                try
                {
                    logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >();
                }
                catch { }

                try
                {
                    logger?.LogInformation($"CreateHostBuilder Started {nameof(AppVersionContext)} ");

                    context = scope.ServiceProvider.GetService <AppVersionContext>();
                    context?.Database.Migrate();
                    logger?.LogInformation($"Called Migrate on {nameof(AppVersionContext)}");
                }
                catch (Exception ex)
                {
                    logger?.LogError(ex, $"An error occurred while migrating the database {nameof(AppVersionContext)}");
                    //try
                    //{
                    //    //context?.Database.EnsureDeleted(); logger?.LogInformation("Called EnsureCreated");
                    //    context?.Database.Migrate(); logger?.LogInformation("Called Migrate");
                    //}
                    //catch (Exception e)
                    //{
                    //    logger?.LogError(e, "An error occurred while migrating the database.");
                    //}
                }

                try
                {
                    tokenCache = scope.ServiceProvider.GetService <TokenCacheContext>();
                    tokenCache?.Database.Migrate();
                    logger?.LogInformation($"Called Migrate on {nameof(TokenCacheContext)}");
                }
                catch (Exception ex)
                {
                    logger?.LogError(ex, $"An error occurred while migrating the database {nameof(TokenCacheContext)} .");
                }

                try
                {
                    //TODO MOVE
                    var billingContext = scope.ServiceProvider.GetService <CustomersDbContext>();
                    billingContext?.Database.Migrate();
                    logger?.LogInformation($"Called Migrate on {nameof(CustomersDbContext)}");
                    CustomersDbContext.SeedCustomersDb(billingContext);
                }
                catch (Exception ex)
                {
                    logger?.LogError(ex, $"An error occurred while migrating the database {nameof(CustomersDbContext)} .");
                }

                // run the web app
                host.Run();
            }
        }
Example #5
0
 public AppRepository(AppVersionContext context, IApiIdentity apiIdentity) : base(context, apiIdentity)
 {
 }
Example #6
0
 public VersionRepository(IRepository <AppVersion> repository)
 {
     _repository = repository;
     _context    = _repository.DatabaseContext as AppVersionContext;
 }
Example #7
0
 public TicketRepository(IRepository <Ticket> repository, AppVersionContext context, IApiIdentity apiIdentity) : base(context, apiIdentity)
 {
     _repository = repository;
     _context    = context;
 }