|
|
@ -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 |
|
|
|
{ |
|
|
|
{ |
|
|
@ -27,6 +28,11 @@ namespace IO.Swagger.Controllers |
|
|
|
[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,7 +43,7 @@ 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")] |
|
|
@ -47,19 +53,30 @@ namespace IO.Swagger.Controllers |
|
|
|
{ |
|
|
|
{ |
|
|
|
//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")] |
|
|
|