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.AddDbContext <SmsDbContext>(options =>
            {
                var connection = this.Configuration.GetConnectionString(nameof(SmsDbContext));
                options.UseSqlServer(connection);
            });

            services.AddControllers();

            services.AddMvc(options => options.EnableEndpointRouting = false);

            services.AddCors(opts =>
            {
                opts.AddPolicy("AllowOrigin",
                               builder => builder.WithOrigins("http://localhost:4200"));
            });

            AddSwagger(services);

            services.AddAutoMapper(config => DefaultMapper.Config(config), AppDomain.CurrentDomain.GetAssemblies());

            services.AddTransient <StudentsService>();
        }