Merge et résolution des conflit avec la branche formation

develop
Yanaël GRETTE 4 years ago
commit 81c5b3043f
  1. 390
      Controllers/FormationsApi.cs
  2. 28
      IServices/IFormationService.cs
  3. 4
      Models/Formation/Formation.cs
  4. 2
      Models/Formation/ModeFormation.cs
  5. 2
      Models/Formation/OrigineDemandeFormation.cs
  6. 2
      Models/Formation/OrigineFormation.cs
  7. 2
      Models/Formation/StatutFormation.cs
  8. 2
      Models/Formation/Theme.cs
  9. 2
      Models/Formation/TypeFormation.cs
  10. 655
      Services/FormationService.cs
  11. 5
      Startup.cs

@ -4,7 +4,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.4
*
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
@ -18,17 +18,27 @@ using IO.Swagger.Attributes;
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>
[ApiController]
public class FormationsApiController : ControllerBase
{
{
private readonly IFormationService formationService;
public FormationsApiController(IFormationService _formationService)
{
formationService = _formationService;
}
/// <summary>
///
///
/// </summary>
/// <remarks>Ajouter une nouvelle formation</remarks>
/// <param name="body"></param>
@ -36,23 +46,27 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpPost]
[Route("/api/formations")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("AjouterFormation")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
public virtual IActionResult AjouterFormation([FromBody]FormationDTO body)
{
//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));
throw new NotImplementedException();
public virtual IActionResult AjouterFormation([FromBody] FormationDTO body)
{
FormationDTO nouvelleFormation = formationService.AddFormation(body);
return Created("", nouvelleFormation);
//if (body.Id != null && body.Id > 0)
//{
// return StatusCode(201, body);
//}
//else
//{
// return NotFound();
//}
}
/// <summary>
///
///
/// </summary>
/// <remarks>Supprimer une formation</remarks>
/// <param name="idFormation">id formation</param>
@ -60,23 +74,26 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpDelete]
[Route("/api/formations/{idFormation}/supprimer")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("DeleteFormation")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
public virtual IActionResult DeleteFormation([FromRoute][Required]long? idFormation)
{
//TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(204);
//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));
throw new NotImplementedException();
public virtual IActionResult DeleteFormation([FromRoute][Required] long? idFormation)
{
if (!formationService.DeleteFormationById(idFormation))
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucune formation trouvée"
};
return NotFound(erreur);
}
return NoContent();
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer les formations annulées</remarks>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;ordre inverse (false)</param>
@ -90,33 +107,31 @@ namespace IO.Swagger.Controllers
/// <response code="404">Ressource n&#x27;a pas été trouvée</response>
[HttpGet]
[Route("/api/formations/annulees")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetFormationAnnulees")]
[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&#x27;a pas été trouvée")]
public virtual IActionResult GetFormationAnnulees([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? 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, 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));
//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);
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);
}
return Ok(formations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer une formation par son id</remarks>
/// <param name="idFormation">id formation</param>
@ -125,33 +140,29 @@ namespace IO.Swagger.Controllers
/// <response code="404">Ressource n&#x27;a pas été trouvée</response>
[HttpGet]
[Route("/api/formations/{idFormation}")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetFormationById")]
[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&#x27;a pas été trouvée")]
public virtual IActionResult GetFormationById([FromRoute][Required]long? 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));
//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 \"heure\" : 5,\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\" : 2,\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\" : 2,\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,\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 \"idAgence\" : 1,\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);
public virtual IActionResult GetFormationById([FromRoute][Required] long? idFormation)
{
FormationDTO formationDTO = formationService.GetFormationById(Convert.ToInt32(idFormation));
if (formationDTO == null)
{
ErreurDTO erreurDTO = new ErreurDTO()
{
Code = "404",
Message = "La formation n'existe pas",
};
return NotFound(erreurDTO);
}
return Ok(formationDTO);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer les formations réalisées</remarks>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;ordre inverse (false)</param>
@ -165,33 +176,32 @@ namespace IO.Swagger.Controllers
/// <response code="404">Ressource n&#x27;a pas été trouvée</response>
[HttpGet]
[Route("/api/formations/realisees")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetFormationRealisee")]
[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&#x27;a pas été trouvée")]
public virtual IActionResult GetFormationRealisee([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? 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, 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));
//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);
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);
}
return Ok(formations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer la liste des formations</remarks>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;ordre inverse (false)</param>
@ -205,87 +215,90 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/formations")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[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]long? 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, 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));
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);
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);
}
return Ok(formations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer les modes de formation</remarks>
/// <response code="200">OK</response>
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/modesFormation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetModesFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<ModeFormationDTO>), description: "OK")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
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, default(List<ModeFormationDTO>));
//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} ]";
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<ModeFormationDTO>>(exampleJson)
: default(List<ModeFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example);
IEnumerable<ModeFormationDTO> modeFormations = formationService.GetModesFormation();
if (modeFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucun mode de formation"
};
return NotFound(erreur);
}
return Ok(modeFormations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer les origines de formation</remarks>
/// <response code="200">OK</response>
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/originesFormation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetOriginesFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<OrigineFormationDTO>), description: "OK")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
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, default(List<OrigineFormationDTO>));
//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} ]";
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<OrigineFormationDTO>>(exampleJson)
: default(List<OrigineFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example);
IEnumerable<OrigineFormationDTO> origineFormations = formationService.GetOriginesFormation();
if (origineFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucune origine de formation"
};
return NotFound(erreur);
}
return Ok(origineFormations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer les formations plannifié et replannifié</remarks>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;ordre inverse (false)</param>
@ -299,91 +312,91 @@ namespace IO.Swagger.Controllers
/// <response code="404">Ressource n&#x27;a pas été trouvée</response>
[HttpGet]
[Route("/api/formations/prochaines")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetProchainesFormation")]
[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&#x27;a pas été trouvée")]
public virtual IActionResult GetProchainesFormation([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? 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));
//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);
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);
}
return Ok(formations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer les statuts de formation</remarks>
/// <response code="200">OK</response>
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/statutsFormation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetStatutsFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<StatutFormationDTO>), description: "OK")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
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, default(List<StatutFormationDTO>));
//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} ]";
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<StatutFormationDTO>>(exampleJson)
: default(List<StatutFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example);
IEnumerable<StatutFormationDTO> statutFormations = formationService.GetStatutsFormation();
if (statutFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucun statut de formation"
};
return NotFound(erreur);
}
return Ok(statutFormations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Récupérer les types de formation</remarks>
/// <response code="200">OK</response>
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/typesFormation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetTypesFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<TypeFormationDTO>), description: "OK")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
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, default(List<TypeFormationDTO>));
//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} ]";
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<TypeFormationDTO>>(exampleJson)
: default(List<TypeFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example);
IEnumerable<TypeFormationDTO> typeFormations = formationService.GetTypesFormation();
if (typeFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucun type de formation"
};
return NotFound(erreur);
}
return Ok(typeFormations);
}
/// <summary>
///
///
/// </summary>
/// <remarks>Mettre à jour une formation</remarks>
/// <param name="body"></param>
@ -393,22 +406,33 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpPut]
[Route("/api/formations/{idFormation}/update")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("UpdateFormation")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
public virtual IActionResult UpdateFormation([FromBody]FormationDTO body, [FromRoute][Required]long? 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));
public virtual IActionResult UpdateFormation([FromBody] FormationDTO body, [FromRoute][Required] long? idFormation)
{
FormationDTO formation = formationService.UpdateFormation(body);
if (formation == null)
{
formation = formationService.AddFormation(body);
return Created("", formation);
}
return Ok(formation);
//switch (formationService.UpdateFormation(body))
//{
// case 0:
// return Ok();
// case 1:
// return StatusCode(201);
// case 2:
// return Forbid();
// default:
// return NotFound();
//}
throw new NotImplementedException();
}
}
}

@ -0,0 +1,28 @@
using EPAServeur.Context;
using IO.Swagger.DTO;
using IO.Swagger.ModelCollaborateur;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.IServices
{
public interface IFormationService
{
FormationDTO GetFormationById(long? id);
IEnumerable<FormationDTO> GetFormations(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri);
IEnumerable<FormationDTO> GetFormationAnnulees(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri);
IEnumerable<FormationDTO> GetFormationRealisee(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri);
IEnumerable<FormationDTO> GetProchainesFormation(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri);
IEnumerable<ModeFormationDTO> GetModesFormation();
IEnumerable<OrigineFormationDTO> GetOriginesFormation();
IEnumerable<StatutFormationDTO> GetStatutsFormation();
IEnumerable<TypeFormationDTO> GetTypesFormation();
FormationDTO AddFormation(FormationDTO formationDTO);
FormationDTO UpdateFormation(FormationDTO formationDTO);
bool DeleteFormationById(long? id);
}
}

@ -12,8 +12,8 @@ namespace EPAServeur.Models.Formation
public long IdAgence { get; set; }
public DateTime DateDebut { get; set; }
public DateTime DateFin { get; set; }
public long Jour { get; set; }
public long Heure { get; set; }
public int Jour { get; set; }
public int Heure { get; set; }
public string Organisme { get; set; }
public bool EstCertifiee { get; set; }
public StatutFormation Statut { get; set; }

@ -7,7 +7,7 @@ namespace EPAServeur.Models.Formation
{
public class ModeFormation
{
public long Id { get; set; }
public int Id { get; set; }
public string Libelle { get; set; }
public List<Formation> Formations { get; set; }
}

@ -7,7 +7,7 @@ namespace EPAServeur.Models.Formation
{
public class OrigineDemandeFormation
{
public long Id { get; set; }
public int Id { get; set; }
public string Libelle { get; set; }
public List<DemandeFormation> DemandeFormations { get; set; }
}

@ -7,7 +7,7 @@ namespace EPAServeur.Models.Formation
{
public class OrigineFormation
{
public long Id { get; set; }
public int Id { get; set; }
public string Libelle { get; set; }
public List<Formation> Formations { get; set; }
}

@ -7,7 +7,7 @@ namespace EPAServeur.Models.Formation
{
public class StatutFormation
{
public long Id { get; set; }
public int Id { get; set; }
public string Libelle { get; set; }
public List<Formation> Formations { get; set; }
}

@ -7,7 +7,7 @@ namespace EPAServeur.Models.Formation
{
public class Theme
{
public long Id { get; set; }
public int Id { get; set; }
public string Libelle { get; set; }
}
}

@ -7,7 +7,7 @@ namespace EPAServeur.Models.Formation
{
public class TypeFormation
{
public long Id { get; set; }
public int Id { get; set; }
public string Libelle { get; set; }
public List<Formation> Formations { get; set; }
}

@ -0,0 +1,655 @@
using EPAServeur.Context;
using EPAServeur.IServices;
using EPAServeur.Models.Formation;
using IO.Swagger.DTO;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
namespace EPAServeur.Services
{
public class FormationService : IFormationService
{
#region Variables
private readonly EpContext epContext;
#endregion
#region Contructeurs
/// <summary>
/// Constructeur de la classe FormationService
/// </summary>
/// <param name="_epContext"></param>
public FormationService(EpContext _epContext)
{
epContext = _epContext;
}
#endregion
#region Méthodes Service
/// <summary>
/// Récupérer une formation par son id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public FormationDTO GetFormationById(long? id)
{
Formation formation = epContext.Formation.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation)
.FirstOrDefault(formation => formation.Id == id);
if (formation == null)
return null;
return GetFormationDTO(formation);
}
/// <summary>
/// Récupérer la liste des formations
/// </summary>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;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&#x27;éléments affiché sur chaque page du tableau</param>
/// <param name="idAgence">id de l&#x27;agence à laquelle sont rattachées les données à récupérer</param>
/// <param name="texte">Texte permettant d&#x27;identifier l&#x27;objet rechercher</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s&#x27;effectue</param>
/// <returns></returns>
public IEnumerable<FormationDTO> GetFormations(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri)
{
IEnumerable<Formation> formations;
IEnumerable<FormationDTO> formationDTOs;
if (texte == null)
texte = "";
else
texte = texte.ToLower();
int skip = (numPage.Value - 1) * parPAge.Value;
int take = parPAge.Value;
if (idAgence != null)
{
try
{
formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence)
.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
}
catch (Exception ex)
{
throw;
}
}
else
{
try
{
formations = epContext.Formation.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
}
catch (Exception ex)
{
throw;
}
}
if (formations == null)
return new List<FormationDTO>();
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
return formationDTOs;
}
/// <summary>
/// Récupérer les formations annulées
/// </summary>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;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&#x27;éléments affiché sur chaque page du tableau</param>
/// <param name="idAgence">id de l&#x27;agence à laquelle sont rattachées les données à récupérer</param>
/// <param name="texte">Texte permettant d&#x27;identifier l&#x27;objet rechercher</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s&#x27;effectue</param>
/// <returns></returns>
public IEnumerable<FormationDTO> GetFormationAnnulees(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri)
{
IEnumerable<Formation> formations;
IEnumerable<FormationDTO> formationDTOs;
if (texte == null)
texte = "";
else
texte = texte.ToLower();
int skip = (numPage.Value - 1) * parPAge.Value;
int take = parPAge.Value;
if (idAgence != null)
formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence && formation.Statut.Id == 4)
.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
else
formations = epContext.Formation.Where(formation => formation.Statut.Id == 4)
.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
if (formations == null)
return new List<FormationDTO>();
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
return formationDTOs;
}
/// <summary>
/// Récupérer les formations réalisées
/// </summary>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;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&#x27;éléments affiché sur chaque page du tableau</param>
/// <param name="idAgence">id de l&#x27;agence à laquelle sont rattachées les données à récupérer</param>
/// <param name="texte">Texte permettant d&#x27;identifier l&#x27;objet rechercher</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s&#x27;effectue</param>
/// <returns></returns>
public IEnumerable<FormationDTO> GetFormationRealisee(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri)
{
IEnumerable<Formation> formations;
IEnumerable<FormationDTO> formationDTOs;
if (texte == null)
texte = "";
else
texte = texte.ToLower();
int skip = (numPage.Value - 1) * parPAge.Value;
int take = parPAge.Value;
if (idAgence != null)
{
try
{
formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence && formation.Statut.Id == 3)
.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
}
catch (Exception ex)
{
throw;
}
}
else
{
try
{
formations = epContext.Formation.Where(formation => formation.Statut.Id == 3)
.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
}
catch (Exception ex)
{
throw;
}
}
if (formations == null)
return new List<FormationDTO>();
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
return formationDTOs;
}
/// <summary>
/// Récupérer les formations plannifiées et replannifiées
/// </summary>
/// <param name="asc">Préciser si les données sont dans l&#x27;ordre (true) ou dans l&#x27;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&#x27;éléments affiché sur chaque page du tableau</param>
/// <param name="idAgence">id de l&#x27;agence à laquelle sont rattachées les données à récupérer</param>
/// <param name="texte">Texte permettant d&#x27;identifier l&#x27;objet rechercher</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s&#x27;effectue</param>
/// <returns></returns>
public IEnumerable<FormationDTO> GetProchainesFormation(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri)
{
IEnumerable<Formation> formations;
IEnumerable<FormationDTO> formationDTOs;
if (texte == null)
texte = "";
else
texte = texte.ToLower();
int skip = (numPage.Value - 1) * parPAge.Value;
int take = parPAge.Value;
if (idAgence != null)
try
{
formations = epContext.Formation.Where(formation => formation.IdAgence == idAgence && (formation.Statut.Id == 1 || formation.Statut.Id == 2))
.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
}
catch (Exception ex)
{
throw;
}
else
{
formations = epContext.Formation.Where(formation => (formation.Statut.Id == 1 || formation.Statut.Id == 2))
.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation);
}
if (formations == null)
return new List<FormationDTO>();
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
return formationDTOs;
}
/// <summary>
/// Récupérer les modes de formation
/// </summary>
/// <returns></returns>
public IEnumerable<ModeFormationDTO> GetModesFormation()
{
IEnumerable<ModeFormation> modeFormations;
IEnumerable<ModeFormationDTO> modeFormationDTOs;
try
{
modeFormations = epContext.ModeFormation;
}
catch (Exception ex)
{
throw;
}
modeFormationDTOs = modeFormations.Select(modeFormation => GetModeFormationDTO(modeFormation));
return modeFormationDTOs;
}
/// <summary>
/// Récupérer les origines de formation
/// </summary>
/// <returns></returns>
public IEnumerable<OrigineFormationDTO> GetOriginesFormation()
{
IEnumerable<OrigineFormation> origineFormations;
IEnumerable<OrigineFormationDTO> origineFormationDTOs;
try
{
origineFormations = epContext.OrigineFormation;
}
catch (Exception ex)
{
throw;
}
origineFormationDTOs = origineFormations.Select(origineFormation => GetOrigineFormationDTO(origineFormation));
return origineFormationDTOs;
}
/// <summary>
/// Récupérer les statuts de formation
/// </summary>
/// <returns></returns>
public IEnumerable<StatutFormationDTO> GetStatutsFormation()
{
IEnumerable<StatutFormation> statutFormations;
IEnumerable<StatutFormationDTO> statutFormationDTOs;
try
{
statutFormations = epContext.StatutFormation;
}
catch (Exception ex)
{
throw;
}
statutFormationDTOs = statutFormations.Select(statutFormation => GetStatutFormationDTO(statutFormation));
return statutFormationDTOs;
}
/// <summary>
/// Récupérer les types de formation
/// </summary>
/// <returns></returns>
public IEnumerable<TypeFormationDTO> GetTypesFormation()
{
IEnumerable<TypeFormation> typeFormations;
IEnumerable<TypeFormationDTO> typeFormationDTOs;
try
{
typeFormations = epContext.TypeFormation;
}
catch (Exception ex)
{
throw;
}
typeFormationDTOs = typeFormations.Select(typeFormation => GetTypeFormationDTO(typeFormation));
return typeFormationDTOs;
}
/// <summary>
/// Ajouter une formation
/// </summary>
/// <param name="formationDTO"></param>
/// <returns></returns>
public FormationDTO AddFormation(FormationDTO formationDTO)
{
Formation formation = new Formation();
formation = SetFormation(formation, formationDTO);
if (formation.Statut != null)
{
epContext.StatutFormation.Attach(formation.Statut);
}
epContext.OrigineFormation.Attach(formation.Origine);
epContext.ModeFormation.Attach(formation.ModeFormation);
epContext.TypeFormation.Attach(formation.TypeFormation);
epContext.Add(formation);
try
{
epContext.SaveChanges();
}
catch (Exception ex)
{
throw;
}
return GetFormationDTO(formation);
}
/// <summary>
/// Modifier une formation
/// </summary>
/// <param name="formationDTO"></param>
/// <returns></returns>
public FormationDTO UpdateFormation(FormationDTO formationDTO)
{
Formation formation = epContext.Formation.FirstOrDefault(formation => formation.Id == formationDTO.Id);
if (formation == null)
{
return null;
}
formation = SetFormation(formation, formationDTO);
try
{
epContext.SaveChanges();
}
catch (Exception ex)
{
throw;
}
return GetFormationDTO(formation);
}
/// <summary>
/// Supprimer une formation
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public bool DeleteFormationById(long? id)
{
Formation formation = epContext.Formation.FirstOrDefault(formation => formation.Id == id);
if (formation == null)
return false;
epContext.Remove(formation);
try
{
epContext.SaveChanges();
}
catch (Exception)
{
throw;
}
return true;
}
#endregion
#region Méthodes Privée
#region Object to DTO
/// <summary>
/// Récupère un objet FormationDTO en fonction d'un objet Formation
/// </summary>
/// <param name="formation"></param>
/// <returns></returns>
private FormationDTO GetFormationDTO(Formation formation)
{
FormationDTO formationDTO = new FormationDTO()
{
Id = formation.Id,
Intitule = formation.Intitule,
IdAgence = formation.IdAgence,
DateDebut = formation.DateDebut,
DateFin = formation.DateFin,
Heure = formation.Heure,
Jour = formation.Jour,
Organisme = formation.Organisme,
EstCertifie = formation.EstCertifiee,
Origine = GetOrigineFormationDTO(formation.Origine),
Statut = GetStatutFormationDTO(formation.Statut),
Mode = GetModeFormationDTO(formation.ModeFormation),
Type = GetTypeFormationDTO(formation.TypeFormation)
};
return formationDTO;
}
/// <summary>
/// Récupère un objet OrigineFormationDTO en fonction d'un objet OrigineFormation
/// </summary>
/// <param name="origineFormation"></param>
/// <returns></returns>
private OrigineFormationDTO GetOrigineFormationDTO(OrigineFormation origineFormation)
{
if (origineFormation == null)
return null;
OrigineFormationDTO origineFormationDTO = new OrigineFormationDTO()
{
Id = origineFormation.Id,
Libelle = origineFormation.Libelle
};
return origineFormationDTO;
}
/// <summary>
/// Récupère un objet StatutFormationDTO en fonction d'un objet StatutFormation
/// </summary>
/// <param name="statutFormation"></param>
/// <returns></returns>
private StatutFormationDTO GetStatutFormationDTO(StatutFormation statutFormation)
{
if (statutFormation == null)
return null;
StatutFormationDTO statutFormationDTO = new StatutFormationDTO()
{
Id = statutFormation.Id,
Libelle = statutFormation.Libelle
};
return statutFormationDTO;
}
/// <summary>
/// Récupère un objet ModeFormationDTO en fonction d'un objet ModeFormation
/// </summary>
/// <param name="modeFormation"></param>
/// <returns></returns>
private ModeFormationDTO GetModeFormationDTO(ModeFormation modeFormation)
{
if (modeFormation == null)
return null;
ModeFormationDTO modeFormationDTO = new ModeFormationDTO()
{
Id = modeFormation.Id,
Libelle = modeFormation.Libelle
};
return modeFormationDTO;
}
/// <summary>
/// Récupère un objet TypeFormationDTO en fonction d'un objet TypeFormation
/// </summary>
/// <param name="typeFormation"></param>
/// <returns></returns>
private TypeFormationDTO GetTypeFormationDTO(TypeFormation typeFormation)
{
if (typeFormation == null)
return null;
TypeFormationDTO typeFormationDTO = new TypeFormationDTO()
{
Id = typeFormation.Id,
Libelle = typeFormation.Libelle
};
return typeFormationDTO;
}
#endregion
#region DTO to Object
/// <summary>
/// Modifie un objet Formation en fonction d'un objet FormationDTO
/// </summary>
/// <param name="formation"></param>
/// <param name="formationDTO"></param>
/// <returns></returns>
private Formation SetFormation(Formation formation, FormationDTO formationDTO)
{
formation.Intitule = formationDTO.Intitule;
formation.IdAgence = formationDTO.IdAgence.Value;
formation.DateDebut = formationDTO.DateDebut.Value;
formation.DateFin = formationDTO.DateFin.Value;
formation.Heure = Convert.ToInt32(formationDTO.Heure.Value);
formation.Jour = Convert.ToInt32(formationDTO.Jour.Value);
formation.Organisme = formationDTO.Organisme;
formation.EstCertifiee = formationDTO.EstCertifie.Value;
formation.Origine = GetOrigineFormation(formationDTO.Origine);
formation.Statut = GetStatutFormation(formationDTO.Statut);
formation.ModeFormation = GetModeFormation(formationDTO.Mode);
formation.TypeFormation = GetTypeFormation(formationDTO.Type);
return formation;
}
/// <summary>
/// Récupère un objet OrigineFormation en fonction d'un objet OrigineFormationDTO
/// </summary>
/// <param name="origineFormationDTO"></param>
/// <returns></returns>
private OrigineFormation GetOrigineFormation(OrigineFormationDTO origineFormationDTO)
{
if (origineFormationDTO == null)
return null;
OrigineFormation origineFormation = new OrigineFormation()
{
Id = origineFormationDTO.Id.Value,
Libelle = origineFormationDTO.Libelle
};
return origineFormation;
}
/// <summary>
/// Récupère un objet StatutFormation en fonction d'un objet StatutFormationDTO
/// </summary>
/// <param name="statutFormationDTO"></param>
/// <returns></returns>
private StatutFormation GetStatutFormation(StatutFormationDTO statutFormationDTO)
{
if (statutFormationDTO == null)
return null;
StatutFormation statutFormation = new StatutFormation()
{
Id = statutFormationDTO.Id.Value,
Libelle = statutFormationDTO.Libelle
};
return statutFormation;
}
/// <summary>
/// Récupère un objet ModeFormation en fonction d'un objet ModeFormationDTO
/// </summary>
/// <param name="modeFormationDTO"></param>
/// <returns></returns>
private ModeFormation GetModeFormation(ModeFormationDTO modeFormationDTO)
{
if (modeFormationDTO == null)
return null;
ModeFormation modeFormation = new ModeFormation()
{
Id = modeFormationDTO.Id.Value,
Libelle = modeFormationDTO.Libelle
};
return modeFormation;
}
/// <summary>
/// Récupère un objet TypeFormation en fonction d'un objet TypeFormationDTO
/// </summary>
/// <param name="typeFormationDTO"></param>
/// <returns></returns>
private TypeFormation GetTypeFormation(TypeFormationDTO typeFormationDTO)
{
if (typeFormationDTO == null)
return null;
TypeFormation typeFormation = new TypeFormation()
{
Id = typeFormationDTO.Id.Value,
Libelle = typeFormationDTO.Libelle
};
return typeFormation;
}
#endregion
#endregion
}
}

@ -34,7 +34,7 @@ namespace EPAServeur
services.AddControllers();
services.AddAuthentication(BearerAuthenticationHandler.SchemeName)
.AddScheme<AuthenticationSchemeOptions, BearerAuthenticationHandler>(BearerAuthenticationHandler.SchemeName, null);
services.AddDbContext<EpContext>();
using(var context = new EpContext())
{
@ -45,7 +45,7 @@ namespace EPAServeur
context.AjoutChamps();
context.AjouterNotes();
}
//faire using, check si kekchoz exkist puis appeler les méthodes de création si il n'y a rien
//faire using, check si kekchoz exkist puis appeler les m<EFBFBD>thodes de cr<EFBFBD>ation si il n'y a rien
//API Collaborateurs
services.AddScoped<ICollaborateurApi, CollaborateurApi>();
@ -56,6 +56,7 @@ namespace EPAServeur
//Services
services.AddScoped<ICollaborateurService, CollaborateurService>();
services.AddScoped<IFormationService, FormationService>();
services.AddScoped<INoteService, NoteService>();
}

Loading…
Cancel
Save