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)
        {
            services.AddCors(options =>
            {
                options.AddPolicy(name: MyAllowSpecificOrigins,
                                  builder =>
                {
                    builder.WithOrigins(
                        "https://localhost:44311",
                        "https://localhost:5001")
                    .WithMethods("PUT", "DELETE", "GET", "POST");
                });
            });

            services.AddTransient <SeedDb>();
            services.AddTransient <IMapperDependency, MapperClient>();
            services.AddTransient <IBookRepository, BookRepository>();
            services.AddTransient <IAutorRepository, AutorRepository>();
            services.AddTransient <IEditorialRepository, EditorialRepository>();
            services.AddTransient <IBookService, BookService>();
            services.AddTransient <IAutorService, AutorService>();


            services.AddDbContext <EntityContext>(cfg =>
            {
                cfg.UseSqlServer(this.Configuration.GetConnectionString("DefaultConnection"));
            });

            AutomapperConfig.CreateMaps();

            services.AddControllers();
        }
Exemplo n.º 2
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     AutofacConfig.RegisterDependencies();
     AutomapperConfig.CreateMaps();
 }