From 4fdfc87290076714248535c7fe0035285233d331 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Thu, 9 Jan 2025 08:54:15 +0100 Subject: [PATCH] =?UTF-8?q?DTO=20user=20et=20Quote=20termin=C3=A9=20avec?= =?UTF-8?q?=20extensions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WF-WebAdmin/WF-WebAdmin/Converter/AdminDTO.cs | 7 --- .../WF-WebAdmin/Converter/AdminExtension.cs | 6 --- WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs | 44 ++++--------------- .../WF-WebAdmin/Converter/QuoteExtension.cs | 2 +- WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs | 20 +++++++++ .../WF-WebAdmin/Converter/UserExtension.cs | 19 ++++++++ WF-WebAdmin/WF-WebAdmin/Model/Quote.cs | 13 ++++++ WF-WebAdmin/WF-WebAdmin/Model/User.cs | 9 ++++ WF-WebAdmin/WF-WebAdmin/appsettings.json | 15 ++++--- 9 files changed, 79 insertions(+), 56 deletions(-) delete mode 100644 WF-WebAdmin/WF-WebAdmin/Converter/AdminDTO.cs delete mode 100644 WF-WebAdmin/WF-WebAdmin/Converter/AdminExtension.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs create mode 100644 WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/AdminDTO.cs b/WF-WebAdmin/WF-WebAdmin/Converter/AdminDTO.cs deleted file mode 100644 index 4356cfe..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Converter/AdminDTO.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace WF_WebAdmin.Converter -{ - public class AdminDTO - { - - } -} diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/AdminExtension.cs b/WF-WebAdmin/WF-WebAdmin/Converter/AdminExtension.cs deleted file mode 100644 index 9b6ef16..0000000 --- a/WF-WebAdmin/WF-WebAdmin/Converter/AdminExtension.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace WF_WebAdmin.Converter -{ - public class AdminExtension - { - } -} diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs index d2f3a58..f8b0fea 100644 --- a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs +++ b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteDTO.cs @@ -18,42 +18,14 @@ namespace WF_WebAdmin.Converter public QuoteDTO(int id_quote, string content, int likes, string langue, bool isValide, string? reason, int id_caracter, int id_source, int? id_user_verif) { this.Id = id_quote; - } - - public int getId_quote() - { - return id_quote; - } - public string getContent() { - return content; - } - public int getLikes() - { - return likes; - } - public string getLangue() - { - return langue; - } - public bool getIsValide() - { - return isValide; - } - public string? getReason() - { - return reason; - } - public int getIdCaracter() - { - return id_caracter; - } - public int getIdSource() - { - return id_source; - } - public int? getIdUserVerif() - { - return id_user_verif; + this.Content = content; + this.Likes = likes; + this.Langue = langue; + this.IsValide = isValide; + this.Reason = reason; + this.IdCaracter = id_caracter; + this.IdSource = id_source; + this.IdUserVerif = id_user_verif; } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs index c3401f3..0f3b187 100644 --- a/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs +++ b/WF-WebAdmin/WF-WebAdmin/Converter/QuoteExtension.cs @@ -12,7 +12,7 @@ namespace WF_WebAdmin.Converter public Quote DTOToQuote(QuoteDTO q) { - Quote quote = new Quote(); + Quote quote = new Quote(q.Id, q.Content, q.Likes, q.Langue, q.IsValide, q.Reason, q.IdCaracter, q.IdSource, q.IdUserVerif); return quote; } } diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs b/WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs new file mode 100644 index 0000000..e1b64da --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Converter/UserDTO.cs @@ -0,0 +1,20 @@ +namespace WF_WebAdmin.Converter +{ + public class UserDTO + { + public int Id { get; set; } + public string Image { get; set; } + public string Name { get; set; } + public string Email { get; set; } + public DateTime DateCreation { get; set; } + + public UserDTO(int id, string image, string name, string email, DateTime dateCreation) + { + this.Id = id; + this.Image = image; + this.Name = name; + this.Email = email; + this.DateCreation = dateCreation; + } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs b/WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs new file mode 100644 index 0000000..4ff0937 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Converter/UserExtension.cs @@ -0,0 +1,19 @@ +using WF_WebAdmin.Model; + +namespace WF_WebAdmin.Converter +{ + public class UserExtension + { + public User UserToDTO(UserDTO u) + { + User user = new User(u.Id, u.Image, u.Name, u.Email, u.DateCreation); + return user; + } + + public UserDTO DTOToUser(User u) + { + UserDTO user = new UserDTO(u.Id, u.Image, u.Name, u.Email, u.DateCreation); + return user; + } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs b/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs index 4e3d711..c640723 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/Quote.cs @@ -24,5 +24,18 @@ IdSource = idSource; IdUserVerif = idUserVerif; } + + public Quote(int id, string content, int likes, string langue, bool isValide, string? reason, int idCaracter, int idSource, int? idUserVerif) + { + Id = id; + Content = content; + Likes = likes; + Langue = langue; + IsValide = isValide; + Reason = reason; + IdCaracter = idCaracter; + IdSource = idSource; + IdUserVerif = idUserVerif; + } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Model/User.cs b/WF-WebAdmin/WF-WebAdmin/Model/User.cs index d599e5b..7598733 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/User.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/User.cs @@ -8,5 +8,14 @@ public string Email { get; set; } public DateTime DateCreation { get; set; } + + public User(int id, string image, string name, string email, DateTime dateCreation) + { + this.Id = id; + this.Image = image; + this.Name = name; + this.Email = email; + this.DateCreation = dateCreation; + } } } diff --git a/WF-WebAdmin/WF-WebAdmin/appsettings.json b/WF-WebAdmin/WF-WebAdmin/appsettings.json index 4d56694..3ec194b 100644 --- a/WF-WebAdmin/WF-WebAdmin/appsettings.json +++ b/WF-WebAdmin/WF-WebAdmin/appsettings.json @@ -1,9 +1,12 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "ConnectionStrings": { + "DefaultConnection": "Host=localhost;Port=5432;Database=wikifantasy3;Username=postgres;Password=postgres" } - }, - "AllowedHosts": "*" }