Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, AcademiaContext dbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            #region Swagger documentation middleware
            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Academia API V1");
            });
            #endregion


            app.UseHttpsRedirection();
            app.UseMvc();
            app.UseStaticFiles();

            //TODO: remove in production
            app.UseCors("AllowSpecificOrigin");

            //TODO: remove in production
            using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = serviceScope.ServiceProvider.GetService <AcademiaContext>())
                {
                    context.Database.Migrate();
                }
            }
        }
Ejemplo n.º 2
0
 public DataService(AcademiaContext context)
 {
     this.context = context;
 }