|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
|
using EPAServeur.Context;
|
|
|
using EPAServeur.IServices;
|
|
|
using EPAServeur.Services;
|
|
|
using IO.Swagger.ApiCollaborateur;
|
|
|
using IO.Swagger.Security;
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
using Microsoft.AspNetCore.HttpsPolicy;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
namespace EPAServeur
|
|
|
{
|
|
|
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.AddControllers();
|
|
|
services.AddAuthentication(BearerAuthenticationHandler.SchemeName)
|
|
|
.AddScheme<AuthenticationSchemeOptions, BearerAuthenticationHandler>(BearerAuthenticationHandler.SchemeName, null);
|
|
|
|
|
|
services.AddDbContext<EpContext>();
|
|
|
using(var context = new EpContext())
|
|
|
{
|
|
|
context.Database.EnsureDeleted(); //PENSEZ A ENLEVER CETTE LIGNE ET A NE JAMAIS LA REMETTRE QUAND LE SERVEUR SERA MIS EN PRODUCTION ^^
|
|
|
context.Database.EnsureCreated();
|
|
|
context.SaveChanges();
|
|
|
context.AjoutInformationsDeBase();
|
|
|
context.AjoutChamps();
|
|
|
context.AjouterNotes();
|
|
|
}
|
|
|
//faire using, check si kekchoz exkist puis appeler les m<EFBFBD>thodes de cr<EFBFBD>ation si il n'y a rien
|
|
|
|
|
|
//API Collaborateurs
|
|
|
services.AddScoped<ICollaborateurApi, CollaborateurApi>();
|
|
|
services.AddScoped<IAgenceApi, AgenceApi>();
|
|
|
services.AddScoped<IReferentApi, ReferentApi>();
|
|
|
|
|
|
|
|
|
|
|
|
//Services
|
|
|
services.AddScoped<ICollaborateurService, CollaborateurService>();
|
|
|
services.AddScoped<IFormationService, FormationService>();
|
|
|
services.AddScoped<INoteService, NoteService>();
|
|
|
|
|
|
}
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
{
|
|
|
if (env.IsDevelopment())
|
|
|
{
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
}
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
{
|
|
|
endpoints.MapControllers();
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|