|
|
@ -18,6 +18,7 @@ using IO.Swagger.Attributes; |
|
|
|
using IO.Swagger.Security; |
|
|
|
using IO.Swagger.Security; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using IO.Swagger.DTO; |
|
|
|
using IO.Swagger.DTO; |
|
|
|
|
|
|
|
using EPAServeur.IServices; |
|
|
|
|
|
|
|
|
|
|
|
namespace IO.Swagger.Controllers |
|
|
|
namespace IO.Swagger.Controllers |
|
|
|
{ |
|
|
|
{ |
|
|
@ -26,7 +27,12 @@ namespace IO.Swagger.Controllers |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
[ApiController] |
|
|
|
[ApiController] |
|
|
|
public class CollaborateursApiController : ControllerBase |
|
|
|
public class CollaborateursApiController : ControllerBase |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
private readonly ICollaborateurService collaborateurService; |
|
|
|
|
|
|
|
public CollaborateursApiController(ICollaborateurService _collaborateurService) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
collaborateurService = _collaborateurService; |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -37,29 +43,40 @@ namespace IO.Swagger.Controllers |
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
[HttpGet] |
|
|
|
[HttpGet] |
|
|
|
[Route("/api/collaborateurs/{idCollaborateur}")] |
|
|
|
[Route("/api/collaborateurs/{idCollaborateur}")] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[ValidateModelState] |
|
|
|
[ValidateModelState] |
|
|
|
[SwaggerOperation("GetCollaborateurById")] |
|
|
|
[SwaggerOperation("GetCollaborateurById")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
|
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
|
|
public virtual IActionResult GetCollaborateurById([FromRoute][Required]Guid? idCollaborateur) |
|
|
|
public virtual IActionResult GetCollaborateurById([FromRoute][Required]Guid? idCollaborateur) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
// return StatusCode(200, default(CollaborateurDTO)); |
|
|
|
// return StatusCode(200, default(CollaborateurDTO)); |
|
|
|
|
|
|
|
Console.WriteLine("COUCOU"); |
|
|
|
|
|
|
|
CollaborateurDTO collaborateurDTO = collaborateurService.GetCollaborateurById(idCollaborateur); |
|
|
|
|
|
|
|
if( collaborateurDTO == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Code = "404", |
|
|
|
|
|
|
|
Message = "Le collaborateur n'existe pas", |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return StatusCode(404, erreurDTO); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return StatusCode(200, collaborateurDTO); |
|
|
|
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
//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)); |
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
|
|
|
|
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
// return StatusCode(404, default(ErreurDTO)); |
|
|
|
// return StatusCode(404, default(ErreurDTO)); |
|
|
|
string exampleJson = null; |
|
|
|
/*string exampleJson = null; |
|
|
|
exampleJson = "{\n \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\n },\n \"mailApside\" : \"\",\n \"dateArrivee\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"dateDepart\" : \"2000-01-23T04:56:07.000+00:00\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n}"; |
|
|
|
exampleJson = "{\n \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\n },\n \"mailApside\" : \"\",\n \"dateArrivee\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"dateDepart\" : \"2000-01-23T04:56:07.000+00:00\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n}"; |
|
|
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
var example = exampleJson != null |
|
|
|
? JsonConvert.DeserializeObject<CollaborateurDTO>(exampleJson) |
|
|
|
? JsonConvert.DeserializeObject<CollaborateurDTO>(exampleJson) |
|
|
|
: default(CollaborateurDTO); //TODO: Change the data returned |
|
|
|
: default(CollaborateurDTO); //TODO: Change the data returned |
|
|
|
return new ObjectResult(example); |
|
|
|
return new ObjectResult(example);*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -71,7 +88,7 @@ namespace IO.Swagger.Controllers |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
[HttpGet] |
|
|
|
[HttpGet] |
|
|
|
[Route("/api/collaborateurs/{mail}")] |
|
|
|
[Route("/api/collaborateurs/mail/{mail}")] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[ValidateModelState] |
|
|
|
[ValidateModelState] |
|
|
|
[SwaggerOperation("GetCollaborateurByMail")] |
|
|
|
[SwaggerOperation("GetCollaborateurByMail")] |
|
|
@ -183,7 +200,7 @@ namespace IO.Swagger.Controllers |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
[HttpGet] |
|
|
|
[HttpGet] |
|
|
|
[Route("/api/collaborateurs/{mail}/profil")] |
|
|
|
[Route("/api/collaborateurs/profil/{mail}/")] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[ValidateModelState] |
|
|
|
[ValidateModelState] |
|
|
|
[SwaggerOperation("GetProfilCollaborateurByMail")] |
|
|
|
[SwaggerOperation("GetProfilCollaborateurByMail")] |
|
|
|