コード例 #1
0
ファイル: Startup.cs プロジェクト: nguyenlevy/do-an
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy = null;
                options.JsonSerializerOptions.DictionaryKeyPolicy  = null;
            });

            // config Connect API Local Angular

            services.AddCors(options =>
            {
                options.AddPolicy(name: "AllowAllHeaders",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyOrigin();
                });
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
            });

            SalesConfiguration.SetSalesConfiguration(Configuration);

            // auto mapping
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new AutoMappingProduct());
            });
            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);


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


            services.AddScoped <IBannerService, BannerService>();
            services.AddScoped <IBlogService, BlogService>();
            services.AddScoped <ICategoryService, CategoryService>();
            services.AddScoped <IPolicyService, PolicyService>();
            services.AddScoped <IProductService, ProductService>();
            services.AddScoped <IAttributeService, AttributeService>();
            services.AddScoped <IContactService, ContactService>();
            services.AddScoped <IBrandService, BrandService>();
            services.AddScoped <IOrderService, OrderService>();
            services.AddScoped <LogService>();


            services.AddFeatureServiceProduct();
            services.AddControllers();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: nguyenlevy/WebShop
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy = null;
                options.JsonSerializerOptions.DictionaryKeyPolicy  = null;
            });

            // config Connect API Local Angular

            services.AddCors(options =>
            {
                options.AddPolicy(name: "AllowAllHeaders",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyOrigin();
                });
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v2", new OpenApiInfo {
                    Title = "My API", Version = "v2"
                });
            });

            SalesConfiguration.SetSalesConfiguration(Configuration);

            // auto mapping
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new AutoMappingCommon());
                mc.AddProfile(new AutoMappingAuthentication());
                mc.AddProfile(new AutoMappingProduct());
                mc.AddProfile(new AutoMappingCustomer());
                mc.AddProfile(new AutoMappingOrder());
            });
            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);



            services.AddFeatureServiceAuthentication();
            services.AddFeatureServiceCommon();
            services.AddFeatureServiceCustomer();
            services.AddFeatureServiceOrder();

            services.AddFeatureServiceProduct();
            services.AddControllers();

            // configure basic authentication
            services.AddAuthentication("BasicAuthentication")
            .AddScheme <AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
        }
コード例 #3
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(DefaultCorsPolicyName, options =>
                {
                    options
                    .WithOrigins(Configuration["App:CorsOrigins"])
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            SalesConfiguration.SetSalesConfiguration(Configuration);

            // auto mapping
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new AutoMappingCommon());
                mc.AddProfile(new AutoMappingAuthentication());
                mc.AddProfile(new AutoMappingProduct());
                mc.AddProfile(new AutoMappingCustomer());
                mc.AddProfile(new AutoMappingOrder());
            });
            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

            services.AddFeatureServiceAuthentication();
            services.AddFeatureServiceCommon();
            services.AddFeatureServiceCustomer();
            services.AddFeatureServiceOrder();
            services.AddFeatureServiceProduct();
            services.AddControllers();

            // configure basic authentication
            services.AddAuthentication("BasicAuthentication")
            .AddScheme <AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
        }
コード例 #4
0
ファイル: Startup.cs プロジェクト: nguyenlevy/TEST-WEBSHOP
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy = null;
                options.JsonSerializerOptions.DictionaryKeyPolicy  = null;
            });

            // config Connect API Local Angular

            services.AddCors(options =>
            {
                options.AddPolicy(name: "AllowAllHeaders",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyOrigin();
                });
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
            });

            SalesConfiguration.SetSalesConfiguration(Configuration);

            // auto mapping
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new AutoMappingProduct());
            });
            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            //services.AddDbContext<PaymentDetailContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DevConnection")));
            //services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            //services.AddMvc().AddJsonOptions(
            //options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
            //);
            //services.AddMvc().AddJsonOptions(
            //options => options.SerializerSettings.DateFormatString = "yyyy-MM-dd"
            //);
            //services.AddSwaggerGen(c =>
            //{
            //    c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
            //});

            // In production, the Angular files will be served from this directory
            services.AddMvc(option => option.EnableEndpointRouting = false);

            //services.AddSpaStaticFiles(configuration =>
            //{
            //    configuration.RootPath = "ClientApp/dist";
            //});
            services.AddScoped <IBannerService, BannerService>();
            services.AddScoped <IBlogService, BlogService>();
            services.AddScoped <ICategoryService, CategoryService>();
            services.AddScoped <IPolicyService, PolicyService>();
            services.AddScoped <IProductService, ProductService>();
            services.AddScoped <IAttributeService, AttributeService>();
            services.AddScoped <IContactService, ContactService>();
            services.AddScoped <IBrandService, BrandService>();
            services.AddScoped <LogService>();


            services.AddFeatureServiceProduct();
            services.AddControllers();
        }