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();
public static AdministratorEntity ToEntity(this AdministratorDto a)
=> a.ToModel().ToEntity();
public static string ToString(this AdministratorDto dto)
{
return $"{dto.Id} : {dto.Username}";
}
}
}

@ -18,13 +18,13 @@ namespace ExtensionsClassLibrairie
{
// conversion methods
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)
=> new Answer(a.Content, a.Question?.ToModel(), a.Id);
=> new Answer(a.Content, a.IdQuestion, a.Id);
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)
=> 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
public static AnswerDto ToDto(this AnswerEntity a)

@ -17,14 +17,13 @@ namespace ExtensionsClassLibrairie
{
// conversion methods
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)
=> 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)
=> new LobbyDto
{
Id = l.Id,
Creator = l.Creator.ToDto(),
IdCreator = l.IdCreator,
Name = l.Name,
Password = l.Password,
@ -34,7 +33,6 @@ namespace ExtensionsClassLibrairie
=> new LobbyEntity
{
Id = l.Id,
Creator = l.Creator.ToEntity(),
IdCreator = l.IdCreator,
Name = l.Name,
Password = l.Password,

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

Loading…
Cancel
Save