|
|
|
@ -19,9 +19,11 @@ using IO.Swagger.Security; |
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
using IO.Swagger.DTO; |
|
|
|
|
using EPAServeur.IServices; |
|
|
|
|
using System.Reflection.Metadata.Ecma335; |
|
|
|
|
using System.Runtime.InteropServices.WindowsRuntime; |
|
|
|
|
|
|
|
|
|
namespace IO.Swagger.Controllers |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
@ -48,17 +50,19 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("AjouterFormation")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
public virtual IActionResult AjouterFormation([FromBody]FormationDTO body) |
|
|
|
|
public virtual IActionResult AjouterFormation([FromBody] FormationDTO body) |
|
|
|
|
{ |
|
|
|
|
switch (formationService.AddFormation(body)) |
|
|
|
|
{ |
|
|
|
|
case 0: |
|
|
|
|
return StatusCode(201); |
|
|
|
|
case 1: |
|
|
|
|
return Forbid(); |
|
|
|
|
default: |
|
|
|
|
return NotFound(); |
|
|
|
|
} |
|
|
|
|
FormationDTO nouvelleFormation = formationService.AddFormation(body); |
|
|
|
|
|
|
|
|
|
return Created("", nouvelleFormation); |
|
|
|
|
//if (body.Id != null && body.Id > 0) |
|
|
|
|
//{ |
|
|
|
|
// return StatusCode(201, body); |
|
|
|
|
//} |
|
|
|
|
//else |
|
|
|
|
//{ |
|
|
|
|
// return NotFound(); |
|
|
|
|
//} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -74,33 +78,18 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("DeleteFormation")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
public virtual IActionResult DeleteFormation([FromRoute][Required]decimal? idFormation) |
|
|
|
|
{ |
|
|
|
|
int id = 0; |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
id = Convert.ToInt32(idFormation); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
public virtual IActionResult DeleteFormation([FromRoute][Required] decimal? idFormation) |
|
|
|
|
{ |
|
|
|
|
if (!formationService.DeleteFormationById(idFormation)) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "403", |
|
|
|
|
Message = "Impossible de convertir le paramètre idFormation en int. " + ex.Message |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucune formation trouvée" |
|
|
|
|
}; |
|
|
|
|
return StatusCode(403, erreurDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (formationService.DeleteFormationById(id)) |
|
|
|
|
{ |
|
|
|
|
case 0: |
|
|
|
|
return NoContent(); |
|
|
|
|
case 1: |
|
|
|
|
return Forbid(); |
|
|
|
|
default: |
|
|
|
|
return NotFound(); |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
return NoContent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -124,23 +113,21 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<FormationDetailsDTO>), 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 GetFormationAnnulees([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
public virtual IActionResult GetFormationAnnulees([FromQuery][Required()] bool? asc, [FromQuery][Required()] int? numPage, [FromQuery][Required()] int? parPAge, [FromQuery] int? idAgence, [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, formationService.GetFormationAnnulees()); |
|
|
|
|
|
|
|
|
|
//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 \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n}, {\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n} ]"; |
|
|
|
|
IEnumerable<FormationDTO> formations = formationService.GetFormationAnnulees(asc, numPage, parPAge, idAgence, texte, tri); |
|
|
|
|
if (formations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucune formation annulée" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<List<FormationDetailsDTO>>(exampleJson) |
|
|
|
|
// : default(List<FormationDetailsDTO>); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
return Ok(formations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -159,33 +146,19 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(FormationDTO), 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 GetFormationById([FromRoute][Required]decimal? idFormation) |
|
|
|
|
public virtual IActionResult GetFormationById([FromRoute][Required] decimal? idFormation) |
|
|
|
|
{ |
|
|
|
|
//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(FormationDTO)); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
|
|
|
|
|
FormationDTO formationDTO = formationService.GetFormationById(Convert.ToInt32(idFormation)); |
|
|
|
|
if (formationDTO == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Le formateur n'existe pas", |
|
|
|
|
Message = "La formation n'existe pas", |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreurDTO); |
|
|
|
|
} |
|
|
|
|
return Ok(formationDTO); |
|
|
|
|
|
|
|
|
|
//string exampleJson = null; |
|
|
|
|
//exampleJson = "{\n \"heure\" : 1.4658129805029452,\n \"participantsFormation\" : [ {\n \"date\" : \"2000-01-23T04:56:07.000+00:00\",\n \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 5,\n \"formation\" : \"formation\",\n \"collaborateur\" : \"collaborateur\",\n \"statut\" : \"statut\"\n }, {\n \"date\" : \"2000-01-23T04:56:07.000+00:00\",\n \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 5,\n \"formation\" : \"formation\",\n \"collaborateur\" : \"collaborateur\",\n \"statut\" : \"statut\"\n } ],\n \"organisme\" : \"organisme\",\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"jour\" : 5.962133916683182,\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n }\n}"; |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<FormationDTO>(exampleJson) |
|
|
|
|
// : default(FormationDTO); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -209,25 +182,24 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<FormationDetailsDTO>), 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 GetFormationRealisee([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
public virtual IActionResult GetFormationRealisee([FromQuery][Required()] bool? asc, [FromQuery][Required()] int? numPage, [FromQuery][Required()] int? parPAge, [FromQuery] int? idAgence, [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, formationService.GetFormationRealisee()); |
|
|
|
|
|
|
|
|
|
//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 \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n}, {\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n} ]"; |
|
|
|
|
IEnumerable<FormationDTO> formations = formationService.GetFormationRealisee(asc, numPage, parPAge, idAgence, texte, tri); |
|
|
|
|
if (formations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucune formation réalisée" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<List<FormationDetailsDTO>>(exampleJson) |
|
|
|
|
// : default(List<FormationDetailsDTO>); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
return Ok(formations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// |
|
|
|
|
/// </summary> |
|
|
|
@ -248,20 +220,21 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[SwaggerOperation("GetFormations")] |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<FormationDetailsDTO>), description: "OK")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
public virtual IActionResult GetFormations()//[FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]int? statutFormation, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
public virtual IActionResult GetFormations([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]int? statutFormation, [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, formationService.GetFormations()); |
|
|
|
|
IEnumerable<FormationDTO> formations = formationService.GetFormations(asc, numPage, parPAge, idAgence, texte, tri); |
|
|
|
|
if (formations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucune formation" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//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 \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n}, {\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n} ]"; |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<List<FormationDetailsDTO>>(exampleJson) |
|
|
|
|
// : default(List<FormationDetailsDTO>); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
return Ok(formations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -280,17 +253,18 @@ namespace IO.Swagger.Controllers |
|
|
|
|
public virtual IActionResult GetModesFormation() |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
return StatusCode(200, formationService.GetModesFormation()); |
|
|
|
|
|
|
|
|
|
//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 \"libelle\" : \"libelle\",\n \"id\" : 5\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n} ]"; |
|
|
|
|
IEnumerable<ModeFormationDTO> modeFormations = formationService.GetModesFormation(); |
|
|
|
|
if (modeFormations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucun mode de formation" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<List<ModeFormationDTO>>(exampleJson) |
|
|
|
|
// : default(List<ModeFormationDTO>); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
return Ok(modeFormations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -309,17 +283,18 @@ namespace IO.Swagger.Controllers |
|
|
|
|
public virtual IActionResult GetOriginesFormation() |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
return StatusCode(200, formationService.GetOriginesFormation()); |
|
|
|
|
|
|
|
|
|
//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 \"libelle\" : \"libelle\",\n \"id\" : 6\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n} ]"; |
|
|
|
|
IEnumerable<OrigineFormationDTO> origineFormations = formationService.GetOriginesFormation(); |
|
|
|
|
if (origineFormations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucune origine de formation" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<List<OrigineFormationDTO>>(exampleJson) |
|
|
|
|
// : default(List<OrigineFormationDTO>); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
return Ok(origineFormations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -343,23 +318,21 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<FormationDetailsDTO>), 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 GetProchainesFormation([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
|
{ |
|
|
|
|
public virtual IActionResult GetProchainesFormation([FromQuery][Required()] bool? asc, [FromQuery][Required()] int? numPage, [FromQuery][Required()] int? parPAge, [FromQuery] int? idAgence, [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<FormationDetailsDTO>)); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
IEnumerable<FormationDTO> formations = formationService.GetProchainesFormation(asc, numPage, parPAge, idAgence, texte, tri); |
|
|
|
|
if (formations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucune prochaine formation" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//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 \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n}, {\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estCertifie\" : true,\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n },\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"nbPartitipants\" : 1\n} ]"; |
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
? JsonConvert.DeserializeObject<List<FormationDetailsDTO>>(exampleJson) |
|
|
|
|
: default(List<FormationDetailsDTO>); //TODO: Change the data returned |
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
return Ok(formations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -378,17 +351,18 @@ namespace IO.Swagger.Controllers |
|
|
|
|
public virtual IActionResult GetStatutsFormation() |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
return StatusCode(200, formationService.GetStatutsFormation()); |
|
|
|
|
|
|
|
|
|
//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 \"libelle\" : \"libelle\",\n \"id\" : 6\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n} ]"; |
|
|
|
|
IEnumerable<StatutFormationDTO> statutFormations = formationService.GetStatutsFormation(); |
|
|
|
|
if (statutFormations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucun statut de formation" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<List<StatutFormationDTO>>(exampleJson) |
|
|
|
|
// : default(List<StatutFormationDTO>); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
return Ok(statutFormations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -407,17 +381,18 @@ namespace IO.Swagger.Controllers |
|
|
|
|
public virtual IActionResult GetTypesFormation() |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
return StatusCode(200, formationService.GetTypesFormation()); |
|
|
|
|
|
|
|
|
|
//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 \"libelle\" : \"libelle\",\n \"id\" : 5\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 5\n} ]"; |
|
|
|
|
IEnumerable<TypeFormationDTO> typeFormations = formationService.GetTypesFormation(); |
|
|
|
|
if (typeFormations == null) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "404", |
|
|
|
|
Message = "Aucun type de formation" |
|
|
|
|
}; |
|
|
|
|
return NotFound(erreur); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// var example = exampleJson != null |
|
|
|
|
// ? JsonConvert.DeserializeObject<List<TypeFormationDTO>>(exampleJson) |
|
|
|
|
// : default(List<TypeFormationDTO>); //TODO: Change the data returned |
|
|
|
|
//return new ObjectResult(example); |
|
|
|
|
return Ok(typeFormations); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -435,47 +410,28 @@ namespace IO.Swagger.Controllers |
|
|
|
|
[ValidateModelState] |
|
|
|
|
[SwaggerOperation("UpdateFormation")] |
|
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
|
public virtual IActionResult UpdateFormation([FromBody]FormationDTO body, [FromRoute][Required]decimal? idFormation) |
|
|
|
|
public virtual IActionResult UpdateFormation([FromBody] FormationDTO body, [FromRoute][Required] decimal? idFormation) |
|
|
|
|
{ |
|
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
// return StatusCode(200); |
|
|
|
|
|
|
|
|
|
//TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
// return StatusCode(201); |
|
|
|
|
|
|
|
|
|
//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)); |
|
|
|
|
int id = 0; |
|
|
|
|
try |
|
|
|
|
FormationDTO formation = formationService.UpdateFormation(body); |
|
|
|
|
if (formation == null) |
|
|
|
|
{ |
|
|
|
|
id = Convert.ToInt32(idFormation); |
|
|
|
|
formation = formationService.AddFormation(body); |
|
|
|
|
return Created("", formation); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
ErreurDTO erreurDTO = new ErreurDTO() |
|
|
|
|
{ |
|
|
|
|
Code = "403", |
|
|
|
|
Message = "Impossible de convertir le paramètre idFormation en int. " + ex.Message |
|
|
|
|
}; |
|
|
|
|
return StatusCode(403, erreurDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (formationService.DeleteFormationById(id)) |
|
|
|
|
{ |
|
|
|
|
case 0: |
|
|
|
|
return StatusCode(201); |
|
|
|
|
case 1: |
|
|
|
|
return StatusCode(200); |
|
|
|
|
case 2: |
|
|
|
|
return StatusCode(403); |
|
|
|
|
default: |
|
|
|
|
return NotFound(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
|
formationService.UpdateFormation(body); |
|
|
|
|
return StatusCode(201); |
|
|
|
|
return Ok(formation); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//switch (formationService.UpdateFormation(body)) |
|
|
|
|
//{ |
|
|
|
|
// case 0: |
|
|
|
|
// return Ok(); |
|
|
|
|
// case 1: |
|
|
|
|
// return StatusCode(201); |
|
|
|
|
// case 2: |
|
|
|
|
// return Forbid(); |
|
|
|
|
// default: |
|
|
|
|
// return NotFound(); |
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|