|
|
|
@ -68,7 +68,7 @@ namespace API.Controllers
|
|
|
|
|
[ProducesResponseType(typeof(string), 404)]
|
|
|
|
|
public async Task<IActionResult> DeleteUser(int id)
|
|
|
|
|
{
|
|
|
|
|
var success = dataService.userService.DeleteUser(id);
|
|
|
|
|
var success = await dataService.userService.DeleteItem(id);
|
|
|
|
|
if (success)
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation("[INFORMATION] L'utilisateur avec l'id {id} a été supprimé.", id);
|
|
|
|
@ -84,19 +84,17 @@ namespace API.Controllers
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[ProducesResponseType(typeof(UserDTO), 201)]
|
|
|
|
|
[ProducesResponseType(typeof(string), 400)]
|
|
|
|
|
public IActionResult CreateUser([FromBody] UserDTO dto)
|
|
|
|
|
public async Task<IActionResult> CreateUser([FromBody] UserDTO dto)
|
|
|
|
|
{
|
|
|
|
|
if (dto.Username == null || dto.Password == null || dto.Email == null)
|
|
|
|
|
{
|
|
|
|
|
return BadRequest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return Ok(userService.CreateUser(username, password, email, isAdmin));
|
|
|
|
|
logger.LogInformation(
|
|
|
|
|
"[INFORMATION] Un utilisateur a été créé : username - {username}, password - {password}, email - {email}, isAdmin - {isAdmin}",
|
|
|
|
|
dto.Username, dto.Password, dto.Email, dto.IsAdmin);
|
|
|
|
|
return Created(nameof(GetUsers),
|
|
|
|
|
dataService.userService.CreateUser(dto.Username, dto.Password, dto.Email, dto.IsAdmin));
|
|
|
|
|
await dataService.userService.AddItem(dto));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPut("user/{id}")]
|
|
|
|
@ -122,7 +120,7 @@ namespace API.Controllers
|
|
|
|
|
{
|
|
|
|
|
logger.LogInformation("[INFORMATION] La mise à jour de l'utilsiateur avec l'id {id} a été effectuée",
|
|
|
|
|
id);
|
|
|
|
|
return Ok(dataService.userService.UpdateUser(id, userDto));
|
|
|
|
|
return Ok(dataService.userService.UpdateItem<UserDTO>(id, userDto));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.LogError("[ERREUR] Aucun utilisateur trouvé avec l'id {id}.", id);
|
|
|
|
|