|
|
@ -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,13 @@ namespace IO.Swagger.Controllers |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
[ApiController] |
|
|
|
[ApiController] |
|
|
|
public class EngagementsApiController : ControllerBase |
|
|
|
public class EngagementsApiController : ControllerBase |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
private readonly IEngagementService engagementService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EngagementsApiController(IEngagementService _engagementService) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
engagementService = _engagementService; |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// |
|
|
|
/// |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -41,25 +48,26 @@ namespace IO.Swagger.Controllers |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
[HttpGet] |
|
|
|
[HttpGet] |
|
|
|
[Route("/api/engagements")] |
|
|
|
[Route("/api/engagements")] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[ValidateModelState] |
|
|
|
[ValidateModelState] |
|
|
|
[SwaggerOperation("GetEngagements")] |
|
|
|
[SwaggerOperation("GetEngagements")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
public virtual IActionResult GetEngagements([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? idAgence, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
public virtual IActionResult GetEngagements([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? 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(..), ... |
|
|
|
//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<EngagementDTO>)); |
|
|
|
IEnumerable<EngagementDTO> engagements = engagementService.GetEngagements(asc, numPage, parPAge, idAgence, texte, tri); |
|
|
|
|
|
|
|
if (engagements == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Code = "404", |
|
|
|
|
|
|
|
Message = "Aucun engagement" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
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 Ok(engagements); |
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
string exampleJson = null; |
|
|
|
|
|
|
|
exampleJson = "[ {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n}, {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n} ]"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
|
|
|
? JsonConvert.DeserializeObject<List<EngagementDTO>>(exampleJson) |
|
|
|
|
|
|
|
: default(List<EngagementDTO>); //TODO: Change the data returned |
|
|
|
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -76,25 +84,26 @@ namespace IO.Swagger.Controllers |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
[HttpGet] |
|
|
|
[HttpGet] |
|
|
|
[Route("/api/engagements/enattente")] |
|
|
|
[Route("/api/engagements/enattente")] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[ValidateModelState] |
|
|
|
[ValidateModelState] |
|
|
|
[SwaggerOperation("GetEngagementsEnAttente")] |
|
|
|
[SwaggerOperation("GetEngagementsEnAttente")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
public virtual IActionResult GetEngagementsEnAttente([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? idAgence, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
public virtual IActionResult GetEngagementsEnAttente([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? 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(..), ... |
|
|
|
//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<EngagementDTO>)); |
|
|
|
IEnumerable<EngagementDTO> engagements = engagementService.GetEngagementsEnAttente(asc, numPage, parPAge, idAgence, texte, tri); |
|
|
|
|
|
|
|
if (engagements == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Code = "404", |
|
|
|
|
|
|
|
Message = "Aucun engagement en attente" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
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 Ok(engagements); |
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
string exampleJson = null; |
|
|
|
|
|
|
|
exampleJson = "[ {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n}, {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n} ]"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
|
|
|
? JsonConvert.DeserializeObject<List<EngagementDTO>>(exampleJson) |
|
|
|
|
|
|
|
: default(List<EngagementDTO>); //TODO: Change the data returned |
|
|
|
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -111,25 +120,26 @@ namespace IO.Swagger.Controllers |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
[HttpGet] |
|
|
|
[HttpGet] |
|
|
|
[Route("/api/engagements/repondus")] |
|
|
|
[Route("/api/engagements/repondus")] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[ValidateModelState] |
|
|
|
[ValidateModelState] |
|
|
|
[SwaggerOperation("GetEngagementsRepondus")] |
|
|
|
[SwaggerOperation("GetEngagementsRepondus")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
public virtual IActionResult GetEngagementsRepondus([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? idAgence, [FromQuery]string texte, [FromQuery]string tri) |
|
|
|
public virtual IActionResult GetEngagementsRepondus([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? 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(..), ... |
|
|
|
//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<EngagementDTO>)); |
|
|
|
IEnumerable<EngagementDTO> engagements = engagementService.GetEngagementsRepondus(asc, numPage, parPAge, idAgence, texte, tri); |
|
|
|
|
|
|
|
if (engagements == null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ErreurDTO erreur = new ErreurDTO() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Code = "404", |
|
|
|
|
|
|
|
Message = "Aucun engagement en repondu" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
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 Ok(engagements); |
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
string exampleJson = null; |
|
|
|
|
|
|
|
exampleJson = "[ {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n}, {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n} ]"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var example = exampleJson != null |
|
|
|
|
|
|
|
? JsonConvert.DeserializeObject<List<EngagementDTO>>(exampleJson) |
|
|
|
|
|
|
|
: default(List<EngagementDTO>); //TODO: Change the data returned |
|
|
|
|
|
|
|
return new ObjectResult(example); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -142,19 +152,18 @@ namespace IO.Swagger.Controllers |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
/// <response code="403">Acces interdit</response> |
|
|
|
[HttpPut] |
|
|
|
[HttpPut] |
|
|
|
[Route("/api/engagements/{idEngagement}/repondre")] |
|
|
|
[Route("/api/engagements/{idEngagement}/repondre")] |
|
|
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
|
|
[ValidateModelState] |
|
|
|
[ValidateModelState] |
|
|
|
[SwaggerOperation("RepondreEngagement")] |
|
|
|
[SwaggerOperation("RepondreEngagement")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
|
|
public virtual IActionResult RepondreEngagement([FromBody]EngagementDTO body, [FromRoute][Required]long? idEngagement) |
|
|
|
public virtual IActionResult RepondreEngagement([FromBody]EngagementDTO body, [FromRoute][Required]long? idEngagement) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
//if (body != null && body.Realise == false && string.IsNullOrWhiteSpace(body.RaisonNonRealisable)) |
|
|
|
// return StatusCode(200); |
|
|
|
// return null; // A traiter ! Retourner une erreur |
|
|
|
|
|
|
|
|
|
|
|
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
|
|
EngagementDTO engagement = engagementService.RepondreEngagement(body, idEngagement); |
|
|
|
// return StatusCode(403, default(ErreurDTO)); |
|
|
|
|
|
|
|
|
|
|
|
return Ok(engagement); |
|
|
|
throw new NotImplementedException(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|