Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddMvc(i => i.Filters.Add(typeof(ValidateModelFilterAttribute)))
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddMvc().AddJsonOptions(options => {
                options.SerializerSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            services.AddEntityFrameworkNpgsql()
            .AddDbContext <SalesContext>(opt =>
                                         opt.UseNpgsql(Configuration.GetConnectionString("Sales")));

            services.AddAutoMapper(s => s.AddProfile(new DtoMapper()));

            InjectionContainer.DoInjection(services);

            services.AddSwaggerGen(c =>
                                   c.SwaggerDoc("v1",
                                                new Info
            {
                Title       = "Gerenciador de Vendas",
                Version     = "v1",
                Description = "API do Sistema Gerenciador de Vendas",
                Contact     = new Contact
                {
                    Name = "Ronaldo  Ribeiro",
                    Url  = "https://github.com/ronaldosjr/SegImob"
                }
            }));
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddMvc(i => i.Filters.Add(typeof(ValidateModelFilterAttribute)))
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddEntityFrameworkNpgsql()
            .AddDbContext <RestaurantContext>(opt =>
                                              opt.UseNpgsql(Configuration.GetConnectionString("Restaurant")));

            services.AddAutoMapper(s => s.AddProfile(new DtoMapper()));

            InjectionContainer.DoInjection(services);

            services.AddSwaggerGen(c =>
                                   c.SwaggerDoc("v1",
                                                new Info
            {
                Title       = "Gerenciador de Restaurante",
                Version     = "v1",
                Description = "API do Sistema Gerenciador de Restaurantes",
                Contact     = new Contact
                {
                    Name = "Ronaldo  Ribeiro",
                    Url  = "https://github.com/ronaldosjr/Restaurant"
                }
            }));
        }