Complete setAdmin method

pull/26/head
tomivt 3 months ago
parent 944c620e80
commit 85aeeb061c

@ -97,7 +97,7 @@ else
<div class="divPopup">
<div class="contentPopup">
<p>Êtes-vous sûr de vouloir changer le rôle de cet utilisateur ?</p>
<button @onclick="() => Admin()">Confirmer</button>
<button @onclick="() => setAdmin()">Confirmer</button>
<button @onclick="ClosePopup">Annuler</button>
</div>
</div>

@ -32,8 +32,8 @@ namespace WF_WebAdmin.Pages
protected override async Task OnInitializedAsync()
{
userService = new UserServiceStub($"fake-dataUsers.json");
users = await userService.GetUsersJson();
userService = new UserServiceStub();
users = await userService.getAllUser();
}
private async Task OnReadData(DataGridReadDataEventArgs<Quote> e)
@ -49,7 +49,7 @@ namespace WF_WebAdmin.Pages
if (!e.CancellationToken.IsCancellationRequested)
{
totalItem = await userService.getNbUser();
users = response.ToArray();
users = new List<User>(response.ToArray());
}
}
@ -71,16 +71,16 @@ namespace WF_WebAdmin.Pages
{
if (userToDelete != null)
{
userService = new UserServiceStub($"fake-dataUsers.json");
await userService.DeleteUserJson(userToDelete.Id);
userService = new UserServiceStub();
await userService.removeUser(userToDelete);
ClosePopup();
}
}
private async Task ModifyUser()
{
userService = new UserServiceStub($"fake-dataUsers.json");
await userService.UpdateUserJson(selectedUser);
userService = new UserServiceStub();
await userService.updateUser(selectedUser);
ClosePopup();
}
@ -102,16 +102,18 @@ namespace WF_WebAdmin.Pages
private async Task Admin()
private async Task setAdmin()
{
if (!userToAdmin.IsAdmin)
{
userToAdmin.IsAdmin = true;
await userService.updateUser(userToAdmin);
ClosePopup();
}
else
{
userToAdmin.IsAdmin = false;
await userService.updateUser(userToAdmin);
ClosePopup();
}
}

@ -5,7 +5,7 @@ namespace WF_WebAdmin.Service;
public class UserServiceStub : IUserService
{
private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake-dataUsers.json");
private readonly string _jsonFilePath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "fake_data_users.json");
public async Task saveUsersJson(List<User> users)

@ -3,7 +3,7 @@
"Id": 1,
"Image": "https://tse4.mm.bing.net/th/id/OIP.fc5TQflh0cbxB1GUeOdk6gHaK8?w=123\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Name": "admin",
"Email": "admin@gmail.com",
"Email": "adminop@gmail.com",
"DateCreation": "2024-12-12T00:00:00",
"IsAdmin": true,
"Comments": [
@ -17,15 +17,6 @@
}
]
},
{
"Id": 2,
"Image": "https://tse2.mm.bing.net/th/id/OIP.MMpXBB5RDRYQm05FJmevGAHaKl?w=137\u0026h=195\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
"Name": "exploit2",
"Email": "exploit@gmail.com",
"DateCreation": "2024-11-12T00:00:00",
"IsAdmin": true,
"Comments": null
},
{
"Id": 3,
"Image": "https://tse4.mm.bing.net/th/id/OIP.XNQPKwc1OUfvnSO9MsxDYgHaE7?w=202\u0026h=180\u0026c=7\u0026r=0\u0026o=5\u0026pid=1.7",
Loading…
Cancel
Save