Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ApplicationServicesInstaller.ConfigureApplicationServices(services, Configuration);
            AuthServicesInstaller.ConfigureServicesAuth(services, Configuration);
            CoreServicesInstaller.ConfigCoreService(services, Configuration);

            ServiceLocator.SetLocatorProvider(services.BuildServiceProvider);

            services.AddControllers();

            services.AddSession();

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

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

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Name   = "Authorization",
                    In     = ParameterLocation.Header,
                    Type   = SecuritySchemeType.ApiKey,
                    Scheme = "Bearer"
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement()
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            },
                            Scheme = "oauth2",
                            Name   = "Bearer",
                            In     = ParameterLocation.Header,
                        },
                        new List <string>()
                    }
                });

                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
                c.CustomSchemaIds(x => x.FullName);
            });

            services.AddCronJob <JobService>(c =>
            {
                c.TimeZoneInfo   = TimeZoneInfo.Local;
                c.CronExpression = @"*/1 * * * *";
            });
        }
Esempio n. 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            CoreServicesInstaller.ConfigureCoreServices(services, Configuration);
            AuthServicesInstaller.ConfigureServicesAuth(services, Configuration);
            ApplicationServicesInstaller.ConfigureApplicationServices(services, Configuration);

            //Auto Mapper Configurations
            services.AddSingleton(provider => new MapperConfiguration(mc =>
            {
                mc.AddProfile(new DtoToSchemaMappingProfile());
                mc.AddProfile(new SchemaToDtoMappingProfile());
                mc.AddProfile(new DtoToResultMappingProfile());
                mc.AddProfile(new ModelToDtoMappingProfile());
            }).CreateMapper());

            // Add Hangfire services
            services.AddHangfire(Configuration.GetConnectionString("HangfireConnection"));
        }
Esempio n. 3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ApplicationServicesInstaller.ConfigureApplicationServices(services, Configuration);
     AuthServicesInstaller.ConfigureServicesAuth(services, Configuration);
     CoreServicesInstaller.ConfigureCoreServices(services, Configuration);
     ServiceLocator.SetLocatorProvider(services.BuildServiceProvider);
     services.AddControllers().AddNewtonsoftJson(options =>
                                                 options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                                                 );
     services.AddControllers();
     services.AddSwaggerGen(c =>
     {
         c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo {
             Title = "My API", Version = "v1"
         });
     }
                            );
 }
Esempio n. 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CoreServicesInstaller.ConfigureCoreServices(services, Configuration);
            AuthServicesInstaller.ConfigureServicesAuth(services, Configuration);
            ApplicationServicesInstaller.ConfigureApplicationServices(services, Configuration);

            services
            .AddControllersWithViews()
            .AddNewtonsoftJson(options =>
                               options.SerializerSettings.Converters.Add(new StringEnumConverter()));

            services.AddHangfire(config =>
            {
                config.UsePostgreSqlStorage(Configuration.GetConnectionString("ReactConnectionString"));
            });

            services.AddSwaggerGen(
                c =>
            {
                c.SwaggerDoc(
                    "v5",
                    new OpenApiInfo
                {
                    Title       = "Glotech React API",
                    Version     = "v5",
                    Description = "ASP.NET Core Web API",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Nguyen Dinh Binh",
                        Email = "*****@*****.**",
                    },
                    License = new OpenApiLicense
                    {
                        Name = "Copyright by Binh Nguyen",
                    }
                });

                c.OrderActionsBy((apiDesc) => $"{apiDesc.ActionDescriptor.RouteValues["controller"]}_{apiDesc.HttpMethod}");
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }
Esempio n. 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CoreServicesInstaller.ConfigureCoreServices(services, Configuration);
            AuthServicesInstaller.ConfigureServicesAuth(services, Configuration);
            ApplicationServicesInstaller.ConfigureApplicationServices(services, Configuration);

            ServiceLocator.SetLocatorProvider(services.BuildServiceProvider);

            // Register the Swagger generator, defining one or more Swagger documents
            services.AddSwaggerGen(
                c =>
            {
                c.DescribeAllEnumsAsStrings();
                c.SwaggerDoc(
                    "v1",
                    new Info
                {
                    Title          = "Wedding.PROJECT API",
                    Version        = "v1",
                    Description    = "ASP.NET Core Web API 2",
                    TermsOfService = "None",
                    Contact        = new Contact
                    {
                        Name  = "Bui Thi Ngoc Phuc",
                        Email = "*****@*****.**",
                        Url   = "*****@*****.**"
                    },
                    License = new License
                    {
                        Name = "Copyright by The 41 Wedding Team",
                        Url  = ""
                    }
                });

                c.OrderActionsBy((apiDesc) => $"{apiDesc.ActionDescriptor.RouteValues["controller"]}_{apiDesc.HttpMethod}");

                var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "Wedding.WebApi.xml");
                c.IncludeXmlComments(filePath);
            });

            services.AddSignalR();
        }
Esempio n. 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CoreServicesInstaller.ConfigureCoreServices(services, Configuration);
            AuthServicesInstaller.ConfigureServicesAuth(services, Configuration);
            ApplicationServicesInstaller.ConfigureApplicationServices(services, Configuration);

            ServiceLocator.SetLocatorProvider(services.BuildServiceProvider);

            services.AddMvcCore()
            .AddApiExplorer();

            // Add the embedded file provider
            var viewAssembly = typeof(RazorViewRenderService).GetTypeInfo().Assembly;
            var fileProvider = new EmbeddedFileProvider(viewAssembly);

            services.Configure <RazorViewEngineOptions>(
                options =>
            {
                options.FileProviders.Add(fileProvider);
            });

            services.AddHangfire(
                config =>
                config.UseSqlServerStorage(Configuration["ConnectionStrings:ErpConnection"]));

            services.Configure <FormOptions>(options =>
            {
                options.MultipartBodyLengthLimit = 52428800;
            });

            // Register the Swagger generator, defining one or more Swagger documents
            services.AddSwaggerGen(
                c =>
            {
                c.EnableAnnotations();
                c.DescribeAllEnumsAsStrings();
                c.SwaggerDoc(
                    "v1",
                    new Info
                {
                    Title          = "HAWA API",
                    Version        = "v1",
                    Description    = "ASP.NET Core Web API 2",
                    TermsOfService = "None",
                    Contact        = new Contact
                    {
                        Name  = "Nguyen Khanh Huy",
                        Email = "*****@*****.**",
                        Url   = "*****@*****.**"
                    },
                    License = new License
                    {
                        Name = "Copyright by BYS JSC",
                        Url  = "https://wwww.bys.vn"
                    }
                });

                c.OrderActionsBy((apiDesc) => $"{apiDesc.ActionDescriptor.RouteValues["controller"]}_{apiDesc.HttpMethod}");

                var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "HawaDDS.xml");
                c.IncludeXmlComments(filePath);
            });
        }