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.AddDbContextPool <ScientificResearchDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ScientificResearch")));
            services.AddControllers().AddNewtonsoftJson();

            // Add service and create Policy with options
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  );
            });

            services.AddAutoMapper(typeof(Startup));

            //Register Services
            services.AddScoped <ILevelService, LevelService>();
            services.AddScoped <IScientificWorkService, ScientificWorkService>();
            services.AddScoped <ILecturerService, LecturerService>();
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <INewsService, NewsService>();
            services.AddScoped <IScientificReportService, ScientificReportService>();
            services.AddScoped <IScientificReportTypeService, ScientificReportTypeService>();
            services.AddScoped <IBookCategoryService, BookCategoryService>();
            services.AddScoped <IPublishBookService, PublishBookService>();
            services.AddScoped <ILevelStudyGuideService, LevelStudyGuideService>();
            services.AddScoped <IStudyGuideService, StudyGuideService>();
            services.AddScoped <IOtherScientificWorkService, OtherScientificWorkService>();
            services.AddScoped <IClassificationOfScientificWorkService, ClassificationOfScientificWorkService>();

            //Register Repository
            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));

            IoCHelper.SetServiceProvider(services.BuildServiceProvider());

            services.AddMvc(option =>
            {
                option.Filters.Add <HandleExceptionFilterAttribute>();
            });

            //Swagger
            services.AddSwaggerGen(x =>
            {
                x.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "ScientificResearch API", Version = "v1"
                });
            });
        }
Exemplo n.º 2
0
        //public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add service and create Policy with options
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader());
            });

            services.AddControllers().AddNewtonsoftJson();
            services.AddSingleton(Configuration);
            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));

            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddSerilog(dispose: true);
                loggingBuilder.SetMinimumLevel(LogLevel.Information);
                loggingBuilder.AddFilter <SerilogLoggerProvider>(null, LogLevel.Trace);
            });
            services.AddSingleton <ILoggerProvider, SerilogLoggerProvider>();

            string conn = Configuration.GetConnectionString("certificate");

            services.AddDbContextPool <CertificateDbContext>(options => options.UseSqlServer(conn));

            //Config AutoMapper
            services.AddAutoMapper(typeof(Startup));

            //Register JwtHelper
            services.AddScoped <IJwtHelper, JwtHelper>();

            //Register Services
            //services.AddScoped<IMenuService, MenuService>();
            //services.AddScoped<IBookingService, BookingService>();
            //services.AddScoped<IPromotionService, PromotionService>();
            //services.AddScoped<ITableService, TableService>();
            //services.AddScoped<IOrderService, OrderService>();
            //services.AddScoped<IOrderDetailService, OrderDetailService>();
            services.AddScoped <IArticleService, ArticleService>();
            services.AddScoped <IArticleCategoryService, ArticleCategoryService>();
            services.AddScoped <ICertificateStatusService, CertificateStatusService>();
            services.AddScoped <IClassService, ClassService>();
            services.AddScoped <IEmailService, EmailService>();
            services.AddScoped <IExtracurricularService, ExtracurricularService>();
            services.AddScoped <IExtracurricularActivityService, ExtracurricularActivityService>();
            services.AddScoped <IFacultyService, FacultyService>();
            services.AddScoped <IMajorService, MajorService>();
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <ISSOAuthService, SSOAuthService>();
            services.AddScoped <ISpecialtyService, SpecialtyService>();
            services.AddScoped <IStandardOfCertificateService, StandardOfCertificateService>();
            services.AddScoped <IStudentService, StudentService>();
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <IReportService, ReportService>();
            //services.AddScoped<IItemService, ItemService>();
            //services.AddScoped<IReviewService, ReviewService>();
            //services.AddScoped<IItemService, ItemService>();
            //services.AddScoped<IReviewService, ReviewService>();

            //Register Repository
            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));

            IoCHelper.SetServiceProvider(services.BuildServiceProvider());

            services.AddMvc(option =>
            {
                option.Filters.Add <HandleExceptionFilterAttribute>();
            });

            //Swagger
            services.AddSwaggerGen(x =>
            {
                x.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Certificate API", Version = "v1"
                });
                x.DescribeAllParametersInCamelCase();
                x.OperationFilter <AccessTokenHeaderParameterOperationFilter>();
                x.CustomSchemaIds(i => i.FullName);
            });
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add service and create Policy with options
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials());
            });

            services.AddMvc().AddJsonOptions(opt =>
            {
                opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            })
            .AddJsonOptions(opt =>
            {
                opt.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
            });

            services.AddSingleton(Configuration);
            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));


            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddSerilog(dispose: true);
                loggingBuilder.SetMinimumLevel(LogLevel.Information);
                loggingBuilder.AddFilter <SerilogLoggerProvider>(null, LogLevel.Trace);
            });
            services.AddSingleton <ILoggerProvider, SerilogLoggerProvider>();

            //Config Automapper map
            Mapper.Initialize(config =>
            {
                config.CreateMap <User, UserRegisterModel>().ReverseMap();
            });

            var conn = Configuration.GetConnectionString("DefaultConnectionString");

            services.AddDbContextPool <OrientNetCoreDbContext>(options => options.UseSqlServer(conn));

            //Register JwtHelper
            services.AddScoped <IJwtHelper, JwtHelper>();

            //Register Repository
            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));

            //Register Service
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <IEmailService, EmailService>();
            services.AddScoped <ISSOAuthService, SSOAuthService>();
            services.AddScoped <IUserService, UserService>();

            //Register MemoryCacheManager
            services.AddScoped <ICacheManager, MemoryCacheManager>();

            // Set Service Provider for IoC Helper
            IoCHelper.SetServiceProvider(services.BuildServiceProvider());

            services.AddMvc(option =>
            {
                option.Filters.Add <HandleExceptionFilterAttribute>();
            });

            // Register the Swagger generator, defining one or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version        = "v1",
                    Title          = "Shopping API",
                    Description    = "ASP.NET Core API.",
                    TermsOfService = "None",
                    Contact        = new Contact {
                        Name = "HO TRONG LICH", Email = "*****@*****.**", Url = ""
                    },
                });

                c.DescribeAllParametersInCamelCase();
                c.OperationFilter <AccessTokenHeaderParameterOperationFilter>();

                // Set the comments path for the Swagger JSON and UI.
                //var basePath = PlatformServices.Default.Application.ApplicationBasePath;
                //var xmlPath = Path.Combine(basePath, "Orient.Base.Net.Core.Api.xml");
                //c.IncludeXmlComments(xmlPath);
            });

            services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);
        }
Exemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add service and create Policy with options
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials());
            });

            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.AddSingleton(Configuration);
            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));
            Mapper.Initialize(config =>
            {
                config.CreateMap <AppUser, UserRegisterViewModel>().ReverseMap();
                config.CreateMap <AppUser, UserUpdateViewModel>().ReverseMap();
                config.CreateMap <AppRole, AddRoleViewModel>().ReverseMap();
                config.CreateMap <ProductCategory, AddProductCategoryViewModel>().ReverseMap();
                config.CreateMap <Product, AddProductViewModel>().ReverseMap();
            });
            services.AddDbContext <AppDbContext>(options =>
                                                 options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <IdentityUser, IdentityRole>()
            .AddEntityFrameworkStores <AppDbContext>()
            .AddDefaultTokenProviders();

            services.AddScoped(typeof(IRepository <>), typeof(GenericRepository <>));
            //Register JwtHelper
            services.AddScoped <IJwtHelper, JwtHelper>();
            //Register ProductCategoryService
            services.AddScoped <IProductCategoryService, ProductCategoryService>();
            //Register FunctionService
            services.AddScoped <IFunctionService, FunctionService>();
            //Register IUserService
            services.AddScoped <IUserService, UserService>();
            //Register IRoleService
            services.AddScoped <IRoleService, RoleService>();
            //Register IUserService
            services.AddScoped <IAuthService, AuthService>();
            //Register IProductService
            services.AddScoped <IProductService, ProductService>();
            // Set Service Provider for IoC Helper
            IoCHelper.SetServiceProvider(services.BuildServiceProvider());
            // Register the Swagger generator, defining one or more Swagger documents

            services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version        = "v1",
                    Title          = "Information User API",
                    Description    = "ASP.NET Core API for user.",
                    TermsOfService = "None",
                });
            });
        }
Exemplo n.º 5
0
        public void ConfigureServices(IServiceCollection services)
        {
            // Add service and create Policy with options
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials());
            });

            services.AddMvc().AddJsonOptions(opt =>
            {
                opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            })
            .AddJsonOptions(opt =>
            {
                opt.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
            });

            services.AddSingleton(Configuration);
            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));

            Mapper.Initialize(config =>
            {
                config.CreateMap <User, UserLoginModel>().ReverseMap();
                config.CreateMap <User, UserRegisterModel>().ReverseMap();
                config.CreateMap <User, UserUpdateProfileModel>().ReverseMap();
                config.CreateMap <Category, CategoryManageModel>().ReverseMap();
                config.CreateMap <Product, ProductManageModel>().ReverseMap();
                config.CreateMap <ProductSize, ProductSizeManageModel>().ReverseMap();
                config.CreateMap <Order, OrderCreateModel>().ReverseMap();
                config.CreateMap <OrderDetail, OrderDetailManageModel>().ReverseMap();
            });

            services.AddDbContext <OMSDbContext>(options =>
            {
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnectionString"));
            });

            //Register JwtHelper
            services.AddScoped <IJwtHelper, JwtHelper>();

            //Register Repository
            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));

            // Register service
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <ISSOAuthService, SSOAuthService>();
            services.AddScoped <ICategoryService, CategoryService>();
            services.AddScoped <IProductService, ProductService>();
            services.AddScoped <ISizeService, SizeService>();
            services.AddScoped <IOrderService, OrderService>();

            // Set Service Provider for IoC Helper
            IoCHelper.SetServiceProvider(services.BuildServiceProvider());

            // Add Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version        = "v1",
                    Title          = "OMS API",
                    Description    = "ASP.NET Core API.",
                    TermsOfService = "None",
                    Contact        = new Contact {
                        Name = "TRAN VAN TAI", Email = "*****@*****.**", Url = ""
                    },
                });

                c.DescribeAllParametersInCamelCase();
                c.OperationFilter <AccessTokenHeaderParameterOperationFilter>();
            });

            services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add service and create Policy with options
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.AllowAnyOrigin()
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials());
            });


            services.AddMvc().AddJsonOptions(opt =>
            {
                opt.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            })
            .AddJsonOptions(opt =>
            {
                opt.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
            });

            services.AddSingleton(Configuration);
            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));


            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddSerilog(dispose: true);
                loggingBuilder.SetMinimumLevel(LogLevel.Information);
                loggingBuilder.AddFilter <SerilogLoggerProvider>(null, LogLevel.Trace);
            });
            services.AddSingleton <ILoggerProvider, SerilogLoggerProvider>();

            //Config Automapper map
            Mapper.Initialize(config =>
            {
                config.AddProfile <UserProfile>();
                config.AddProfile <CategoryProfile>();
                config.AddProfile <ProductProfile>();
                config.AddProfile <ShopProfile>();
                config.AddProfile <CommentProfile>();
            });

            var conn = Configuration.GetConnectionString("DefaultConnectionString");

            services.AddDbContextPool <OrientNetCoreDbContext>(options => options.UseSqlServer(conn));

            //Register Repository
            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));

            //Config Ldap

            //Register Service
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <ISSOAuthService, SSOAuthService>();
            services.AddScoped <IUserService, UserService>();

            //Register MemoryCacheManager
            services.AddScoped <ICacheManager, MemoryCacheManager>();

            //Category Service
            services.AddScoped <ICategoryService, CategoryService>();

            //Product Service
            services.AddScoped <IProductService, ProductService>();


            //Shop Service
            services.AddScoped <IShopService, ShopService>();

            //Comment Service
            services.AddScoped <ICommentService, CommentService>();

            // Set Service Provider for IoC Helper
            IoCHelper.SetServiceProvider(services.BuildServiceProvider());

            services.AddMvc(option =>
            {
                option.Filters.Add <HandleExceptionFilterAttribute>();
            });

            // Register the Swagger generator, defining one or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version        = "v1",
                    Title          = "Beverages API",
                    Description    = "ASP.NET Core API.",
                    TermsOfService = "None",
                    Contact        = new Contact {
                        Name = "THANH UCHIHA", Email = "*****@*****.**", Url = ""
                    },
                });

                c.DescribeAllParametersInCamelCase();
                c.OperationFilter <AccessTokenHeaderParameterOperationFilter>();

                // Set the comments path for the Swagger JSON and UI.
                var basePath = PlatformServices.Default.Application.ApplicationBasePath;
                var xmlPath  = Path.Combine(basePath, "Orient.Base.Net.Core.Api.xml");
                c.IncludeXmlComments(xmlPath);
            });

            services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);

            // Add RazorLight
            services.AddScoped <IRazorLightEngine>(sp =>
            {
                var engine = new RazorLightEngineBuilder()
                             .UseFilesystemProject(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location))
                             .UseMemoryCachingProvider()
                             .Build();
                return(engine);
            });

            // config signal R
            services.AddSignalR();
        }
Exemplo n.º 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add service and create Policy with options
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder => builder.SetIsOriginAllowed(host => true)
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials()
                                  );
            });

            services.AddControllers().AddNewtonsoftJson(options =>
            {
                // Use the default property (Pascal) casing
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
            });

            services.AddSingleton(Configuration);
            services.Configure <AppSettings>(Configuration.GetSection("AppSettings"));


            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddSerilog(dispose: true);
                loggingBuilder.SetMinimumLevel(LogLevel.Information);
                loggingBuilder.AddFilter <SerilogLoggerProvider>(null, LogLevel.Trace);
            });
            services.AddSingleton <ILoggerProvider, SerilogLoggerProvider>();

            //services.AddAutoMapper();

            //Config Automapper map
            //Mapper.Initialize(config =>
            //{
            //    config.CreateMap<User, UserRegisterModel>().ReverseMap();
            //});

            var conn = Configuration.GetConnectionString("DefaultConnectionString");

            services.AddDbContextPool <HVSNetCoreDbContext>(options => options.UseSqlServer(conn));

            //Register JwtHelper
            services.AddScoped <IJwtHelper, JwtHelper>();

            //Register Repository
            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));

            //Register Service
            services.AddScoped <IRoleService, RoleService>();
            services.AddScoped <IEmailService, EmailService>();
            services.AddScoped <ISSOAuthService, SSOAuthService>();
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <IPostService, PostService>();

            //Register MemoryCacheManager
            services.AddScoped <ICacheManager, MemoryCacheManager>();

            // Set Service Provider for IoC Helper
            IoCHelper.SetServiceProvider(services.BuildServiceProvider());

            services.AddMvc(option =>
            {
                option.Filters.Add <HandleExceptionFilterAttribute>();
            });

            // Register the Swagger generator, defining one or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version        = "v1",
                    Title          = "HVS API",
                    Description    = "ASP.NET Core API.",
                    TermsOfService = null,
                    Contact        = new OpenApiContact {
                        Name = "DINH KHAC HOAI PHUNG", Email = "*****@*****.**", Url = null
                    },
                });

                c.DescribeAllParametersInCamelCase();
                c.OperationFilter <AccessTokenHeaderParameterOperationFilter>();
            });

            services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);
        }