// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var dbUser = Environment.GetEnvironmentVariable("MP_API_DB_USER"); var dbPassword = Environment.GetEnvironmentVariable("MP_API_DB_PASSWORD"); var hangfireConnectionString = Configuration["ConnectionStrings:Hangfire"]; hangfireConnectionString = String.Format(hangfireConnectionString, dbUser, dbPassword); services.AddHangfire(config => config.UseSqlServerStorage(hangfireConnectionString)); services.AddMvc(); services.AddAutoMapper(); services.AddDistributedMemoryCache(); services.AddRouting(options => options.LowercaseUrls = true); services.AddCors(); // Dependency Injection CrossroadsWebCommonConfig.Register(services); // Service Layer services.AddSingleton <IBatchService, BatchService>(); services.AddSingleton <IDonationService, DonationService>(); services.AddSingleton <IDepositService, DepositService>(); services.AddSingleton <IPaymentEventService, PaymentEventService>(); services.AddSingleton <IPushpayService, PushpayService>(); services.AddSingleton <IPushpayClient, PushpayClient>(); services.AddSingleton <IPushpayTokenService, PushpayTokenService>(); // Repo Layer services.AddSingleton <IBatchRepository, BatchRepository>(); services.AddSingleton <IDepositRepository, DepositRepository>(); services.AddSingleton <IDonationRepository, DonationRepository>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <ActivityValidator>());; services.AddRouting(options => options.LowercaseUrls = false); services.AddCors(); CrossroadsWebCommonConfig.Register(services); services.AddSingleton <ILoggerFactory, LoggerFactory>(); services.AddLogging(); services.AddSingleton <IClock, Clock>(); services.AddSingleton <IGenerateCombGuid, GenerateCombGuid>(); services.AddSingleton <ISleep, Sleeper>(); services.AddSingleton <IJsonSerializer, JsonSerializer>(); services.AddSingleton <IMinistryPlatformContactRepository, MinistryPlatformContactRepository>(); services.AddSingleton <ISyncMpContactsToHubSpotService, SyncMpContactsToHubSpotService>(); services.AddSingleton <IPrepareMpDataForHubSpot, PrepareMpDataForHubSpot>(); services.AddSingleton(sp => new MongoClient(Configuration["MONGO_DB_CONN"]).GetDatabase("hubspotsync")); // Mongo stores UTC by default services.AddSingleton <IJobRepository, JobRepository>(); services.AddSingleton <IConfigurationService, ConfigurationService>(); services.AddSingleton <ICleanUpActivity, CleanUpActivity>(); services.AddSingleton(Configuration); services.Configure <InauguralSync>(Configuration.GetSection("InauguralSync")); services.Configure <DocumentDbSettings>(Configuration.GetSection("DocumentDbSettings")); services.AddSingleton <ICreateOrUpdateContactsInHubSpot>(context => new CreateOrUpdateContactsInHubSpot( new HttpClientFacade( new HttpClient { BaseAddress = new Uri(Configuration["HubSpotApiBaseUrl"]) }, context.GetService <IJsonSerializer>(), context.GetService <ILogger <HttpClientFacade> >()), context.GetService <IClock>(), context.GetService <IJsonSerializer>(), context.GetService <ISleep>(), Configuration["TEST_HUBSPOT_API_KEY"] ?? Configuration["HUBSPOT_API_KEY"], // env variable context.GetService <ILogger <CreateOrUpdateContactsInHubSpot> >())); services.AddSingleton(provider => new MapperConfiguration(cfg => { cfg.AddProfile(new MappingProfile(provider.GetService <IConfigurationService>())); }).CreateMapper()); services.AddBackgroundQueue(maxConcurrentCount: 1, millisecondsToWaitBeforePickingUpTask: 1000, onException: exception => throw new Exception("An exception occurred while a background process was executing.", exception)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "crds-service-auth", Version = "v1" }); }); string vaultRoleId = System.Environment.GetEnvironmentVariable("VAULT_ROLE_ID"); string vaultSecretId = System.Environment.GetEnvironmentVariable("VAULT_SECRET_ID"); SettingsService settingsService = new SettingsService(); services.AddSingleton <ISettingsService>(settingsService); //Logging Logger.SetUpLogging(settingsService.GetSetting("LOGZIO_API_TOKEN"), settingsService.GetSetting("CRDS_ENV")); // Register all the webcommon stuff WebCommonSettingsConfig webCommonConfig = new WebCommonSettingsConfig( null, settingsService.GetSetting("MP_OAUTH_BASE_URL"), settingsService.GetSetting("MP_REST_API_ENDPOINT"), settingsService.GetSetting("CRDS_MP_COMMON_CLIENT_ID"), settingsService.GetSetting("CRDS_MP_COMMON_CLIENT_SECRET"), null, null ); CrossroadsWebCommonConfig.Register(services, webCommonConfig); //Add services //Add singleton does not seem to actually add a singleton unless you create it and pass it in OIDConfigurationService configurationService = new OIDConfigurationService(settingsService); services.AddSingleton <IOIDConfigurationService>(configurationService); services.AddSingleton <IJwtService, JwtService>(); services.AddSingleton <IMpUserService, MpUserService>(); services.AddSingleton <IOktaUserService, OktaUserService>(); services.AddSingleton <IUserService, UserService>(); services.AddSingleton <IAuthService, AuthService>(); }