Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddDefaultAWSOptions(Configuration.GetAWSOptions());
            services.AddDataProtection().PersistKeysToAWSSystemsManager("/KBS-API/DataProtection");
            services.AddAWSService <IAmazonSimpleEmailService>();
            services.AddScoped <IEmailService, EmailService>();

            //services.AddSingleton<ILog, LogNLog>();

            IServiceProvider p = null;

            services.AddLogging(config =>
            {
                config.ClearProviders();
                config.AddConsole();
                config.SetMinimumLevel(LogLevel.Warning);
                config.AddNLog();
            });

            NLogHelper.ConfigureLogger();

            services.AddDbContext <BookingContext>(opt =>
                                                   opt.UseSqlServer(Environment.GetEnvironmentVariable("KewBookingConnection"))
                                                   .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking));

            services.AddMemoryCache();
            services.AddHttpClient <IBankHolidayAPI, BankHolidayAPI>(c =>
            {
                c.BaseAddress = new Uri(Environment.GetEnvironmentVariable("RecordCopying_WebApi_URL"));
                c.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                c.DefaultRequestHeaders.Host = Environment.GetEnvironmentVariable("RecordCopying_Header");
            });
            services.AddScoped <IWorkingDayService, WorkingDayService>();
            services.AddScoped <IAvailabilityService, AvailabilityService>();
            services.AddScoped <IBookingService, BookingService>();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Book a reading room visit-api", Version = "v1"
                });
            });
        }