diff --git a/WebApi/DTOs/AdministratorDto.cs b/WebApi/DTOs/AdministratorDto.cs
new file mode 100644
index 0000000..d417d95
--- /dev/null
+++ b/WebApi/DTOs/AdministratorDto.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTOs
+{
+ public class AdministratorDto
+ {
+ ///
+ /// define a DTO for an administrator
+ /// properties :
+ /// Id : identifier in the database
+ /// Username : username for a player
+ /// HashedPassword : hashed of the password of the player
+ ///
+ public int Id { get; set; }
+ public string Username { get; set; } = null!;
+ public string HashedPassword { get; set; } = null!;
+ }
+}
diff --git a/WebApi/DTOs/AnswerDto.cs b/WebApi/DTOs/AnswerDto.cs
index f0fe9d9..257811c 100644
--- a/WebApi/DTOs/AnswerDto.cs
+++ b/WebApi/DTOs/AnswerDto.cs
@@ -1,25 +1,19 @@
-namespace DTOs
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace DTOs
{
- ///
- /// define a DTO of an answer for a Question with Mutiple Choice
- /// properties :
- /// Id : identifier in the database
- /// Content : content of the answer
- ///
public class AnswerDto
{
- public int Id { get; set; }
- public string Content { get; set; } = null!;
-
///
- /// constructor of an answer
+ /// define a DTO for an answer for a Question with Mutiple Choice
+ /// properties :
+ /// Id : identifier in the database
+ /// Content : content of the answer
+ /// idQuestion : the id of the question which it answer to
///
- /// the content of an answer
- /// the id of an answer
- public AnswerDto(string content, int id = -1)
- {
- Content = content;
- Id = id;
- }
+ public int Id { get; set; }
+ public string Content { get; set; } = null!;
+ public int? IdQuestion { get; set; }
}
}
diff --git a/WebApi/DTOs/ChapterDto.cs b/WebApi/DTOs/ChapterDto.cs
new file mode 100644
index 0000000..a514ab7
--- /dev/null
+++ b/WebApi/DTOs/ChapterDto.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTOs
+{
+ public class ChapterDto
+ {
+ ///
+ /// define a mathematical chapter or thematic
+ /// properties :
+ /// Id : identifier in the database
+ /// Name : name of the chapter
+ ///
+ public int Id { get; set; }
+ public string Name { get; set; } = null!;
+ }
+}
diff --git a/WebApi/DTOs/LobbyDto.cs b/WebApi/DTOs/LobbyDto.cs
new file mode 100644
index 0000000..9c03514
--- /dev/null
+++ b/WebApi/DTOs/LobbyDto.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTOs
+{
+ public class LobbyDto
+ {
+ ///
+ /// define a lobby for QMC rapidity fight
+ /// properties :
+ /// Id : identifier of the lobby in the database
+ /// Name : name of the lobby
+ /// Password : password require to access at the lobby
+ /// IdCreator : identifier of the creator player
+ ///
+ public int Id { get; set; }
+ public string Name { get; set; } = null!;
+ public string Password { get; set; } = null!;
+ public int NbPlayers { get; set; }
+ public int IdCreator { get; set; }
+ }
+}
diff --git a/WebApi/DTOs/PlayerDto.cs b/WebApi/DTOs/PlayerDto.cs
new file mode 100644
index 0000000..be06345
--- /dev/null
+++ b/WebApi/DTOs/PlayerDto.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTOs
+{
+ public class PlayerDto
+ {
+ ///
+ /// define a DTO for a player
+ /// properties :
+ /// Id : identifier in the database
+ /// Nickname : nickname for a player
+ /// HashedPassword : hashed of the password of the player
+ ///
+ public int Id { get; set; }
+ public string Nickname { get; set; } = null!;
+ public string HashedPassword { get; set; } = null!;
+ }
+}
diff --git a/WebApi/DTOs/QuestionDto.cs b/WebApi/DTOs/QuestionDto.cs
new file mode 100644
index 0000000..c0eb3e4
--- /dev/null
+++ b/WebApi/DTOs/QuestionDto.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DTOs
+{
+ public class QuestionDto
+ {
+ ///
+ /// represent a mathematical question
+ /// properties :
+ /// Id : identifier of the question in the database
+ /// Content : the content of the question
+ /// Difficulty : difficulty (between 1 and 3 included) of the question
+ /// NbFails : number of time that people fail on this question
+ /// IdChapter : identifier of the chapter of the question
+ /// IdAnswerGood : identifier of the right answer to this question
+ ///
+ public int Id { get; set; }
+ public string Content { get; set; } = null!;
+ public int Difficuty { get; set; }
+ public int NbFalls { get; set; }
+ public int IdChapter { get; set; }
+ public int IdAnswerGood { get; set; }
+ }
+}
diff --git a/WebApi/Entities/AdministratorEntity.cs b/WebApi/Entities/AdministratorEntity.cs
new file mode 100644
index 0000000..8ee63ac
--- /dev/null
+++ b/WebApi/Entities/AdministratorEntity.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Entities
+{
+ public class AdministratorEntity
+ {
+ ///
+ /// define an entity for an administrator
+ /// properties :
+ /// Id : identifier in the database
+ /// Username : username for a player
+ /// HashedPassword : hashed of the password of the player
+ ///
+ [Key]
+ public int Id { get; set; }
+ public string Username { get; set; } = null!;
+ public string HashedPassword { get; set; } = null!;
+ }
+}
diff --git a/WebApi/Entities/AnswerEntity.cs b/WebApi/Entities/AnswerEntity.cs
index b5a6b21..5395dbc 100644
--- a/WebApi/Entities/AnswerEntity.cs
+++ b/WebApi/Entities/AnswerEntity.cs
@@ -1,19 +1,22 @@
-using System.ComponentModel.DataAnnotations.Schema;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
namespace Entities
{
public class AnswerEntity
{
///
- /// define an entity of an answer for a Question with Mutiple Choice
+ /// define an entity for an answer for a Question with Mutiple Choice
/// properties :
/// Id : identifier in the database
/// Content : content of the answer
+ /// idQuestion : the id of the question which it answer to
///
+ [Key]
public int Id { get; set; }
public string Content { get; set; } = null!;
[ForeignKey(nameof(QuestionEntity))]
- public int IdQuestion { get; set; }
+ public int? IdQuestion { get; set; }
}
}
diff --git a/WebApi/Entities/ChapterEntity.cs b/WebApi/Entities/ChapterEntity.cs
new file mode 100644
index 0000000..fa608dd
--- /dev/null
+++ b/WebApi/Entities/ChapterEntity.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Entities
+{
+ public class ChapterEntity
+ {
+ ///
+ /// define a mathematical chapter or thematic
+ /// properties :
+ /// Id : identifier in the database
+ /// Name : name of the chapter
+ ///
+ [Key]
+ public int Id { get; set; }
+ public string Name { get; set; } = null!;
+ }
+}
diff --git a/WebApi/Entities/LobbyEntity.cs b/WebApi/Entities/LobbyEntity.cs
new file mode 100644
index 0000000..a999e52
--- /dev/null
+++ b/WebApi/Entities/LobbyEntity.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Entities
+{
+ public class LobbyEntity
+ {
+ ///
+ /// define a lobby for QMC rapidity fight
+ /// properties :
+ /// Id : identifier of the lobby in the database
+ /// Name : name of the lobby
+ /// Password : password require to access at the lobby
+ /// IdCreator : identifier of the creator player
+ ///
+ [Key]
+ public int Id { get; set; }
+ public string Name { get; set; } = null!;
+ public string Password { get; set; } = null!;
+ public int NbPlayers { get; set; }
+
+ [ForeignKey(nameof(PlayerEntity))]
+ public int IdCreator { get; set; }
+ }
+}
diff --git a/WebApi/Entities/PlayerEntity.cs b/WebApi/Entities/PlayerEntity.cs
new file mode 100644
index 0000000..9aa0411
--- /dev/null
+++ b/WebApi/Entities/PlayerEntity.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Entities
+{
+ public class PlayerEntity
+ {
+ ///
+ /// define an entity for a player
+ /// properties :
+ /// Id : identifier in the database
+ /// Nickname : nickname for a player
+ /// HashedPassword : hashed of the password of the player
+ ///
+ [Key]
+ public int Id { get; set; }
+ public string Nickname { get; set; } = null!;
+ public string HashedPassword { get; set; } = null!;
+ }
+}
diff --git a/WebApi/Entities/QuestionEntity.cs b/WebApi/Entities/QuestionEntity.cs
index 38605d0..b01c0d0 100644
--- a/WebApi/Entities/QuestionEntity.cs
+++ b/WebApi/Entities/QuestionEntity.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
@@ -9,10 +10,23 @@ namespace Entities
{
public class QuestionEntity
{
+ ///
+ /// represent a mathematical question
+ /// properties :
+ /// Id : identifier of the question in the database
+ /// Content : the content of the question
+ /// Difficulty : difficulty (between 1 and 3 included) of the question
+ /// NbFails : number of time that people fail on this question
+ /// IdChapter : identifier of the chapter of the question
+ /// IdAnswerGood : identifier of the right answer to this question
+ ///
+ [Key]
public int Id { get; set; }
- public string Content { get; set; }
- public int difficuty { get; set; }
+ public string Content { get; set; } = null!;
+ public int Difficuty { get; set; }
public int NbFalls { get; set; }
+
+ [ForeignKey(nameof(ChapterEntity))]
public int IdChapter { get; set; }
[ForeignKey(nameof(AnswerEntity))]
diff --git a/WebApi/ManagerInterfaces/IAnswerManager.cs b/WebApi/ManagerInterfaces/IAnswerManager.cs
index 3da9c98..758c1c1 100644
--- a/WebApi/ManagerInterfaces/IAnswerManager.cs
+++ b/WebApi/ManagerInterfaces/IAnswerManager.cs
@@ -25,7 +25,7 @@ namespace ManagerInterfaces
/// this page (or null if (nb-1)*count
/// is outside boundaries (0, getNbElement()-1)
///
- public IEnumerable? getAnswers(int nb, int count, AnswerOrderCriteria orderCriteria = AnswerOrderCriteria.ById);
+ public Task<(int nbAnswer, IEnumerable? answers)> getAnswers(int nb, int count, AnswerOrderCriteria orderCriteria = AnswerOrderCriteria.ById);
///
/// get a T element with an id
///
@@ -33,7 +33,7 @@ namespace ManagerInterfaces
///
/// a set of all T element that correspond to this question
///
- public ReadOnlyCollection? getAnswersByIdQuestion(long id);
+ public Task?> getAnswersByIdQuestion(long id);
///
/// modified a T element with an id
///
@@ -43,7 +43,7 @@ namespace ManagerInterfaces
/// the T element (modified) that corresponde
/// to the id or null if there isn't any
///
- public T? modifierAnswer(long id, T answer);
+ public Task modifierAnswer(long id, T answer);
///
/// delete a T element with an id
///
@@ -52,12 +52,12 @@ namespace ManagerInterfaces
/// the T element deleted that corresponde
/// to the id or null if there isn't any
///
- public T? supprimerAnswer(long id);
+ public Task supprimerAnswer(long id);
///
/// delete a T element
///
/// the T element to delete
- public void supprimerAnswer(T answer);
+ public Task supprimerAnswer(T answer);
///
/// add a T element
///
@@ -66,6 +66,6 @@ namespace ManagerInterfaces
/// the T element (modified) that corresponde
/// to the id or null if there isn't any
///
- public T ajouterAnswer(T answer);
+ public Task ajouterAnswer(T answer);
}
}
diff --git a/WebApi/ManagerInterfaces/IChapterManager.cs b/WebApi/ManagerInterfaces/IChapterManager.cs
new file mode 100644
index 0000000..132dc38
--- /dev/null
+++ b/WebApi/ManagerInterfaces/IChapterManager.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ManagerInterfaces
+{
+ public interface IChapterManager
+ {
+ Task ajouterChapitre(T chapter);
+
+ Task supprimerChapitre(T chapter);
+
+ Task<(int nbChapter, ReadOnlyCollection)> getChapters();
+ }
+}
diff --git a/WebApi/Model/Administrator.cs b/WebApi/Model/Administrator.cs
new file mode 100644
index 0000000..d325829
--- /dev/null
+++ b/WebApi/Model/Administrator.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace model
+{
+ public class Administrator
+ {
+ ///
+ /// define a DTO for an administrator
+ /// attributes :
+ /// id : identifier in the database
+ /// username : username for a player
+ /// hashedPassword : hashed of the password of the player
+ ///
+ private int id;
+ private string? username;
+ private string hashedPassword;
+ ///
+ /// getters and setters for attributes
+ ///
+ public int Id
+ {
+ get => id;
+ private set { id = value < 0 ? 0 : value; }
+ }
+ public string Username
+ {
+ get { return username == null ? "" : username; }
+ private set { username = value == "" ? null : value; }
+ }
+ public string HashedPassword
+ {
+ get => hashedPassword;
+ set { hashedPassword = value; }
+ }
+
+ public Administrator(string username, string hashedPassword, int id)
+ {
+ this.Username = username;
+ this.HashedPassword = hashedPassword;
+ this.Id = id;
+ }
+ }
+}
diff --git a/WebApi/Model/Answer.cs b/WebApi/Model/Answer.cs
index dbe80e6..01c100d 100644
--- a/WebApi/Model/Answer.cs
+++ b/WebApi/Model/Answer.cs
@@ -1,53 +1,19 @@
-namespace Model
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace model
{
- ///
- /// define an answer for a Question with Mutiple Choice
- /// variable :
- /// id : identifier in the database
- /// content : content of the answer
- ///
public class Answer
{
- private int id;
- private string? content;
- ///
- /// property for id manipulations
- ///
- public int Id
- {
- get
- {
- return id;
- }
- private set
- {
- id = value < -1 ? -1 : value;
- }
- }
- ///
- /// property for content manipulations
- ///
- public string Content
- {
- get
- {
- return content == null ? "" : content;
- }
- set
- {
- content = value == "" ? null : value;
- }
- }
-
///
- /// constructor of an answer
+ /// define a DTO for an answer for a Question with Mutiple Choice
+ /// properties :
+ /// Id : identifier in the database
+ /// Content : content of the answer
+ /// idQuestion : the id of the question which it answer to
///
- /// the content of an answer
- /// the id of an answer
- public Answer(string content, int id = -1)
- {
- Id = id;
- Content = content;
- }
+ public int Id { get; set; }
+ public string Content { get; set; } = null!;
+ public int? IdQuestion { get; set; }
}
}
diff --git a/WebApi/Model/Chapter.cs b/WebApi/Model/Chapter.cs
new file mode 100644
index 0000000..bf5cc35
--- /dev/null
+++ b/WebApi/Model/Chapter.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace model
+{
+ public class Chapter
+ {
+ ///
+ /// define a mathematical chapter or thematic
+ /// properties :
+ /// Id : identifier in the database
+ /// Name : name of the chapter
+ ///
+ public int Id { get; set; }
+ public string Name { get; set; } = null!;
+ }
+}
diff --git a/WebApi/Model/Lobby.cs b/WebApi/Model/Lobby.cs
new file mode 100644
index 0000000..83da300
--- /dev/null
+++ b/WebApi/Model/Lobby.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace model
+{
+ public class Lobby
+ {
+ ///
+ /// define a lobby for QMC rapidity fight
+ /// properties :
+ /// Id : identifier of the lobby in the database
+ /// Name : name of the lobby
+ /// Password : password require to access at the lobby
+ /// idCreator : identifier of the creator player
+ ///
+ public int Id { get; set; }
+ public string Name { get; set; } = null!;
+ public string Password { get; set; } = null!;
+ public int NbPlayers { get; set; }
+ public int idCreator { get; set; }
+ }
+}
diff --git a/WebApi/Model/Player.cs b/WebApi/Model/Player.cs
new file mode 100644
index 0000000..5d641ac
--- /dev/null
+++ b/WebApi/Model/Player.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace model
+{
+ public class Player
+ {
+ ///
+ /// define a DTO for a player
+ /// properties :
+ /// Id : identifier in the database
+ /// Nickname : nickname for a player
+ /// HashedPassword : hashed of the password of the player
+ ///
+ public int Id { get; set; }
+ public string Nickname { get; set; } = null!;
+ public string HashedPassword { get; set; } = null!;
+ }
+}
diff --git a/WebApi/Model/Question.cs b/WebApi/Model/Question.cs
new file mode 100644
index 0000000..275659a
--- /dev/null
+++ b/WebApi/Model/Question.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace model
+{
+ public class Question
+ {
+ ///
+ /// represent a mathematical question
+ /// properties :
+ /// Id : identifier of the question in the database
+ /// Content : the content of the question
+ /// Difficulty : difficulty (between 1 and 3 included) of the question
+ /// NbFails : number of time that people fail on this question
+ /// IdChapter : identifier of the chapter of the question
+ /// IdAnswerGood : identifier of the right answer to this question
+ ///
+ public int Id { get; set; }
+ public string Content { get; set; } = null!;
+ public int Difficuty { get; set; }
+ public int NbFalls { get; set; }
+ public int IdChapter { get; set; }
+ public int IdAnswerGood { get; set; }
+ }
+}
diff --git a/WebApi/UnitTestsEntityManagers/UnitTestAnswerManager.cs b/WebApi/UnitTestsEntityManagers/UnitTestAnswerManager.cs
index 4eaf450..7526de7 100644
--- a/WebApi/UnitTestsEntityManagers/UnitTestAnswerManager.cs
+++ b/WebApi/UnitTestsEntityManagers/UnitTestAnswerManager.cs
@@ -8,7 +8,7 @@ namespace UnitTestsEntityManagers
public class UnitTestAnswerManager : AbstractUnitTestEM
{
IEnumerable answers = JsonConvert
- .DeserializeObject>
+ .DeserializeObject>
(File.ReadAllTextAsync("../fake-Answers.json").Result)!; // if this is null, we don't want to continue
AnswerEntityManager mgr;