perf : modification des méthodes d'extension
continuous-integration/drone/push Build is passing Details

API
Damien NORTIER 1 year ago
parent fd140081ad
commit 813dccecb9

@ -31,5 +31,10 @@ namespace ExtensionsClassLibrairie
=> a.ToModel().ToDto(); => a.ToModel().ToDto();
public static AdministratorEntity ToEntity(this AdministratorDto a) public static AdministratorEntity ToEntity(this AdministratorDto a)
=> a.ToModel().ToEntity(); => a.ToModel().ToEntity();
public static string ToString(this AdministratorDto dto)
{
return $"{dto.Id} : {dto.Username}";
}
} }
} }

@ -18,13 +18,13 @@ namespace ExtensionsClassLibrairie
{ {
// conversion methods // conversion methods
public static Answer ToModel(this AnswerEntity a) public static Answer ToModel(this AnswerEntity a)
=> new Answer(a.Content, a.Question?.ToModel(), a.Id); => new Answer(a.Content, a.IdQuestion , a.Id);
public static Answer ToModel(this AnswerDto a) public static Answer ToModel(this AnswerDto a)
=> new Answer(a.Content, a.Question?.ToModel(), a.Id); => new Answer(a.Content, a.IdQuestion, a.Id);
public static AnswerDto ToDto(this Answer a) public static AnswerDto ToDto(this Answer a)
=> new AnswerDto { Id = a.Id, Content = a.Content, Question = a.Question?.ToDto(), IdQuestion = a.IdQuestion }; => new AnswerDto { Id = a.Id, Content = a.Content, IdQuestion = a.IdQuestion };
public static AnswerEntity ToEntity(this Answer a) public static AnswerEntity ToEntity(this Answer a)
=> new AnswerEntity { Id = a.Id, Content = a.Content, Question = a.Question?.ToEntity(), IdQuestion = a.IdQuestion }; => new AnswerEntity { Id = a.Id, Content = a.Content, IdQuestion = a.IdQuestion };
// reuse other methods // reuse other methods
public static AnswerDto ToDto(this AnswerEntity a) public static AnswerDto ToDto(this AnswerEntity a)

@ -17,14 +17,13 @@ namespace ExtensionsClassLibrairie
{ {
// conversion methods // conversion methods
public static Lobby ToModel(this LobbyEntity l) public static Lobby ToModel(this LobbyEntity l)
=> new Lobby(l.Name, l.Creator.ToModel(), l.Password, l.NbPlayers, l.Id); => new Lobby(l.Name, l.IdCreator, l.Password, l.NbPlayers, l.Id);
public static Lobby ToModel(this LobbyDto l) public static Lobby ToModel(this LobbyDto l)
=> new Lobby(l.Name, l.Creator.ToModel(), l.Password, l.NbPlayers, l.Id); => new Lobby(l.Name, l.IdCreator, l.Password, l.NbPlayers, l.Id);
public static LobbyDto ToDto(this Lobby l) public static LobbyDto ToDto(this Lobby l)
=> new LobbyDto => new LobbyDto
{ {
Id = l.Id, Id = l.Id,
Creator = l.Creator.ToDto(),
IdCreator = l.IdCreator, IdCreator = l.IdCreator,
Name = l.Name, Name = l.Name,
Password = l.Password, Password = l.Password,
@ -34,7 +33,6 @@ namespace ExtensionsClassLibrairie
=> new LobbyEntity => new LobbyEntity
{ {
Id = l.Id, Id = l.Id,
Creator = l.Creator.ToEntity(),
IdCreator = l.IdCreator, IdCreator = l.IdCreator,
Name = l.Name, Name = l.Name,
Password = l.Password, Password = l.Password,

@ -19,24 +19,24 @@ namespace ExtensionsClassLibrairie
// conversion methods // conversion methods
public static Question ToModel(this QuestionEntity q) public static Question ToModel(this QuestionEntity q)
{ {
var tmp = new Question(q.Content, q.Chapter?.ToModel(), q.Id, q.AnswerGood?.ToModel()); var tmp = new Question(q.Content, q.IdChapter, q.Id, q.IdAnswerGood);
tmp.Difficulty = q.Difficulty; tmp.Difficulty = q.Difficulty;
tmp.NbFalls = q.NbFalls; tmp.NbFalls = q.NbFalls;
return tmp; return tmp;
} }
public static Question ToModel(this QuestionDto q) public static Question ToModel(this QuestionDto q)
{ {
var tmp = new Question(q.Content, q.Chapter?.ToModel(), q.Id, q.AnswerGood?.ToModel()); var tmp = new Question(q.Content, q.IdChapter, q.Id, q.IdAnswerGood);
tmp.Difficulty = q.Difficulty; tmp.Difficulty = q.Difficulty;
tmp.NbFalls = q.NbFalls; tmp.NbFalls = q.NbFalls;
return tmp; return tmp;
} }
public static QuestionDto ToDto(this Question q) public static QuestionDto ToDto(this Question q)
=> new QuestionDto { Id = q.Id, Content = q.Content, AnswerGood = q.AnswerGood?.ToDto(), => new QuestionDto { Id = q.Id, Content = q.Content, IdAnswerGood = q.IdAnswerGood,
Chapter = q.Chapter?.ToDto(), Difficulty = q.Difficulty, NbFalls = q.NbFalls }; IdChapter = q.IdChapter, Difficulty = q.Difficulty, NbFalls = q.NbFalls };
public static QuestionEntity ToEntity(this Question q) public static QuestionEntity ToEntity(this Question q)
=> new QuestionEntity { Id = q.Id, Content = q.Content, AnswerGood = q.AnswerGood?.ToEntity(), => new QuestionEntity { Id = q.Id, Content = q.Content, IdAnswerGood = q.IdAnswerGood,
Chapter = q.Chapter?.ToEntity(), Difficulty = q.Difficulty, NbFalls = q.NbFalls }; IdChapter = q.IdChapter, Difficulty = q.Difficulty, NbFalls = q.NbFalls };
// reuse other methods // reuse other methods
public static QuestionDto ToDto(this QuestionEntity q) public static QuestionDto ToDto(this QuestionEntity q)

Loading…
Cancel
Save