Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Authentication;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using webapilvcc.Models;
- using webapilvcc.Models.DB;
- using webapilvcc.Models.Interfaces;
- using webapilvcc.Models.Repositories;
- using webapilvcc.Models.Services;
- namespace webapilvcc
- {
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
- 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)
- {
- services.AddCors(options =>
- {
- options.AddPolicy("AllowSpecificOrigin",
- builder => builder.AllowAnyOrigin().AllowCredentials().AllowAnyMethod().AllowAnyHeader().WithExposedHeaders("x-custom-header"));
- });
- services.AddMvc()
- .AddJsonOptions(
- options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore)
- .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
- var connection = @"server=ooe.dev.cisc.pl;user=benek_mik;password=cisc!Qaz;database=benek_mik;Convert Zero Datetime=True";
- services.AddDbContext<DatabaseContext>(options => options.UseMySql(connection));
- services.AddScoped<IProjektsRepository, ProjektsRepository>();
- services.AddScoped<IZleceniesRepository, ZleceniesRepository>();
- services.AddScoped<IZadaniesRepository, ZadaniesRepository>();
- services.AddScoped<IReadersRepository, ReadersRepository>();
- services.AddScoped<IRaportProjektsRepository, RaportProjektsRepository>();
- services.AddScoped<IConnectorLogsRepository, ConnectorLogsRepository>();
- services.AddScoped<IPausesRepository, PausesRepository>();
- services.AddScoped<IWorkerBatsRepository, WorkerBatsRepository>();
- services.AddScoped<IAdministratorsRepository, AdministratorsRepository>();
- services.AddScoped<IWorkerReadersRepository, WorkerReadersRepository>();
- services.AddScoped<RaportProjektsService>();
- services.AddScoped<DetailsProjektService>();
- services.AddScoped<AdministratorsService>();
- services.AddScoped<WorkerReadersService>();
- services.AddHostedService<TimedHostedService>();
- }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- app.UseCors("AllowSpecificOrigin");
- app.UseMvc();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement