// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("AllowSpecificOrigin", config => config.WithOrigins("http://localhost:4200", "http://localhost:5000").AllowAnyMethod().AllowAnyHeader()); }); services.AddMvc(options => { options.Filters.Add(typeof(ValidateModelAttribute)); }).AddJsonOptions(options => { options.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local; }); var appSettingsSection = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appSettingsSection); // configure jwt authentication services.AddDbContext <AppDbContext>(options => options.UseLazyLoadingProxies().UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])); services.AddSwaggerDocumentation(); InjectionModule.ConfigureServices(services); services.AddJwtAuthentication(Configuration); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.Configure <SettingsWrapper>(Configuration); services.AddScoped <ControllerHelper>(); _injectionModule.ConfigureServices(services); _injectionModule.ConfigureRepositories(services, shouldUseMongoRepository: bool.Parse(Configuration["Repositories:UseMongoRepository"])); _mappingModule.ConfigureServices(services); services.AddSwaggerGen(c => { c.SwaggerDoc("v1.0", new Info { Version = "v1.0", Title = "Whatflix", }); var basePath = PlatformServices.Default.Application.ApplicationBasePath; var xmlPath = Path.Combine(basePath, "Whatflix.Api.xml"); c.IncludeXmlComments(xmlPath); }); }