diff --git a/WF-WebAdmin/WF-WebAdmin/Model/Commentary.cs b/WF-WebAdmin/WF-WebAdmin/Model/Commentary.cs new file mode 100644 index 0000000..c3251c3 --- /dev/null +++ b/WF-WebAdmin/WF-WebAdmin/Model/Commentary.cs @@ -0,0 +1,10 @@ +namespace WF_WebAdmin.Model +{ + public class Commentary + { + public int Id { get; set; } + public int IdUser { get; set; } + public string Text { get; set; } + public DateTime DateCreation { get; set; } + } +} diff --git a/WF-WebAdmin/WF-WebAdmin/Model/User.cs b/WF-WebAdmin/WF-WebAdmin/Model/User.cs index d599e5b..05671ab 100644 --- a/WF-WebAdmin/WF-WebAdmin/Model/User.cs +++ b/WF-WebAdmin/WF-WebAdmin/Model/User.cs @@ -3,10 +3,13 @@ public class User { 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 Boolean IsAdmin { get; set; } + public List Comments { get; set; } } } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor index 47af991..fe1c3fa 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor @@ -14,13 +14,44 @@

Identifiant d'utilisateur : @user.Id

-

Nom d'utilisateur : @user.Name

+ @if (user.IsAdmin) + { +

Nom d'utilisateur : @user.Name (Administrateur)

+ } + else + { +

Nom d'utilisateur : @user.Name

+ } +

Email de l'utilisateur : @user.Email

Date de création de l'utilisateur : @user.DateCreation.ToShortDateString()

+ + @if(user.Comments != null) + { + @foreach (var comment in user.Comments) + { +

Commentaire (@comment.) : @comment.Text

+ } + } + else + { +

Aucun commentaires

+ } + + + @if (!user.IsAdmin) + { + + } + else + { + + } +
} - + @if (showPopup) {
@@ -32,6 +63,18 @@
} + + @if (showPopupAdmin) + { +
+
+

Êtes-vous sûr de vouloir changer le rôle de cet utilisateur ?

+ + +
+
+ } + } else diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs index 0743f27..8c8a98f 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/DeleteUser.razor.cs @@ -11,6 +11,9 @@ namespace WF_WebAdmin.Pages private bool showPopup = false; private User userToDelete = null; + + private bool showPopupAdmin = false; + private User userToAdmin = null; [Inject] public HttpClient Http { get; set; } @@ -27,7 +30,6 @@ namespace WF_WebAdmin.Pages private void ShowConfirmation(User user) { - // Afficher la modale et mémoriser l'utilisateur à supprimer userToDelete = user; showPopup = true; } @@ -47,6 +49,39 @@ namespace WF_WebAdmin.Pages { showPopup = false; } + + + + + + private void ShowConfirmationAdmin(User user) + { + userToAdmin = user; + showPopupAdmin = true; + } + + + + private async Task Admin() + { + if (!userToAdmin.IsAdmin) + { + userToAdmin.IsAdmin = true; + ClosePopupAdmin(); + } + else + { + userToAdmin.IsAdmin = false; + ClosePopupAdmin(); + } + } + + private void ClosePopupAdmin() + { + showPopupAdmin = false; + } + + } } diff --git a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs index a42112a..5e061c5 100644 --- a/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs +++ b/WF-WebAdmin/WF-WebAdmin/Pages/ValidQuote.razor.cs @@ -13,7 +13,7 @@ namespace WF_WebAdmin.Pages { // Chaîne de connexion à adapter private const string connectionString = - "Host=localhost;Port=5432;Database=wikifantasy3;Username=postgres;Password=postgres"; + "Host=londres;Port=5432;Database=dbkentin;Username=kentin;Password=passwd"; private List quotes; diff --git a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json index 60632fc..519f6ca 100644 --- a/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json +++ b/WF-WebAdmin/WF-WebAdmin/wwwroot/fake-dataUser.json @@ -2,30 +2,161 @@ { "Id": 1, "Image": "https://tse4.mm.bing.net/th/id/OIP.fc5TQflh0cbxB1GUeOdk6gHaK8?w=123&h=180&c=7&r=0&o=5&pid=1.7", - "Name": "Demo", - "Email": "demo@gmail.com", - "DateCreation": "2024-12-12" - + "Name": "Admin", + "Email": "admin@gmail.com", + "DateCreation": "2024-12-12", + "IsAdmin": true }, { "Id": 2, "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", "Name": "exploit", "Email": "exploit@gmail.com", - "DateCreation": "2024-11-12" + "DateCreation": "2024-11-12", + "IsAdmin": true }, { "Id": 3, "Image": "https://tse4.mm.bing.net/th/id/OIP.XNQPKwc1OUfvnSO9MsxDYgHaE7?w=202&h=180&c=7&r=0&o=5&pid=1.7", "Name": "testeur", "Email": "testeur@gmail.com", - "DateCreation": "2024-08-02" + "DateCreation": "2024-08-02", + "IsAdmin": false }, { "Id": 4, - "Image": "https://tse2.mm.bing.net/th/id/OIP.3vXkEUJ9J8s-GsnBC6I3KAHaF0?w=185&h=180&c=7&r=0&o=5&pid=1.7", + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", "Name": "dev", "Email": "dev@gmail.com", - "DateCreation": "2024-10-10" + "DateCreation": "2024-10-10", + "IsAdmin": false + }, + { + "Id": 5, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "jean_doe", + "Email": "jean.doe@gmail.com", + "DateCreation": "2024-06-25", + "IsAdmin": false + }, + { + "Id": 6, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "jane_smith", + "Email": "jane.smith@gmail.com", + "DateCreation": "2024-07-15", + "IsAdmin": false + }, + { + "Id": 7, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "admin_joe", + "Email": "admin.joe@gmail.com", + "DateCreation": "2024-05-30", + "IsAdmin": true + }, + { + "Id": 8, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "dev_anna", + "Email": "dev.anna@gmail.com", + "DateCreation": "2024-09-05", + "IsAdmin": false + }, + { + "Id": 9, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "support_mark", + "Email": "support.mark@gmail.com", + "DateCreation": "2024-11-20", + "IsAdmin": false + }, + { + "Id": 10, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "dev_susan", + "Email": "dev.susan@gmail.com", + "DateCreation": "2024-08-12", + "IsAdmin": false + }, + { + "Id": 11, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "designer_steve", + "Email": "designer.steve@gmail.com", + "DateCreation": "2024-07-01", + "IsAdmin": false + }, + { + "Id": 12, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "admin_lucas", + "Email": "admin.lucas@gmail.com", + "DateCreation": "2024-09-22", + "IsAdmin": true + }, + { + "Id": 13, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "manager_anna", + "Email": "manager.anna@gmail.com", + "DateCreation": "2024-05-01", + "IsAdmin": false + }, + { + "Id": 14, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "developer_mike", + "Email": "developer.mike@gmail.com", + "DateCreation": "2024-11-02", + "IsAdmin": false + }, + { + "Id": 15, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "test_user_01", + "Email": "test.user01@gmail.com", + "DateCreation": "2024-06-10", + "IsAdmin": false + }, + { + "Id": 16, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "admin_kate", + "Email": "admin.kate@gmail.com", + "DateCreation": "2024-04-16", + "IsAdmin": true + }, + { + "Id": 17, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "support_olivia", + "Email": "support.olivia@gmail.com", + "DateCreation": "2024-07-30", + "IsAdmin": false + }, + { + "Id": 18, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "assistant_jack", + "Email": "assistant.jack@gmail.com", + "DateCreation": "2024-10-03", + "IsAdmin": false + }, + { + "Id": 19, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "developer_bob", + "Email": "developer.bob@gmail.com", + "DateCreation": "2024-06-01", + "IsAdmin": false + }, + { + "Id": 20, + "Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137&h=195&c=7&r=0&o=5&pid=1.7", + "Name": "admin_sophie", + "Email": "admin.sophie@gmail.com", + "DateCreation": "2024-12-05", + "IsAdmin": true } ] \ No newline at end of file