|
|
|
@ -1,7 +1,13 @@
|
|
|
|
|
using DataManagers;
|
|
|
|
|
using DbConnectionLibrairie;
|
|
|
|
|
using DTOs;
|
|
|
|
|
using EntityManagers;
|
|
|
|
|
using ManagerInterfaces;
|
|
|
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using ServiceManagers;
|
|
|
|
|
using WebApi;
|
|
|
|
|
using WebApi.Controllers;
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
@ -14,16 +20,36 @@ builder.Services.AddEndpointsApiExplorer();
|
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddApiVersioning();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddSingleton<MyDbContext>(provider => {
|
|
|
|
|
var connection = new SqliteConnection("DataSource=database");
|
|
|
|
|
connection.Open();
|
|
|
|
|
|
|
|
|
|
var options = new DbContextOptionsBuilder<MyDbContext>()
|
|
|
|
|
.UseSqlite(connection)
|
|
|
|
|
.Options;
|
|
|
|
|
|
|
|
|
|
return new MyDbContext(options);
|
|
|
|
|
var dbContext = new MyDbContext(options);
|
|
|
|
|
builder.Services.AddSingleton(provider =>
|
|
|
|
|
{
|
|
|
|
|
return new AdministratorServiceManager(new AdministratorDataManager(new AdministratorEntityManager(dbContext)));
|
|
|
|
|
});
|
|
|
|
|
builder.Services.AddSingleton(provider =>
|
|
|
|
|
{
|
|
|
|
|
return new AnswerServiceManager(new AnswerDataManager(new AnswerEntityManager(dbContext)));
|
|
|
|
|
});
|
|
|
|
|
builder.Services.AddSingleton(provider =>
|
|
|
|
|
{
|
|
|
|
|
return new ChapterServiceManager(new ChapterDataManager(new ChapterEntityManager(dbContext)));
|
|
|
|
|
});
|
|
|
|
|
builder.Services.AddSingleton(provider =>
|
|
|
|
|
{
|
|
|
|
|
return new LobbyServiceManager(new LobbyDataManager(new LobbyEntityManager(dbContext)));
|
|
|
|
|
});
|
|
|
|
|
builder.Services.AddSingleton(provider =>
|
|
|
|
|
{
|
|
|
|
|
return new PlayerServiceManager(new PlayerDataManager(new PlayerEntityManager(dbContext)));
|
|
|
|
|
});
|
|
|
|
|
builder.Services.AddSingleton(provider =>
|
|
|
|
|
{
|
|
|
|
|
return new QuestionServiceManager(new QuestionDataManager(new QuestionEntityManager(dbContext)));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|