Advertisement
Guest User

Untitled

a guest
Oct 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Authentication;
  6. using Microsoft.AspNetCore.Builder;
  7. using Microsoft.AspNetCore.Hosting;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Microsoft.EntityFrameworkCore;
  10. using Microsoft.Extensions.Configuration;
  11. using Microsoft.Extensions.DependencyInjection;
  12. using Microsoft.Extensions.Logging;
  13. using Microsoft.Extensions.Options;
  14. using webapilvcc.Models;
  15. using webapilvcc.Models.DB;
  16. using webapilvcc.Models.Interfaces;
  17. using webapilvcc.Models.Repositories;
  18. using webapilvcc.Models.Services;
  19.  
  20. namespace webapilvcc
  21. {
  22.     public class Startup
  23.     {
  24.         public Startup(IConfiguration configuration)
  25.         {
  26.             Configuration = configuration;
  27.         }
  28.  
  29.         public IConfiguration Configuration { get; }
  30.  
  31.         // This method gets called by the runtime. Use this method to add services to the container.
  32.         public void ConfigureServices(IServiceCollection services)
  33.         {
  34.  
  35.             services.AddCors(options =>
  36.             {
  37.                 options.AddPolicy("AllowSpecificOrigin",
  38.                 builder => builder.AllowAnyOrigin().AllowCredentials().AllowAnyMethod().AllowAnyHeader().WithExposedHeaders("x-custom-header"));
  39.             });
  40.             services.AddMvc()
  41.                 .AddJsonOptions(
  42.                     options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore)
  43.                 .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  44.             var connection = @"server=ooe.dev.cisc.pl;user=benek_mik;password=cisc!Qaz;database=benek_mik;Convert Zero Datetime=True";
  45.             services.AddDbContext<DatabaseContext>(options => options.UseMySql(connection));
  46.  
  47.             services.AddScoped<IProjektsRepository, ProjektsRepository>();
  48.             services.AddScoped<IZleceniesRepository, ZleceniesRepository>();
  49.             services.AddScoped<IZadaniesRepository, ZadaniesRepository>();
  50.             services.AddScoped<IReadersRepository, ReadersRepository>();
  51.             services.AddScoped<IRaportProjektsRepository, RaportProjektsRepository>();
  52.             services.AddScoped<IConnectorLogsRepository, ConnectorLogsRepository>();
  53.             services.AddScoped<IPausesRepository, PausesRepository>();
  54.             services.AddScoped<IWorkerBatsRepository, WorkerBatsRepository>();
  55.             services.AddScoped<IAdministratorsRepository, AdministratorsRepository>();
  56.             services.AddScoped<IWorkerReadersRepository, WorkerReadersRepository>();
  57.             services.AddScoped<RaportProjektsService>();
  58.             services.AddScoped<DetailsProjektService>();
  59.             services.AddScoped<AdministratorsService>();
  60.             services.AddScoped<WorkerReadersService>();
  61.  
  62.             services.AddHostedService<TimedHostedService>();
  63.  
  64.            
  65.  
  66.         }
  67.  
  68.         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  69.         public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  70.         {
  71.             if (env.IsDevelopment())
  72.             {
  73.                 app.UseDeveloperExceptionPage();
  74.             }
  75.             app.UseCors("AllowSpecificOrigin");
  76.             app.UseMvc();
  77.  
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement