feat + doc : création de projet et ajout de la classe Answer (AnswerEntity, AnswerDTO) + documentation de cette classe
continuous-integration/drone/push Build is passing Details

API
Damien NORTIER 1 year ago
parent ce6871a30f
commit b8d6d6cecf

@ -0,0 +1,25 @@
namespace DTOs
{
/// <summary>
/// define a DTO of an answer for a Question with Mutiple Choice
/// properties :
/// Id : identifier in the database
/// Content : content of the answer
/// </summary>
public class AnswerDto
{
public long Id { get; set; }
public string Content { get; set; } = null!;
/// <summary>
/// constructor of an answer
/// </summary>
/// <param name="id">the id of an answer</param>
/// <param name="content">the content of an answer</param>
public AnswerDto(long id, string content)
{
Id = id;
Content = content;
}
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Entities\Entities.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
namespace DbConnectionLibrairie
{
public class MyDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
if (!options.IsConfigured)
{
options.UseSqlite(@"Data source = database.db");
}
}
}
}

@ -0,0 +1,14 @@
namespace Entities
{
public class AnswerEntity
{
/// <summary>
/// define an entity of an answer for a Question with Mutiple Choice
/// properties :
/// Id : identifier in the database
/// Content : content of the answer
/// </summary>
long Id { get; set; }
string Content { get; set; } = null!;
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,7 @@
namespace ManagerInterfaces
{
public interface IAnswerManager<T>
{
public T getAnswers(int nb, int count);
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,53 @@
namespace Model
{
/// <summary>
/// define an answer for a Question with Mutiple Choice
/// variable :
/// id : identifier in the database
/// content : content of the answer
/// </summary>
public class Answer
{
private long id;
private string? content;
/// <summary>
/// property for id manipulations
/// </summary>
public long Id
{
get
{
return id;
}
private set
{
id = value < -1 ? -1 : value;
}
}
/// <summary>
/// property for content manipulations
/// </summary>
public string Content
{
get
{
return content == null ? "" : content;
}
set
{
content = value == "" ? null : value;
}
}
/// <summary>
/// constructor of an answer
/// </summary>
/// <param name="content">the content of an answer</param>
/// <param name="id">the id of an answer</param>
private Answer(string content, long id = -1)
{
Id = id;
Content = content;
}
}
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34607.119
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication", "WebApplication\WebApplication.csproj", "{9F05B995-3079-4905-A9B1-7B3E8621ECC1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{19A1AA55-0FDF-427F-97EA-157E816C93CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbConnectionLibrairie", "DbConnectionLibrairie\DbConnectionLibrairie.csproj", "{8224E470-B008-4738-88FD-7DEDCAA4AE44}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagerInterfaces", "ManagerInterfaces\ManagerInterfaces.csproj", "{35D8DDF1-93B1-4064-9205-BB745D300BCC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DTOs", "DTOs\DTOs.csproj", "{F911181D-6194-4CA9-A302-7A055652E5FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{1C517096-268C-478C-BB98-5ACB8DD0692A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F05B995-3079-4905-A9B1-7B3E8621ECC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F05B995-3079-4905-A9B1-7B3E8621ECC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F05B995-3079-4905-A9B1-7B3E8621ECC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F05B995-3079-4905-A9B1-7B3E8621ECC1}.Release|Any CPU.Build.0 = Release|Any CPU
{19A1AA55-0FDF-427F-97EA-157E816C93CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19A1AA55-0FDF-427F-97EA-157E816C93CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19A1AA55-0FDF-427F-97EA-157E816C93CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19A1AA55-0FDF-427F-97EA-157E816C93CE}.Release|Any CPU.Build.0 = Release|Any CPU
{8224E470-B008-4738-88FD-7DEDCAA4AE44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8224E470-B008-4738-88FD-7DEDCAA4AE44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8224E470-B008-4738-88FD-7DEDCAA4AE44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8224E470-B008-4738-88FD-7DEDCAA4AE44}.Release|Any CPU.Build.0 = Release|Any CPU
{35D8DDF1-93B1-4064-9205-BB745D300BCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35D8DDF1-93B1-4064-9205-BB745D300BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35D8DDF1-93B1-4064-9205-BB745D300BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35D8DDF1-93B1-4064-9205-BB745D300BCC}.Release|Any CPU.Build.0 = Release|Any CPU
{F911181D-6194-4CA9-A302-7A055652E5FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F911181D-6194-4CA9-A302-7A055652E5FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F911181D-6194-4CA9-A302-7A055652E5FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F911181D-6194-4CA9-A302-7A055652E5FA}.Release|Any CPU.Build.0 = Release|Any CPU
{1C517096-268C-478C-BB98-5ACB8DD0692A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C517096-268C-478C-BB98-5ACB8DD0692A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C517096-268C-478C-BB98-5ACB8DD0692A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C517096-268C-478C-BB98-5ACB8DD0692A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {30D8C710-2DC7-401D-AC62-AB63591468C8}
EndGlobalSection
EndGlobal

@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace WebApplication.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62623",
"sslPort": 44358
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5228",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7256;http://localhost:5228",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -0,0 +1,13 @@
namespace WebApplication
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>

@ -0,0 +1,6 @@
@WebApplication_HostAddress = http://localhost:5228
GET {{WebApplication_HostAddress}}/weatherforecast/
Accept: application/json
###

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

@ -0,0 +1,30 @@
./Blazor/Blazor/Pages/Admins/AddAdministrator.razor.cs: string apiUri = API.API_URL + "add/administrator/" + API.TOKEN
./Blazor/Blazor/Pages/Admins/Administrators.razor.cs: var response = await Http.GetFromJsonAsync<Administrator[]>(API.API_URL + "all/administrators/" + API.TOKEN + "/" + page)
./Blazor/Blazor/Pages/Admins/Administrators.razor.cs: string apiUri = API.API_URL +"delete/administrator/" + id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Admins/EditAdministrator.razor.cs: string apiUri = API.API_URL + "update/administrator/" + administratorModel.Id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Chapters/AddChapter.razor.cs: string apiUri = API.API_URL + "add/chapter/" + API.TOKEN
./Blazor/Blazor/Pages/Chapters/Chapters.razor.cs: string apiUri = API.API_URL+"delete/chapter/" + id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Chapters/Chapters.razor.cs: var response = await Http.GetFromJsonAsync<Chapter[]>(API.API_URL + "all/chapters/" + API.TOKEN + "/" + page)
./Blazor/Blazor/Pages/Chapters/EditChapter.razor.cs: string apiUri = API.API_URL+"update/chapter/" + chapterModel.Id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Players/AddPlayer.razor.cs: string apiUri = API.API_URL + "add/player/" + API.TOKEN
./Blazor/Blazor/Pages/Players/EditPlayer.razor.cs: string apiUri = API.API_URL+"update/player/" + playerModel.Id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Players/Players.razor.cs: string apiUri = API.API_URL+"delete/player/" + id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Players/Players.razor.cs: var response = await Http.GetFromJsonAsync<Player[]>(API.API_URL + "all/players/" + API.TOKEN + "/" + page)
./Blazor/Blazor/Pages/Questions/AddQuestion.razor.cs: var response = Http.GetFromJsonAsync<Chapter[]>(API.API_URL + "all/chapters/" + API.TOKEN + "/1").Result
./Blazor/Blazor/Pages/Questions/AddQuestion.razor.cs: string apiUri = API.API_URL + "add/question/" + API.TOKEN
./Blazor/Blazor/Pages/Questions/DisplayQuestions.razor.cs: var response = Http.GetFromJsonAsync<Question[]>(API.API_URL + "questions/" + QuestionId + "/" + API.TOKEN).Result
./Blazor/Blazor/Pages/Questions/EditQuestion.razor.cs: var response = Http.GetFromJsonAsync<Chapter[]>(API.API_URL + "all/chapters/" + API.TOKEN + "/1").Result
./Blazor/Blazor/Pages/Questions/EditQuestion.razor.cs: var resp = Http.GetFromJsonAsync<Question[]>(API.API_URL + "questions/" + Id + "/" + API.TOKEN).Result
./Blazor/Blazor/Pages/Questions/EditQuestion.razor.cs: string apiUri = API.API_URL+"/update/question/" + question.Id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Questions/Questions.razor.cs: string apiUri = API.API_URL+"delete/question/" + id + "/" + API.TOKEN
./Blazor/Blazor/Pages/Questions/Questions.razor.cs: var response = await Http.GetFromJsonAsync<Question[]>(API.API_URL + "all/questions/" + API.TOKEN + "/" + page)
./Blazor/Blazor/Pages/Questions/Questions.razor.cs: HttpResponseMessage response = await Http.GetAsync(API.API_URL+"questionsExport/"+API.TOKEN)
./Blazor/Blazor/Pages/Questions/Questions.razor.cs: string apiUri = API.API_URL+"chapters/name/"+field[1] + "/" + API.TOKEN
./Blazor/Blazor/Pages/Questions/Questions.razor.cs: apiUri = API.API_URL+"add/question/"+API.TOKEN
./Blazor/Blazor/Services/DataLocalService.cs: var currentData = _http.GetFromJsonAsync<List<Chapter>>(API.API_URL + "chapters/" + id + "/" + API.TOKEN).Result
./Blazor/Blazor/Services/DataLocalService.cs: var currentData = _http.GetFromJsonAsync<List<Administrator>>(API.API_URL + "administrators/" + id + "/" + API.TOKEN).Result
./Blazor/Blazor/Services/DataLocalService.cs: var currentData = _http.GetFromJsonAsync<List<Question>>(API.API_URL + "questions/"+API.TOKEN).Result
./Blazor/Blazor/Services/DataLocalService.cs: var currentData = await _http.GetFromJsonAsync<List<Question>>(API.API_URL + "questions/" + API.TOKEN)
./Blazor/Blazor/Services/DataLocalService.cs: var currentData = _http.GetFromJsonAsync<List<Player>>(API.API_URL + "players/" + id + "/" + API.TOKEN).Result
./Blazor/Blazor/Services/DataLocalService.cs: var answer = _http.GetFromJsonAsync<Answer>(API.API_URL + "answer/" + id + "/" + API.TOKEN).Result
Loading…
Cancel
Save