Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var appSettings = Configuration.GetSection("AppSettings").Get <TPMenuAppSetings>();
            var mongoKey    = appSettings.TPMenuDatabaseString;
            var mongoConn   = mongoKey;

            Console.Out.WriteLine(mongoKey + "|" + appSettings.DatabaseMenu);


            services.AddScoped <IEmpleadoRepository>(provider =>
                                                     new EmpleadoAdapter(mongoConn, $"{appSettings.DatabaseMenu}")
                                                     );

            services.BuildServiceProvider().GetService <IEmpleadoRepository>();
            services.AddTransient <HomeUseCase>();

            var servicesProvider = services.BuildServiceProvider();

            services.AddTransient <HomeUseCase>(provider => new HomeUseCase(servicesProvider.GetRequiredService <IEmpleadoRepository>()));

            HomeUseCase homeUseCase = services.BuildServiceProvider().GetService <HomeUseCase>();

            services.AddCors(options =>
            {
                options.AddPolicy(MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
            });

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddMvcCore().AddApiExplorer();
        }
Exemplo n.º 2
0
 public HomeController(HomeUseCase homeUseCase)
 {
     this.homeUseCase = homeUseCase;
 }