|
|
|
@ -11,53 +11,90 @@ using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
using Swashbuckle.AspNetCore.Annotations; |
|
|
|
|
using Swashbuckle.AspNetCore.SwaggerGen; |
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
using IO.Swagger.Attributes; |
|
|
|
|
using IO.Swagger.Security; |
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
using IO.Swagger.DTO; |
|
|
|
|
using EPAServeur.IServices; |
|
|
|
|
using System.Net; |
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
using IO.Swagger.Security; |
|
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
|
|
namespace IO.Swagger.Controllers |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
[ApiController] |
|
|
|
|
public class ReferentsApiController : ControllerBase |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
private readonly IReferentService referentService; |
|
|
|
|
|
|
|
|
|
public ReferentsApiController(IReferentService _referentService) |
|
|
|
|
{ |
|
|
|
|
referentService = _referentService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <remarks>Récupérer la liste des référents d'un collaborateur</remarks> |
|
|
|
|
/// <remarks>Récupérer un referent par son id</remarks> |
|
|
|
|
/// <param name="idReferent">id referent</param> |
|
|
|
|
/// <response code="200">OK</response> |
|
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("/api/referents/{idReferent}")] |
|
|
|
|
////[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("GetReferentById")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(ReferentDTO), description: "OK")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
|
|
|
public virtual IActionResult GetReferentById([FromRoute][Required]Guid? idReferent) |
|
|
|
|
{ |
|
|
|
|
ReferentDTO referentDTO = referentService.GetReferentById(idReferent); |
|
|
|
|
if (referentDTO == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Le référent n'existe pas", |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreurDTO); |
|
|
|
|
} |
|
|
|
|
return Ok(referentDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <remarks>Récupérer la liste de tous les referents</remarks> |
|
|
|
|
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</param> |
|
|
|
|
/// <param name="idCollaborateur">id collaborateur</param> |
|
|
|
|
/// <param name="numPage">Numéro de la page du tableau qui affiche les données</param> |
|
|
|
|
/// <param name="parPAge">Nombre d'éléments affiché sur chaque page du tableau</param> |
|
|
|
|
/// <param name="fonctions">Liste des fonctions des collaborateurs que l'on veut récupérer</param> |
|
|
|
|
/// <param name="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
|
|
|
/// <param name="idBU">id de la business unit à laquelle sont rattachées les données à récupérer</param> |
|
|
|
|
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
|
|
|
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
|
|
|
/// <response code="200">OK</response> |
|
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("/api/referents/collaborateur/{idCollaborateur}")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[Route("/api/referents")] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("GetReferentByCollaborateur")] |
|
|
|
|
[SwaggerOperation("GetReferents")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<ReferentDTO>), description: "OK")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
|
|
|
public virtual IActionResult GetReferentByCollaborateur([FromQuery][Required()]bool? asc, [FromRoute][Required]Guid? idCollaborateur, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
public virtual IActionResult GetReferents([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]List<string> fonctions, [FromQuery]long? idAgence, [FromQuery]long? idBU, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
{ |
|
|
|
|
//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(List<ReferentDTO>)); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
string exampleJson = null; |
|
|
|
|
exampleJson = "[ {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\",\n \"collaborateurs\" : [ null, null ]\n}, {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\",\n \"collaborateurs\" : [ null, null ]\n} ]"; |
|
|
|
|
|
|
|
|
@ -70,73 +107,68 @@ namespace IO.Swagger.Controllers |
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <remarks>Récupérer un referent par son id</remarks> |
|
|
|
|
/// <param name="idReferent">id referent</param> |
|
|
|
|
/// <remarks>Récupérer le référent actuel d'un collaborateur</remarks> |
|
|
|
|
/// <param name="idCollaborateur">id collaborateur</param> |
|
|
|
|
/// <response code="200">OK</response> |
|
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("/api/referents/{idReferent}")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[Route("/api/referents/actuel/collaborateur/{idCollaborateur}")] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("GetReferentById")] |
|
|
|
|
[SwaggerOperation("GetReferentActuelCollaborateur")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(ReferentDTO), description: "OK")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
|
|
|
public virtual IActionResult GetReferentById([FromRoute][Required]Guid? idReferent) |
|
|
|
|
{ |
|
|
|
|
//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(ReferentDTO)); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
string exampleJson = null; |
|
|
|
|
exampleJson = "{\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\",\n \"collaborateurs\" : [ null, null ]\n}"; |
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
? JsonConvert.DeserializeObject<ReferentDTO>(exampleJson) |
|
|
|
|
: default(ReferentDTO); //TODO: Change the data returned |
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
public virtual IActionResult GetReferentActuelCollaborateur([FromRoute][Required] Guid? idCollaborateur) |
|
|
|
|
{ |
|
|
|
|
ReferentDTO referentDTO = referentService.GetReferentActuelCollaborateur(idCollaborateur); |
|
|
|
|
if (referentDTO == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucun référent pour le collaborateur", |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreurDTO); |
|
|
|
|
} |
|
|
|
|
return Ok(referentDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <remarks>Récupérer la liste de tous les referents</remarks> |
|
|
|
|
/// <remarks>Récupérer la liste des référents d'un collaborateur</remarks> |
|
|
|
|
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</param> |
|
|
|
|
/// <param name="idCollaborateur">id collaborateur</param> |
|
|
|
|
/// <param name="numPage">Numéro de la page du tableau qui affiche les données</param> |
|
|
|
|
/// <param name="parPAge">Nombre d'éléments affiché sur chaque page du tableau</param> |
|
|
|
|
/// <param name="fonctions">Liste des fonctions des collaborateurs que l'on veut récupérer</param> |
|
|
|
|
/// <param name="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
|
|
|
/// <param name="idBU">id de la business unit à laquelle sont rattachées les données à récupérer</param> |
|
|
|
|
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
|
|
|
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
|
|
|
/// <response code="200">OK</response> |
|
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("/api/referents")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[Route("/api/referents/collaborateur/{idCollaborateur}")] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("GetReferents")] |
|
|
|
|
[SwaggerOperation("GetReferentByCollaborateur")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<ReferentDTO>), description: "OK")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
public virtual IActionResult GetReferents([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]List<string> fonctions, [FromQuery]long? idAgence, [FromQuery]long? idBU, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
{ |
|
|
|
|
//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(List<ReferentDTO>)); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
string exampleJson = null; |
|
|
|
|
exampleJson = "[ {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\",\n \"collaborateurs\" : [ null, null ]\n}, {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\",\n \"collaborateurs\" : [ null, null ]\n} ]"; |
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
? JsonConvert.DeserializeObject<List<ReferentDTO>>(exampleJson) |
|
|
|
|
: default(List<ReferentDTO>); //TODO: Change the data returned |
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
|
|
|
public virtual IActionResult GetReferentsByCollaborateur([FromQuery][Required()] bool? asc, [FromRoute][Required] Guid? idCollaborateur, [FromQuery][Required()] int? numPage, [FromQuery][Required()] int? parPAge, [FromQuery] string texte, [FromQuery] string tri) |
|
|
|
|
{ |
|
|
|
|
IEnumerable<ReferentDTO> referentDTO = referentService.GetReferentsByCollaborateur(asc,idCollaborateur,numPage,parPAge,texte,tri); |
|
|
|
|
if (referentDTO.Count() == 0) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucun référent pour le collaborateur", |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreurDTO); |
|
|
|
|
} |
|
|
|
|
return Ok(referentDTO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|