|
|
|
@ -3,7 +3,7 @@ |
|
|
|
|
* |
|
|
|
|
* API qui sra utilisée afin de faire communiquer le client et le serveur ainsi que le serveur et la boîte noire. |
|
|
|
|
* |
|
|
|
|
* OpenAPI spec version: 1.3.2 |
|
|
|
|
* OpenAPI spec version: 1.3.3 |
|
|
|
|
* |
|
|
|
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
|
|
|
*/ |
|
|
|
@ -18,6 +18,8 @@ using IO.Swagger.Attributes; |
|
|
|
|
using IO.Swagger.Security; |
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
using IO.Swagger.DTO; |
|
|
|
|
using EPAServeur.Services; |
|
|
|
|
using EPAServeur.IServices; |
|
|
|
|
|
|
|
|
|
namespace IO.Swagger.Controllers |
|
|
|
|
{ |
|
|
|
@ -26,7 +28,14 @@ namespace IO.Swagger.Controllers |
|
|
|
|
/// </summary> |
|
|
|
|
[ApiController] |
|
|
|
|
public class NotesApiController : ControllerBase |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
private readonly INoteService noteService; |
|
|
|
|
|
|
|
|
|
public NotesApiController(INoteService _noteService) |
|
|
|
|
{ |
|
|
|
|
noteService = _noteService; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
@ -37,7 +46,7 @@ namespace IO.Swagger.Controllers |
|
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
|
[HttpDelete] |
|
|
|
|
[Route("/api/notes/{idNote}/supprimer")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("DeleteNote")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
@ -66,35 +75,38 @@ namespace IO.Swagger.Controllers |
|
|
|
|
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("/api/notes/{idNote}")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("GetNoteById")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(DetailsNoteDTO), 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 GetNoteById([FromRoute][Required]int? idNote) |
|
|
|
|
{ |
|
|
|
|
//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(DetailsNoteDTO)); |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
//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 \"idAuteur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateMiseAjour\" : \"2000-01-23T04:56:07.000+00:00\",\n \"titre\" : \"titre\",\n \"texte\" : \"texte\",\n \"id\" : 0,\n \"collaborateur\" : {\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 \"referent\" : {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\",\n \"collaborateurs\" : [ null, null ]\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 }\n}"; |
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
? JsonConvert.DeserializeObject<DetailsNoteDTO>(exampleJson) |
|
|
|
|
: default(DetailsNoteDTO); //TODO: Change the data returned |
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
DetailsNoteDTO note = noteService.GetNoteById(idNote); |
|
|
|
|
if(note == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucune note n'a été trouvée" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
return Ok(note); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <remarks>Récupérer toutes les notes</remarks> |
|
|
|
|
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</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="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> |
|
|
|
|
[HttpGet] |
|
|
|
@ -104,7 +116,7 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[SwaggerOperation("GetNotes")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<AffichageNoteDTO>), description: "OK")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
public virtual IActionResult GetNotes() |
|
|
|
|
public virtual IActionResult GetNotes([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [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<AffichageNoteDTO>)); |
|
|
|
@ -124,71 +136,77 @@ namespace IO.Swagger.Controllers |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <remarks>Récupérer les notes d'une personne a écrite</remarks> |
|
|
|
|
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</param> |
|
|
|
|
/// <param name="idReferent">id referent</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="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/notes/auteur/{idReferent}")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("GetNotesByAuteur")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<AffichageNoteDTO>), 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 GetNotesByAuteur([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(List<AffichageNoteDTO>)); |
|
|
|
|
|
|
|
|
|
public virtual IActionResult GetNotesByAuteur([FromQuery][Required()]bool? asc, [FromRoute][Required]Guid? idReferent, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
{ |
|
|
|
|
//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 \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"dateMiseAjour\" : \"2000-01-23T04:56:07.000+00:00\",\n \"titre\" : \"titre\",\n \"id\" : 0,\n \"collaborateur\" : \"collaborateur\"\n}, {\n \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"dateMiseAjour\" : \"2000-01-23T04:56:07.000+00:00\",\n \"titre\" : \"titre\",\n \"id\" : 0,\n \"collaborateur\" : \"collaborateur\"\n} ]"; |
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
? JsonConvert.DeserializeObject<List<AffichageNoteDTO>>(exampleJson) |
|
|
|
|
: default(List<AffichageNoteDTO>); //TODO: Change the data returned |
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
IEnumerable<AffichageNoteDTO> notes = noteService.GetNotesByAuteur(idReferent, asc, numPage, parPAge, texte, tri); |
|
|
|
|
if(notes == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucun id ne correspond au référent" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
return Ok(notes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
|
/// <remarks>Récupérer une note par son id</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="idReferent">id referent</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="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/notes/auteur/{idReferent}/collaborateur/{idCollaborateur}")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("GetNotesByCollaborateur")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<AffichageNoteDTO>), 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 GetNotesByCollaborateur([FromRoute][Required]Guid? idCollaborateur, [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(List<AffichageNoteDTO>)); |
|
|
|
|
|
|
|
|
|
public virtual IActionResult GetNotesByCollaborateur([FromQuery][Required()]bool? asc, [FromRoute][Required]Guid? idCollaborateur, [FromRoute][Required]Guid? idReferent, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
{ |
|
|
|
|
//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 \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"dateMiseAjour\" : \"2000-01-23T04:56:07.000+00:00\",\n \"titre\" : \"titre\",\n \"id\" : 0,\n \"collaborateur\" : \"collaborateur\"\n}, {\n \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"dateMiseAjour\" : \"2000-01-23T04:56:07.000+00:00\",\n \"titre\" : \"titre\",\n \"id\" : 0,\n \"collaborateur\" : \"collaborateur\"\n} ]"; |
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
? JsonConvert.DeserializeObject<List<AffichageNoteDTO>>(exampleJson) |
|
|
|
|
: default(List<AffichageNoteDTO>); //TODO: Change the data returned |
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
IEnumerable<AffichageNoteDTO> notes = noteService.GetNotesByCollaborateur(idReferent, idCollaborateur, asc, numPage, parPAge, texte, tri); |
|
|
|
|
if (notes == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucun id ne correspond au référent et/ou au collaborateur" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
return Ok(notes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -200,7 +218,7 @@ namespace IO.Swagger.Controllers |
|
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
|
[HttpPost] |
|
|
|
|
[Route("/api/notes/nouvellenote")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("NouvelleNote")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
@ -226,7 +244,7 @@ namespace IO.Swagger.Controllers |
|
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
|
[HttpPut] |
|
|
|
|
[Route("/api/notes/{idNote}/updateNote")] |
|
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("UpdateNote")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|