Route user entièrement fonctionnelles
continuous-integration/drone/push Build is failing Details

pull/6/head
Kevin MONDEJAR 3 weeks ago
parent f53718694e
commit 48c12241d8

@ -129,8 +129,13 @@ namespace Contextlib
return user; return user;
} }
public async Task RemoveUser(Users user) public async Task RemoveUser(int id)
{ {
Users? user = _repo.GetById(id);
if (user == null)
{
throw new KeyNotFoundException($"Error : No users found with the ID: {id}.");
}
_repo.Delete(user); _repo.Delete(user);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
} }

@ -206,7 +206,7 @@ namespace Dto2Entities
user.Password = item.Password; user.Password = item.Password;
user.Email = item.Email; user.Email = item.Email;
user.date = item.Created; user.date = item.Created;
user.ImageProfil = item.Images.ImgPath; // image null avec put user.ImageProfil = item.Images.ImgPath;
return user; return user;
} }

@ -82,9 +82,9 @@ namespace ServicesApi
return userService.GetUserByUsername(username).Result.ToDto(); return userService.GetUserByUsername(username).Result.ToDto();
} }
public async Task RemoveUser(UserDTO user) public async Task RemoveUser(int id)
{ {
await userService.RemoveUser(user.ToEntity()); await userService.RemoveUser(id);
} }
public async Task SetAdminRole(bool isAdmin) public async Task SetAdminRole(bool isAdmin)

@ -39,7 +39,7 @@ namespace Shared
// Removes a user from the system based on their unique identifier ('userId'). // Removes a user from the system based on their unique identifier ('userId').
// 'userId' is the unique identifier of the user to be removed. // 'userId' is the unique identifier of the user to be removed.
Task RemoveUser(TUser user); Task RemoveUser(int id);
// Retrieves the hashed password for a given username. // Retrieves the hashed password for a given username.
// 'username' is the username for which the password hash is to be retrieved. // 'username' is the username for which the password hash is to be retrieved.

@ -92,8 +92,9 @@ namespace StubApi
return _users.FirstOrDefault(u => u.Pseudo == username); return _users.FirstOrDefault(u => u.Pseudo == username);
} }
public async Task RemoveUser(UserDTO user) public async Task RemoveUser(int id)
{ {
var user = await GetUserById(id);
_users.Remove(user); _users.Remove(user);
} }

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class migration1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

@ -638,9 +638,9 @@ namespace WfApi.Controllers
return NotFound(new { message = "Player not found." }); return NotFound(new { message = "Player not found." });
} }
_user.RemoveUser(existingPlayer); await _user.RemoveUser(id);
return Ok(new { message = $"Player {id} deleted successfully." }); return Ok(new { message = $"User {id} deleted successfully." });
} }
catch (Exception) catch (Exception)
{ {

Loading…
Cancel
Save