You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
150 lines
5.0 KiB
150 lines
5.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Entity;
|
|
using DTO;
|
|
using System.Reflection.Metadata;
|
|
|
|
namespace Dto2Entities
|
|
{
|
|
public static class Extention
|
|
{
|
|
// --------------------------- ToDto --------------------------- \\
|
|
|
|
public static CharacterDTO ToDto(this Character item)
|
|
{
|
|
CharacterDTO character = new CharacterDTO();
|
|
character.Id = item.Id;
|
|
character.Name = item.Name;
|
|
character.imagePath = item.Images.ImgPath;
|
|
return character;
|
|
}
|
|
|
|
public static CommentaryDTO ToDto(this Commentary item)
|
|
{
|
|
CommentaryDTO commentary = new CommentaryDTO();
|
|
commentary.Id = item.Id;
|
|
commentary.Date = item.DateCommentary;
|
|
commentary.Comment = item.Comment;
|
|
commentary.User = item.User.UserName;
|
|
commentary.ImagePath = item.User.Images.ImgPath;
|
|
return commentary;
|
|
}
|
|
|
|
// Surement a refaire car Faoirite Entity modifier sur branche EF
|
|
public static FavoriteDTO ToDto(this Favorite item)
|
|
{
|
|
FavoriteDTO favorite = new FavoriteDTO();
|
|
favorite.IdUser = item.IdUsers;
|
|
favorite.IdQuote = item.IdQuote;
|
|
return favorite;
|
|
}
|
|
|
|
public static ImageDTO ToDto(this Images item)
|
|
{
|
|
ImageDTO image = new ImageDTO();
|
|
image.IdImage = item.Id;
|
|
image.ImagePath = item.ImgPath;
|
|
return image;
|
|
}
|
|
|
|
public static QuestionDTO ToDto(this Question item)
|
|
{
|
|
QuestionDTO question = new QuestionDTO();
|
|
question.Id = item.Id;
|
|
question.Question = item.Text;
|
|
question.AnswerA = item.AnswerA;
|
|
question.AnswerB = item.AnswerB;
|
|
question.AnswerC = item.AnswerC;
|
|
question.AnswerD = item.AnswerD;
|
|
question.CorrectAnswer = item.CorrectAnswer;
|
|
return question;
|
|
}
|
|
|
|
public static QuizDTO ToDto(this Quiz item)
|
|
{
|
|
QuizDTO quiz = new QuizDTO();
|
|
quiz.Id = item.Id;
|
|
quiz.NbQuestion = item.NbQuestion;
|
|
quiz.Title = item.Title;
|
|
quiz.ImagePath = item.Images.ImgPath;
|
|
return quiz;
|
|
}
|
|
|
|
// Surement a refaire car QuizQuestion Entity modifier sur branche EF
|
|
public static QuizQuestionDTO ToDto(this QuizQuestion item)
|
|
{
|
|
QuizQuestionDTO quizQuestion = new QuizQuestionDTO();
|
|
quizQuestion.IdQuiz = item.IdQuiz;
|
|
quizQuestion.IdQuestion = item.IdQuestion;
|
|
return quizQuestion;
|
|
}
|
|
|
|
public static QuoteDTO ToDto(this Quote item)
|
|
{
|
|
QuoteDTO quote = new QuoteDTO();
|
|
quote.Id = item.Id;
|
|
quote.Content = item.Content;
|
|
quote.DateSource = item.Source.Year;
|
|
quote.Character = item.Character.Name;
|
|
quote.TitleSource = item.Source.Title;
|
|
quote.Langage = item.Langage.ToDto();
|
|
quote.ImagePath = item.Character.Images.ImgPath;
|
|
quote.Like = item.Likes;
|
|
quote.Type = item.Source.TypeSrc.ToDto();
|
|
return quote;
|
|
}
|
|
|
|
public static SourceDTO ToDto(this Source item)
|
|
{
|
|
SourceDTO source = new SourceDTO();
|
|
source.Id = item.Id;
|
|
source.Date = item.Year;
|
|
source.Title = item.Title;
|
|
source.Type = item.TypeSrc.ToDto();
|
|
return source;
|
|
}
|
|
|
|
public static UserDTO ToDto(this Users item)
|
|
{
|
|
UserDTO user = new UserDTO();
|
|
user.Id = item.Id;
|
|
user.Pseudo = item.UserName;
|
|
user.Password = item.Password;
|
|
user.Email = item.Email;
|
|
user.date = item.Created;
|
|
user.ImageProfil = item.Images.ImgPath;
|
|
return user;
|
|
}
|
|
|
|
public static TypeLangageDTO ToDto(this LangEnum item)
|
|
{
|
|
switch (item)
|
|
{
|
|
case LangEnum.vf: return TypeLangageDTO.vf;
|
|
case LangEnum.vo: return TypeLangageDTO.vo;
|
|
case LangEnum.ve: return TypeLangageDTO.ve;
|
|
default: return TypeLangageDTO.vo;
|
|
}
|
|
}
|
|
|
|
public static TypeSrcEnumDTO ToDto(this TypeSrcEnum item)
|
|
{
|
|
switch (item)
|
|
{
|
|
case TypeSrcEnum.movie: return TypeSrcEnumDTO.movie;
|
|
case TypeSrcEnum.book: return TypeSrcEnumDTO.book;
|
|
case TypeSrcEnum.series: return TypeSrcEnumDTO.serie;
|
|
case TypeSrcEnum.videogame: return TypeSrcEnumDTO.videogame;
|
|
default: return TypeSrcEnumDTO.movie;
|
|
}
|
|
}
|
|
|
|
// --------------------------- ToEntity --------------------------- \\
|
|
|
|
|
|
}
|
|
}
|