|
|
|
@ -19,6 +19,7 @@ using IO.Swagger.Security; |
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
using IO.Swagger.DTO; |
|
|
|
|
using EPAServeur.IServices; |
|
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
|
|
|
|
|
|
namespace IO.Swagger.Controllers |
|
|
|
|
{ |
|
|
|
@ -29,9 +30,11 @@ namespace IO.Swagger.Controllers |
|
|
|
|
public class CollaborateursApiController : ControllerBase |
|
|
|
|
{ |
|
|
|
|
private readonly ICollaborateurService collaborateurService; |
|
|
|
|
public CollaborateursApiController(ICollaborateurService _collaborateurService) |
|
|
|
|
private readonly ILogger<CollaborateursApiController> logger; |
|
|
|
|
public CollaborateursApiController(ICollaborateurService _collaborateurService, ILogger<CollaborateursApiController> _logger) |
|
|
|
|
{ |
|
|
|
|
collaborateurService = _collaborateurService; |
|
|
|
|
logger = _logger; |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
@ -53,10 +56,11 @@ namespace IO.Swagger.Controllers |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
|
|
logger.LogInformation("Récupération du collaborateur d'ID {idCollaborateur}", idCollaborateur); |
|
|
|
|
CollaborateurDTO collaborateurDTO = collaborateurService.GetCollaborateurById(idCollaborateur); |
|
|
|
|
if( collaborateurDTO == null) |
|
|
|
|
{ |
|
|
|
|
logger.LogWarning("Le ccollaborateur {id} est introuvable", idCollaborateur); |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
@ -64,6 +68,7 @@ namespace IO.Swagger.Controllers |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreurDTO); |
|
|
|
|
} |
|
|
|
|
logger.LogInformation("Collaborateur {id} trouvée", idCollaborateur); |
|
|
|
|
return Ok(collaborateurDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -87,10 +92,11 @@ namespace IO.Swagger.Controllers |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
|
|
logger.LogInformation("Récupération d'un collaborateur par le mail {mail}", mail); |
|
|
|
|
CollaborateurDTO collaborateurDTO = collaborateurService.GetCollaborateurByMail(mail); |
|
|
|
|
if (collaborateurDTO == null) |
|
|
|
|
{ |
|
|
|
|
logger.LogWarning("Le collaborateur {mail} est introuvable", mail); |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
@ -98,6 +104,7 @@ namespace IO.Swagger.Controllers |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreurDTO); |
|
|
|
|
} |
|
|
|
|
logger.LogInformation("Collaborateur {mail} trouvée", mail); |
|
|
|
|
return Ok(collaborateurDTO); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -127,7 +134,7 @@ namespace IO.Swagger.Controllers |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
|
|
logger.LogInformation("Récupération de la liste des collaborateurs"); |
|
|
|
|
return Ok(collaborateurService.GetCollaborateurs(asc, numPage, parPAge, fonctions, idAgence, idBU, texte, tri)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|