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)
        {
            services.AddScoped <ILookupService, DefaultLookupService>();
            services.AddScoped <IEnrolleeService, DefaultEnrolleeService>();
            services.AddScoped <IAutomaticAdjudicationService, DefaultAutomaticAdjudicationService>();
            services.AddScoped <IEnrolmentCertificateService, DefaultEnrolmentCertificateService>();
            services.AddScoped <IEmailService, DefaultEmailService>();

            services
            .AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            // add a convertor <globally> to change empty strings into null on serialization
            .AddJsonOptions(options => options.SerializerSettings.Converters.Add(new EmptyStringToNullJsonConverter()));

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                                  builder =>
                {
                    builder
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials();
                });
            });

            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Prime Web API", Version = "v1"
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });

            services.AddHttpContextAccessor();

            this.ConfigureDatabase(services);

            AuthenticationSetup.Initialize(services, Configuration, Environment);
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <ILookupService, LookupService>();
            services.AddScoped <IEnrolleeService, EnrolleeService>();
            services.AddScoped <ISubmissionRulesService, SubmissionRulesService>();
            services.AddScoped <IEnrolmentCertificateService, EnrolmentCertificateService>();
            services.AddScoped <IEmailService, EmailService>();
            services.AddScoped <IPrivilegeService, PrivilegeService>();
            services.AddScoped <IAccessTermService, AccessTermService>();
            services.AddScoped <IEnrolleeProfileVersionService, EnrolleeProfileVersionService>();
            services.AddScoped <IAdminService, AdminService>();
            services.AddScoped <IFeedbackService, FeedbackService>();
            services.AddScoped <IBusinessEventService, BusinessEventService>();
            services.AddScoped <ISubmissionService, SubmissionService>();
            services.AddScoped <IRazorConverterService, RazorConverterService>();
            services.AddScoped <ISiteService, SiteService>();
            services.AddScoped <IPartyService, PartyService>();
            services.AddScoped <IDocumentService, DocumentService>();
            services.AddScoped <IOrganizationService, OrganizationService>();
            services.AddScoped <IPdfService, PdfService>();
            services.AddScoped <IVerifiableCredentialService, VerifiableCredentialService>();

            ConfigureClients(services);

            services.AddControllers()
            .AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.Converters.Add(new EmptyStringToNullJsonConverter());
            });

            services.Configure <RouteOptions>(options =>
            {
                options.ConstraintMap.Add("submissionAction", typeof(EnumRouteConstraint <SubmissionAction>));
            });

            services.AddCors(options =>
            {
                options.AddPolicy(AllowSpecificOrigins,
                                  builder =>
                {
                    builder
                    .AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .WithExposedHeaders("Location");
                });
            });

            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Prime Web API", Version = "v1"
                });

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
            services.AddSwaggerGenNewtonsoftSupport();
            services.AddWkhtmltopdf("./Resources/wkhtmltopdf");

            services.AddHttpContextAccessor();
            services.AddRazorPages();

            this.ConfigureDatabase(services);

            AuthenticationSetup.Initialize(services, Configuration, Environment);
        }