Ejemplo n.º 1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddConnections();
     services.AddCors(options =>
     {
         options.AddDefaultPolicy(ApplicationBuilder =>
         {
             ApplicationBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
         });
     });
     services.AddControllers();
 }
Ejemplo n.º 2
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddCors(c => c.AddPolicy("CorsAllowAll1", ApplicationBuilder =>
     {
         ApplicationBuilder.AllowAnyOrigin()
         .AllowAnyMethod()
         .AllowAnyHeader();
     }));
     services.AddScoped <IStaticSearch, StaticSearch>();
     services.AddScoped <IGoogleSearch, GoogleSearch>();
     services.AddScoped <IStaticSearchService, StaticSearchService>();
     services.AddScoped <IGoogleSearchService, GoogleSearchService>();
     services.AddControllers();
     services.AddApplicationLayer();
 }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            AddSwagger(services);

            services.AddApplicationServices();
            services.AddInfrastructureServices(Configuration);
            services.AddPersistenceServices(Configuration);
            services.AddIdentityServices(Configuration);

            services.AddScoped <ILoggedInUserService, LoggedInUserService>();

            services.AddControllers();

            services.AddCors(options =>
            {
                options.AddDefaultPolicy(ApplicationBuilder => ApplicationBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
                //options.AddPolicy("open", builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            });
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime.
        //Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(o => o.AddPolicy("MyCorsPolicy", ApplicationBuilder =>
            {
                ApplicationBuilder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));
            services.AddDbContext <HospitalDbContext>(
                options =>
            {
                options.UseSqlServer(Configuration["Connectionstring:HospitalDB"]);
            }
                );

            services.AddSingleton <IPatient, Patient>();
            services.AddSession(options =>
            {
                options.IdleTimeout        = TimeSpan.FromSeconds(60);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
            });
            //var conn = Configuration.GetConnectionString("HospitalDB");
            //services.AddDbContext<HospitalDbContext>(options =>
            //options.UseSqlServer(conn));
            services.AddControllersWithViews();
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = "Parth",
                    ValidAudience    = "Parth",
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("Part4299fshahadf"))
                };
            });
        }