Esempio n. 1
0
        public virtual void ConfigureServices(IServiceCollection AServices)
        {
            AServices.AddMvc();
            AServices.AddControllers();
            AServices.AddSpaStaticFiles(AOptions => AOptions.RootPath = "ClientApp/build");
            AServices.AddResponseCompression(AOptions => AOptions.Providers.Add <GzipCompressionProvider>());
            Dependencies.Register(AServices, FConfiguration);

            if (FEnvironment.IsDevelopment())
            {
                AServices.AddSwaggerGen(AOption =>
                                        AOption.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "HotelCaliforniaApi", Version = "v1"
                }));
            }
        }
Esempio n. 2
0
        public void ConfigureServices(IServiceCollection AServices)
        {
            AServices.AddMvc(AOption => AOption.CacheProfiles
                             .Add("Standard", new CacheProfile()
            {
                Duration = 10,
                Location = ResponseCacheLocation.Any,
                NoStore  = false
            }));

            AServices.AddMvc(AOption => AOption.EnableEndpointRouting = false)
            .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            AServices.AddControllers();
            AServices.AddSingleton(Configuration.GetSection("CosmosDb").Get <CosmosDbSettings>());
            AServices.AddScoped <ICosmosDbService, CosmosDbService>();

            AServices.AddMediatR(Assembly.GetExecutingAssembly());
            AServices.AddTransient <IRequestHandler <AddNewUserCommand, Unit>, AddNewUserCommandHandler>();
            AServices.AddTransient <IRequestHandler <AddNewArticleCommand, Unit>, AddNewArticleCommandHandler>();
            AServices.AddTransient <IRequestHandler <AddNewSubscriberCommand, Unit>, AddNewSubscriberCommandHandler>();
            AServices.AddTransient <IRequestHandler <GetAllArticlesQuery, IEnumerable <Articles> >, GetAllArticlesQueryHandler>();
            AServices.AddTransient <IRequestHandler <GetAllUsersQuery, IEnumerable <Users> >, GetAllUsersQueryHandler>();
            AServices.AddTransient <IRequestHandler <GetAllSubscribersQuery, IEnumerable <Subscribers> >, GetAllSubscribersQueryHandler>();
            AServices.AddTransient <IRequestHandler <GetSingleArticleQuery, Articles>, GetSingleArticleQueryHandler>();
            AServices.AddTransient <IRequestHandler <GetSingleUserQuery, Users>, GetSingleUserQueryHandler>();
            AServices.AddTransient <IRequestHandler <GetSingleSubscriberQuery, Subscribers>, GetSingleSubscriberQueryHandler>();

            AServices.AddResponseCompression(AOptions =>
            {
                AOptions.Providers.Add <GzipCompressionProvider>();
            });

            AServices.AddSwaggerGen(AOption =>
            {
                AOption.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Cosmos DB Example", Version = "v1"
                });
            });
        }