Compare commits
257 Commits
Author | SHA1 | Date |
---|---|---|
Yanaël GRETTE | c316fe1b1c | 4 years ago |
Yanaël GRETTE | 644d473ce7 | 4 years ago |
Yanaël GRETTE | b1d3ebdaeb | 4 years ago |
Yanaël GRETTE | fb8fff4a92 | 4 years ago |
Yanaël GRETTE | d15c4a3a3b | 4 years ago |
Yanaël GRETTE | 2a8d199020 | 4 years ago |
jboinembalome | 559cec8611 | 4 years ago |
Yanaël GRETTE | fedbd4b901 | 4 years ago |
Yanaël GRETTE | 73e9a0315c | 4 years ago |
Yanaël GRETTE | c54d9fc48b | 4 years ago |
Yanaël GRETTE | b59e2d9617 | 4 years ago |
Yanaël GRETTE | 6197d6d0a6 | 4 years ago |
Yanaël GRETTE | 5af948d0ea | 4 years ago |
jboinembalome | 3fd54f315d | 4 years ago |
jboinembalome | b0bc3d9d5f | 4 years ago |
jboinembalome | 301c6e456a | 4 years ago |
jboinembalome | b48c53aa28 | 4 years ago |
jboinembalome | dbd3888e27 | 4 years ago |
jboinembalome | bc43b2f2ff | 4 years ago |
jboinembalome | 15e9a57e0b | 4 years ago |
jboinembalome | 308e6b6001 | 4 years ago |
jboinembalome | 3bfc264c12 | 4 years ago |
jboinembalome | 72eb5ce675 | 4 years ago |
jboinembalome | d7f93b4913 | 4 years ago |
jboinembalome | 0f8e905098 | 4 years ago |
jboinembalome | 80003b0c66 | 4 years ago |
jboinembalome | ce44d25807 | 4 years ago |
jboinembalome | 0b63a775ff | 4 years ago |
jboinembalome | b6dfd23cee | 4 years ago |
Yanaël GRETTE | 72153decaf | 4 years ago |
Yanaël GRETTE | 2fbd2076cd | 4 years ago |
Yanaël GRETTE | b48458e2d0 | 4 years ago |
Yanaël GRETTE | daab188c86 | 4 years ago |
Yanaël GRETTE | 8f3aed1f24 | 4 years ago |
Yanaël GRETTE | fdda245aad | 4 years ago |
Yanaël GRETTE | f8ba6c6237 | 4 years ago |
Yanaël GRETTE | a9edf6c89f | 4 years ago |
Yanaël GRETTE | ee742082fe | 4 years ago |
jboinembalome | ed83ee261c | 4 years ago |
jboinembalome | 838bc44b08 | 4 years ago |
jboinembalome | b64e5c0a23 | 4 years ago |
jboinembalome | bdf7e343e7 | 4 years ago |
jboinembalome | 96e7715a49 | 4 years ago |
jboinembalome | be8cb5551b | 4 years ago |
jboinembalome | 6e3f6287a2 | 4 years ago |
jboinembalome | 021be18a03 | 4 years ago |
jboinembalome | 04171808f5 | 4 years ago |
jboinembalome | 6633d5db52 | 4 years ago |
jboinembalome | 6a2e28378f | 4 years ago |
jboinembalome | 4e101f472c | 4 years ago |
jboinembalome | 87f887be0c | 4 years ago |
jboinembalome | 670cf11891 | 4 years ago |
jboinembalome | fa805a1768 | 4 years ago |
jboinembalome | 2d38013907 | 4 years ago |
jboinembalome | 67b9d60371 | 4 years ago |
jboinembalome | 7de1183ad4 | 4 years ago |
jboinembalome | cc83dea6d0 | 4 years ago |
jboinembalome | 9578543b99 | 4 years ago |
jboinembalome | 39083c619b | 4 years ago |
jboinembalome | b43dd25ff1 | 4 years ago |
jboinembalome | 76db2cb8de | 4 years ago |
Yanaël GRETTE | e46d08ecb0 | 4 years ago |
Yanaël GRETTE | 64a9b6a69d | 4 years ago |
Yanaël GRETTE | 10a306c888 | 4 years ago |
Yanaël GRETTE | 480cefb528 | 4 years ago |
jboinembalome | 9949eee8d2 | 4 years ago |
jboinembalome | a78370d4d7 | 4 years ago |
jboinembalome | fb89826622 | 4 years ago |
jboinembalome | 3146d7a9c5 | 4 years ago |
jboinembalome | 6970bd3436 | 4 years ago |
jboinembalome | 09b0483523 | 4 years ago |
jboinembalome | 3bc3bb5d56 | 4 years ago |
jboinembalome | 1373fea1ba | 4 years ago |
jboinembalome | fafe2d9d9b | 4 years ago |
Yanaël GRETTE | 87bd06dd80 | 4 years ago |
Yanaël GRETTE | ad15e84d51 | 4 years ago |
Yanaël GRETTE | 586702001f | 4 years ago |
Yanaël GRETTE | 76b4a06b9d | 4 years ago |
Yanaël GRETTE | e362dc75df | 4 years ago |
Yanaël GRETTE | d48884349f | 4 years ago |
Yanaël GRETTE | 87f978bcf9 | 4 years ago |
Yanaël GRETTE | f70eb4bc3a | 4 years ago |
Yanaël GRETTE | caec1c0390 | 4 years ago |
Yanaël GRETTE | 213c6c851a | 4 years ago |
Yanaël GRETTE | 9a0071a556 | 4 years ago |
Yanaël GRETTE | 25bd7a4a69 | 4 years ago |
Yanaël GRETTE | b70b255f2b | 4 years ago |
Yanaël GRETTE | db66711b77 | 4 years ago |
jboinembalome | 8a4365547d | 4 years ago |
jboinembalome | 647ac6537f | 4 years ago |
jboinembalome | 5e3c971282 | 4 years ago |
Yanaël GRETTE | f13fcc25b7 | 4 years ago |
Yanaël GRETTE | 95ed1e83ac | 4 years ago |
Yanaël GRETTE | 8a88b0de2b | 4 years ago |
Yanaël GRETTE | 59af0e29c8 | 4 years ago |
Yanaël GRETTE | 8f964f255f | 4 years ago |
Yanaël GRETTE | d6e34b2369 | 4 years ago |
Yanaël GRETTE | f924d3e40f | 4 years ago |
Yanaël GRETTE | e0b433ebca | 4 years ago |
Yanaël GRETTE | 2ba2de0df3 | 4 years ago |
Yanaël GRETTE | 7b571f75cb | 4 years ago |
Yanaël GRETTE | 2f3440b27f | 4 years ago |
Yanaël GRETTE | b96dedada8 | 4 years ago |
Yanaël GRETTE | b1c494d811 | 4 years ago |
Yanaël GRETTE | f37ccf27e5 | 4 years ago |
Yanaël GRETTE | 6336fa1340 | 4 years ago |
Yanaël GRETTE | fffa45ef5f | 4 years ago |
jboinembalome | 65afda1ab6 | 4 years ago |
Yanaël GRETTE | ea59807f4c | 4 years ago |
Yanaël GRETTE | abfab24cf5 | 4 years ago |
jboinembalome | ac7571dbfa | 4 years ago |
jboinembalome | f056c41133 | 4 years ago |
jboinembalome | 3190add127 | 4 years ago |
jboinembalome | 70808c2966 | 4 years ago |
jboinembalome | 74ca7f067b | 4 years ago |
jboinembalome | a1ca683027 | 4 years ago |
jboinembalome | 170b806e40 | 4 years ago |
jboinembalome | 92a68a26cc | 4 years ago |
jboinembalome | 0fdb651fdd | 4 years ago |
jboinembalome | bcc0ddb5d9 | 4 years ago |
Yanaël GRETTE | b41dbc443e | 4 years ago |
jboinembalome | 6aae6cc0a4 | 4 years ago |
jboinembalome | d75ee2b391 | 4 years ago |
jboinembalome | e8d4bb2961 | 4 years ago |
jboinembalome | 28c4a95eb5 | 4 years ago |
jboinembalome | 71e8c9b538 | 4 years ago |
jboinembalome | 5e3870ec6e | 4 years ago |
jboinembalome | 6747f231fe | 4 years ago |
jboinembalome | 17d7fc7778 | 4 years ago |
Yanaël GRETTE | 2c442d99d7 | 4 years ago |
jboinembalome | 1c56a12d0d | 4 years ago |
jboinembalome | 7b7546bc19 | 4 years ago |
jboinembalome | 695562391a | 4 years ago |
jboinembalome | d08a86bb9b | 4 years ago |
jboinembalome | 29970bc54f | 4 years ago |
Yanaël GRETTE | 442a799e76 | 4 years ago |
Yanaël GRETTE | a783047bb5 | 4 years ago |
Yanaël GRETTE | ee2a5e422d | 4 years ago |
Yanaël GRETTE | 2523a0d9f7 | 4 years ago |
jboinembalome | ff98567d1e | 4 years ago |
jboinembalome | cf0c099bcd | 4 years ago |
Yanaël GRETTE | 297af95517 | 4 years ago |
Yanaël GRETTE | c02b2b4126 | 4 years ago |
Yanaël GRETTE | 166bb4ac38 | 4 years ago |
jboinembalome | 5b8e5b043a | 4 years ago |
jboinembalome | a8e8b85b0a | 4 years ago |
jboinembalome | 8f4fb19e81 | 4 years ago |
jboinembalome | bccb8846e6 | 4 years ago |
jboinembalome | 23f8b69940 | 4 years ago |
jboinembalome | db7eff40a8 | 4 years ago |
jboinembalome | bb67f315cd | 4 years ago |
jboinembalome | e97d88ccee | 4 years ago |
Yanaël GRETTE | ae2a8a4200 | 4 years ago |
Yanaël GRETTE | 58376f8e96 | 4 years ago |
Yanaël GRETTE | 7da1e7f35e | 4 years ago |
Yanaël GRETTE | f2b9db54e8 | 4 years ago |
Yanaël GRETTE | bcdd8faa83 | 4 years ago |
Yanaël GRETTE | 67c115f0aa | 4 years ago |
Yanaël GRETTE | d3aaf48312 | 4 years ago |
Yanaël GRETTE | 5392c3f50f | 4 years ago |
Yanaël GRETTE | 3aaa8e8ddb | 4 years ago |
Yanaël GRETTE | 316a978e57 | 4 years ago |
Yanaël GRETTE | 12c55c7f95 | 4 years ago |
Yanaël GRETTE | 7bbc7e2d4b | 4 years ago |
Yanaël GRETTE | 8360570eea | 4 years ago |
jboinembalome | 8a92c3e58c | 4 years ago |
jboinembalome | b72e5acaa3 | 4 years ago |
jboinembalome | cfe019be07 | 4 years ago |
Yanaël GRETTE | bf9058f516 | 4 years ago |
Yanaël GRETTE | 39519bfc34 | 4 years ago |
Yanaël GRETTE | 194e67135c | 4 years ago |
Yanaël GRETTE | ef948a59d8 | 4 years ago |
Yanaël GRETTE | ddd1d6d9b1 | 4 years ago |
Yanaël GRETTE | d2e57ab001 | 4 years ago |
Yanaël GRETTE | c0985a63b8 | 4 years ago |
Yanaël GRETTE | 97b67e6530 | 4 years ago |
Yanaël GRETTE | 67bc0d5f20 | 4 years ago |
Yanaël GRETTE | fdbf2502b0 | 4 years ago |
jboinembalome | 44a8edf119 | 4 years ago |
jboinembalome | 2c81fe440e | 4 years ago |
jboinembalome | 811d2aabd5 | 4 years ago |
jboinembalome | a6d33450de | 4 years ago |
jboinembalome | 3aac3ed70a | 4 years ago |
jboinembalome | bb420fd978 | 4 years ago |
jboinembalome | 6438227068 | 4 years ago |
jboinembalome | c10dfd5069 | 4 years ago |
jboinembalome | 49ec9b8387 | 4 years ago |
jboinembalome | 3ff19b51b7 | 4 years ago |
jboinembalome | eb61b11b23 | 4 years ago |
Yanaël GRETTE | c13baf22c6 | 4 years ago |
jboinembalome | 61f0effc51 | 4 years ago |
jboinembalome | efbfd193d7 | 4 years ago |
jboinembalome | 71b2de4176 | 4 years ago |
jboinembalome | 03dd6302b2 | 4 years ago |
jboinembalome | 8f57dfcf12 | 4 years ago |
jboinembalome | a0feaefec0 | 4 years ago |
jboinembalome | c6ccba8bab | 4 years ago |
jboinembalome | b8072d67fa | 4 years ago |
jboinembalome | b2bea37630 | 4 years ago |
jboinembalome | b81852a4cb | 4 years ago |
jboinembalome | 04aac98989 | 4 years ago |
jboinembalome | cc984a6771 | 4 years ago |
jboinembalome | 56c878e0f8 | 4 years ago |
jboinembalome | 02f9f66f35 | 4 years ago |
jboinembalome | 568df4befd | 4 years ago |
jboinembalome | a07e54c6bc | 4 years ago |
jboinembalome | 1f43723b07 | 4 years ago |
jboinembalome | 13bc6e6619 | 4 years ago |
jboinembalome | 340c856b7d | 4 years ago |
jboinembalome | 25051d03d0 | 4 years ago |
jboinembalome | d19d74746c | 4 years ago |
jboinembalome | b809486cd3 | 4 years ago |
jboinembalome | ebc246b31d | 4 years ago |
Yanaël GRETTE | d7a9e83a8e | 4 years ago |
Yanaël GRETTE | 7c889ca1c7 | 4 years ago |
jboinembalome | 051b2fb731 | 4 years ago |
jboinembalome | f97cce68b4 | 4 years ago |
jboinembalome | 79828d46b1 | 4 years ago |
jboinembalome | c6d69a0d20 | 4 years ago |
jboinembalome | 925e8268af | 4 years ago |
jboinembalome | 9ed1697bf2 | 4 years ago |
jboinembalome | 83c5a51137 | 4 years ago |
jboinembalome | 3ec0c7fdf4 | 4 years ago |
jboinembalome | c6518a5f3a | 4 years ago |
jboinembalome | 13c4fb74fd | 4 years ago |
jboinembalome | 2f716d22dd | 4 years ago |
jboinembalome | 7cdf09e341 | 4 years ago |
jboinembalome | 7ecb14ec59 | 4 years ago |
jboinembalome | 6b3e8ec32a | 4 years ago |
jboinembalome | cd6439a643 | 4 years ago |
Yanaël GRETTE | 2f3e202450 | 4 years ago |
Yanaël GRETTE | f9205b0a5e | 4 years ago |
Yanaël GRETTE | 79df883367 | 4 years ago |
Yanaël GRETTE | 64b4394994 | 4 years ago |
Yanaël GRETTE | 8768f63fac | 4 years ago |
jboinembalome | 2144a10458 | 4 years ago |
jboinembalome | 7221f86417 | 4 years ago |
jboinembalome | 52977a4520 | 4 years ago |
jboinembalome | 79e8a86071 | 4 years ago |
Yanaël GRETTE | d673d32cb3 | 4 years ago |
jboinembalome | b0f6787f29 | 4 years ago |
jboinembalome | 991401d487 | 4 years ago |
Yanaël GRETTE | 81c5b3043f | 4 years ago |
jboinembalome | f60c4ddb83 | 4 years ago |
Yanaël GRETTE | 71a84d0e42 | 4 years ago |
jboinembalome | 2f0b45406c | 4 years ago |
Yanaël GRETTE | 19600f3950 | 4 years ago |
Yanaël GRETTE | 4e7c474b0b | 4 years ago |
Yanaël GRETTE | f11c134bc4 | 4 years ago |
jboinembalome | cda46536ee | 4 years ago |
Yanaël GRETTE | a07a78af87 | 4 years ago |
Yanaël GRETTE | 5443b49388 | 4 years ago |
Yanaël GRETTE | 4e78c28d10 | 4 years ago |
Yanaël GRETTE | f01fa3099f | 4 years ago |
Yanaël GRETTE | e38ef1b7ce | 4 years ago |
Yanaël GRETTE | 1354101310 | 4 years ago |
Yanaël GRETTE | 18316d9f8a | 4 years ago |
@ -1,864 +0,0 @@ |
|||||||
/* |
|
||||||
* Service Collaborateur API |
|
||||||
* |
|
||||||
* Api du service Collaborateur, utilisée pour récupérer les données des collaborateurs d'Apside |
|
||||||
* |
|
||||||
* OpenAPI spec version: 1.1.2 |
|
||||||
* Contact: lilian.gayet@apside-groupe.com |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Collections.ObjectModel; |
|
||||||
using System.Linq; |
|
||||||
using RestSharp; |
|
||||||
using IO.Swagger.ClientCollaborateur; |
|
||||||
using IO.Swagger.ModelCollaborateur; |
|
||||||
|
|
||||||
namespace IO.Swagger.ApiCollaborateur |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Represents a collection of functions to interact with the API endpoints |
|
||||||
/// </summary> |
|
||||||
public interface IRfrentApi : IApiAccessor |
|
||||||
{ |
|
||||||
#region Synchronous Operations |
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>List<Collaborateur></returns> |
|
||||||
List<Collaborateur> ChercherRefCollabId (Guid? collabId); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>ApiResponse of List<Collaborateur></returns> |
|
||||||
ApiResponse<List<Collaborateur>> ChercherRefCollabIdWithHttpInfo (Guid? collabId); |
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>List<Collaborateur></returns> |
|
||||||
List<Collaborateur> ChercherRefCollabMail (string mailApside); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>ApiResponse of List<Collaborateur></returns> |
|
||||||
ApiResponse<List<Collaborateur>> ChercherRefCollabMailWithHttpInfo (string mailApside); |
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Collaborateur</returns> |
|
||||||
Collaborateur ChercherRefSuiviParDateCollabId (Guid? collabId, string date); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>ApiResponse of Collaborateur</returns> |
|
||||||
ApiResponse<Collaborateur> ChercherRefSuiviParDateCollabIdWithHttpInfo (Guid? collabId, string date); |
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Collaborateur</returns> |
|
||||||
Collaborateur ChercherRefSuiviParDateCollabMail (string mailApside, string date); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>ApiResponse of Collaborateur</returns> |
|
||||||
ApiResponse<Collaborateur> ChercherRefSuiviParDateCollabMailWithHttpInfo (string mailApside, string date); |
|
||||||
#endregion Synchronous Operations |
|
||||||
#region Asynchronous Operations |
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>Task of List<Collaborateur></returns> |
|
||||||
System.Threading.Tasks.Task<List<Collaborateur>> ChercherRefCollabIdAsync (Guid? collabId); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>Task of ApiResponse (List<Collaborateur>)</returns> |
|
||||||
System.Threading.Tasks.Task<ApiResponse<List<Collaborateur>>> ChercherRefCollabIdAsyncWithHttpInfo (Guid? collabId); |
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>Task of List<Collaborateur></returns> |
|
||||||
System.Threading.Tasks.Task<List<Collaborateur>> ChercherRefCollabMailAsync (string mailApside); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>Task of ApiResponse (List<Collaborateur>)</returns> |
|
||||||
System.Threading.Tasks.Task<ApiResponse<List<Collaborateur>>> ChercherRefCollabMailAsyncWithHttpInfo (string mailApside); |
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of Collaborateur</returns> |
|
||||||
System.Threading.Tasks.Task<Collaborateur> ChercherRefSuiviParDateCollabIdAsync (Guid? collabId, string date); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of ApiResponse (Collaborateur)</returns> |
|
||||||
System.Threading.Tasks.Task<ApiResponse<Collaborateur>> ChercherRefSuiviParDateCollabIdAsyncWithHttpInfo (Guid? collabId, string date); |
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of Collaborateur</returns> |
|
||||||
System.Threading.Tasks.Task<Collaborateur> ChercherRefSuiviParDateCollabMailAsync (string mailApside, string date); |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit |
|
||||||
/// </summary> |
|
||||||
/// <remarks> |
|
||||||
/// rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </remarks> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of ApiResponse (Collaborateur)</returns> |
|
||||||
System.Threading.Tasks.Task<ApiResponse<Collaborateur>> ChercherRefSuiviParDateCollabMailAsyncWithHttpInfo (string mailApside, string date); |
|
||||||
#endregion Asynchronous Operations |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Represents a collection of functions to interact with the API endpoints |
|
||||||
/// </summary> |
|
||||||
public partial class RfrentApi : IRfrentApi |
|
||||||
{ |
|
||||||
private IO.Swagger.ClientCollaborateur.ExceptionFactory _exceptionFactory = (name, response) => null; |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Initializes a new instance of the <see cref="RfrentApi"/> class. |
|
||||||
/// </summary> |
|
||||||
/// <returns></returns> |
|
||||||
public RfrentApi(String basePath) |
|
||||||
{ |
|
||||||
this.Configuration = new IO.Swagger.ClientCollaborateur.Configuration { BasePath = basePath }; |
|
||||||
|
|
||||||
ExceptionFactory = IO.Swagger.ClientCollaborateur.Configuration.DefaultExceptionFactory; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Initializes a new instance of the <see cref="RfrentApi"/> class |
|
||||||
/// </summary> |
|
||||||
/// <returns></returns> |
|
||||||
public RfrentApi() |
|
||||||
{ |
|
||||||
this.Configuration = IO.Swagger.ClientCollaborateur.Configuration.Default; |
|
||||||
|
|
||||||
ExceptionFactory = IO.Swagger.ClientCollaborateur.Configuration.DefaultExceptionFactory; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Initializes a new instance of the <see cref="RfrentApi"/> class |
|
||||||
/// using Configuration object |
|
||||||
/// </summary> |
|
||||||
/// <param name="configuration">An instance of Configuration</param> |
|
||||||
/// <returns></returns> |
|
||||||
public RfrentApi(IO.Swagger.ClientCollaborateur.Configuration configuration = null) |
|
||||||
{ |
|
||||||
if (configuration == null) // use the default one in Configuration |
|
||||||
this.Configuration = IO.Swagger.ClientCollaborateur.Configuration.Default; |
|
||||||
else |
|
||||||
this.Configuration = configuration; |
|
||||||
|
|
||||||
ExceptionFactory = IO.Swagger.ClientCollaborateur.Configuration.DefaultExceptionFactory; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets the base path of the API client. |
|
||||||
/// </summary> |
|
||||||
/// <value>The base path</value> |
|
||||||
public String GetBasePath() |
|
||||||
{ |
|
||||||
return this.Configuration.ApiClient.RestClient.BaseUrl.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Sets the base path of the API client. |
|
||||||
/// </summary> |
|
||||||
/// <value>The base path</value> |
|
||||||
[Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")] |
|
||||||
public void SetBasePath(String basePath) |
|
||||||
{ |
|
||||||
// do nothing |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or sets the configuration object |
|
||||||
/// </summary> |
|
||||||
/// <value>An instance of the Configuration</value> |
|
||||||
public IO.Swagger.ClientCollaborateur.Configuration Configuration {get; set;} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Provides a factory method hook for the creation of exceptions. |
|
||||||
/// </summary> |
|
||||||
public IO.Swagger.ClientCollaborateur.ExceptionFactory ExceptionFactory |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) |
|
||||||
{ |
|
||||||
throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); |
|
||||||
} |
|
||||||
return _exceptionFactory; |
|
||||||
} |
|
||||||
set { _exceptionFactory = value; } |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets the default header. |
|
||||||
/// </summary> |
|
||||||
/// <returns>Dictionary of HTTP header</returns> |
|
||||||
[Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] |
|
||||||
public IDictionary<String, String> DefaultHeader() |
|
||||||
{ |
|
||||||
return new ReadOnlyDictionary<string, string>(this.Configuration.DefaultHeader); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Add default header. |
|
||||||
/// </summary> |
|
||||||
/// <param name="key">Header field name.</param> |
|
||||||
/// <param name="value">Header field value.</param> |
|
||||||
/// <returns></returns> |
|
||||||
[Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")] |
|
||||||
public void AddDefaultHeader(string key, string value) |
|
||||||
{ |
|
||||||
this.Configuration.AddDefaultHeader(key, value); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>List<Collaborateur></returns> |
|
||||||
public List<Collaborateur> ChercherRefCollabId (Guid? collabId) |
|
||||||
{ |
|
||||||
ApiResponse<List<Collaborateur>> localVarResponse = ChercherRefCollabIdWithHttpInfo(collabId); |
|
||||||
return localVarResponse.Data; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>ApiResponse of List<Collaborateur></returns> |
|
||||||
public ApiResponse< List<Collaborateur> > ChercherRefCollabIdWithHttpInfo (Guid? collabId) |
|
||||||
{ |
|
||||||
// verify the required parameter 'collabId' is set |
|
||||||
if (collabId == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'collabId' when calling RfrentApi->ChercherRefCollabId"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{collabId}/referents"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (collabId != null) localVarPathParams.Add("collabId", this.Configuration.ApiClient.ParameterToString(collabId)); // path parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) this.Configuration.ApiClient.CallApi(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefCollabId", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<List<Collaborateur>>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(List<Collaborateur>) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(List<Collaborateur>))); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>Task of List<Collaborateur></returns> |
|
||||||
public async System.Threading.Tasks.Task<List<Collaborateur>> ChercherRefCollabIdAsync (Guid? collabId) |
|
||||||
{ |
|
||||||
ApiResponse<List<Collaborateur>> localVarResponse = await ChercherRefCollabIdAsyncWithHttpInfo(collabId); |
|
||||||
return localVarResponse.Data; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <returns>Task of ApiResponse (List<Collaborateur>)</returns> |
|
||||||
public async System.Threading.Tasks.Task<ApiResponse<List<Collaborateur>>> ChercherRefCollabIdAsyncWithHttpInfo (Guid? collabId) |
|
||||||
{ |
|
||||||
// verify the required parameter 'collabId' is set |
|
||||||
if (collabId == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'collabId' when calling RfrentApi->ChercherRefCollabId"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{collabId}/referents"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (collabId != null) localVarPathParams.Add("collabId", this.Configuration.ApiClient.ParameterToString(collabId)); // path parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) await this.Configuration.ApiClient.CallApiAsync(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefCollabId", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<List<Collaborateur>>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(List<Collaborateur>) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(List<Collaborateur>))); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>List<Collaborateur></returns> |
|
||||||
public List<Collaborateur> ChercherRefCollabMail (string mailApside) |
|
||||||
{ |
|
||||||
ApiResponse<List<Collaborateur>> localVarResponse = ChercherRefCollabMailWithHttpInfo(mailApside); |
|
||||||
return localVarResponse.Data; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>ApiResponse of List<Collaborateur></returns> |
|
||||||
public ApiResponse< List<Collaborateur> > ChercherRefCollabMailWithHttpInfo (string mailApside) |
|
||||||
{ |
|
||||||
// verify the required parameter 'mailApside' is set |
|
||||||
if (mailApside == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'mailApside' when calling RfrentApi->ChercherRefCollabMail"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{mailApside}/referents"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (mailApside != null) localVarPathParams.Add("mailApside", this.Configuration.ApiClient.ParameterToString(mailApside)); // path parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) this.Configuration.ApiClient.CallApi(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefCollabMail", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<List<Collaborateur>>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(List<Collaborateur>) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(List<Collaborateur>))); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>Task of List<Collaborateur></returns> |
|
||||||
public async System.Threading.Tasks.Task<List<Collaborateur>> ChercherRefCollabMailAsync (string mailApside) |
|
||||||
{ |
|
||||||
ApiResponse<List<Collaborateur>> localVarResponse = await ChercherRefCollabMailAsyncWithHttpInfo(mailApside); |
|
||||||
return localVarResponse.Data; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher les référents rechercher les référents d'un collaborateur à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <returns>Task of ApiResponse (List<Collaborateur>)</returns> |
|
||||||
public async System.Threading.Tasks.Task<ApiResponse<List<Collaborateur>>> ChercherRefCollabMailAsyncWithHttpInfo (string mailApside) |
|
||||||
{ |
|
||||||
// verify the required parameter 'mailApside' is set |
|
||||||
if (mailApside == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'mailApside' when calling RfrentApi->ChercherRefCollabMail"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{mailApside}/referents"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (mailApside != null) localVarPathParams.Add("mailApside", this.Configuration.ApiClient.ParameterToString(mailApside)); // path parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) await this.Configuration.ApiClient.CallApiAsync(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefCollabMail", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<List<Collaborateur>>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(List<Collaborateur>) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(List<Collaborateur>))); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Collaborateur</returns> |
|
||||||
public Collaborateur ChercherRefSuiviParDateCollabId (Guid? collabId, string date) |
|
||||||
{ |
|
||||||
ApiResponse<Collaborateur> localVarResponse = ChercherRefSuiviParDateCollabIdWithHttpInfo(collabId, date); |
|
||||||
return localVarResponse.Data; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>ApiResponse of Collaborateur</returns> |
|
||||||
public ApiResponse< Collaborateur > ChercherRefSuiviParDateCollabIdWithHttpInfo (Guid? collabId, string date) |
|
||||||
{ |
|
||||||
// verify the required parameter 'collabId' is set |
|
||||||
if (collabId == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'collabId' when calling RfrentApi->ChercherRefSuiviParDateCollabId"); |
|
||||||
// verify the required parameter 'date' is set |
|
||||||
if (date == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'date' when calling RfrentApi->ChercherRefSuiviParDateCollabId"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{collabId}/referent"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (collabId != null) localVarPathParams.Add("collabId", this.Configuration.ApiClient.ParameterToString(collabId)); // path parameter |
|
||||||
if (date != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "date", date)); // query parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) this.Configuration.ApiClient.CallApi(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefSuiviParDateCollabId", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<Collaborateur>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(Collaborateur) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Collaborateur))); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of Collaborateur</returns> |
|
||||||
public async System.Threading.Tasks.Task<Collaborateur> ChercherRefSuiviParDateCollabIdAsync (Guid? collabId, string date) |
|
||||||
{ |
|
||||||
ApiResponse<Collaborateur> localVarResponse = await ChercherRefSuiviParDateCollabIdAsyncWithHttpInfo(collabId, date); |
|
||||||
return localVarResponse.Data; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son identifiant |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="collabId">Ce paramêtre permet de renseigner l'identifiant du collaborateur recherché</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of ApiResponse (Collaborateur)</returns> |
|
||||||
public async System.Threading.Tasks.Task<ApiResponse<Collaborateur>> ChercherRefSuiviParDateCollabIdAsyncWithHttpInfo (Guid? collabId, string date) |
|
||||||
{ |
|
||||||
// verify the required parameter 'collabId' is set |
|
||||||
if (collabId == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'collabId' when calling RfrentApi->ChercherRefSuiviParDateCollabId"); |
|
||||||
// verify the required parameter 'date' is set |
|
||||||
if (date == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'date' when calling RfrentApi->ChercherRefSuiviParDateCollabId"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{collabId}/referent"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (collabId != null) localVarPathParams.Add("collabId", this.Configuration.ApiClient.ParameterToString(collabId)); // path parameter |
|
||||||
if (date != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "date", date)); // query parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) await this.Configuration.ApiClient.CallApiAsync(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefSuiviParDateCollabId", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<Collaborateur>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(Collaborateur) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Collaborateur))); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Collaborateur</returns> |
|
||||||
public Collaborateur ChercherRefSuiviParDateCollabMail (string mailApside, string date) |
|
||||||
{ |
|
||||||
ApiResponse<Collaborateur> localVarResponse = ChercherRefSuiviParDateCollabMailWithHttpInfo(mailApside, date); |
|
||||||
return localVarResponse.Data; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>ApiResponse of Collaborateur</returns> |
|
||||||
public ApiResponse< Collaborateur > ChercherRefSuiviParDateCollabMailWithHttpInfo (string mailApside, string date) |
|
||||||
{ |
|
||||||
// verify the required parameter 'mailApside' is set |
|
||||||
if (mailApside == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'mailApside' when calling RfrentApi->ChercherRefSuiviParDateCollabMail"); |
|
||||||
// verify the required parameter 'date' is set |
|
||||||
if (date == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'date' when calling RfrentApi->ChercherRefSuiviParDateCollabMail"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{mailApside}/referent"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (mailApside != null) localVarPathParams.Add("mailApside", this.Configuration.ApiClient.ParameterToString(mailApside)); // path parameter |
|
||||||
if (date != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "date", date)); // query parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) this.Configuration.ApiClient.CallApi(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefSuiviParDateCollabMail", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<Collaborateur>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(Collaborateur) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Collaborateur))); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of Collaborateur</returns> |
|
||||||
public async System.Threading.Tasks.Task<Collaborateur> ChercherRefSuiviParDateCollabMailAsync (string mailApside, string date) |
|
||||||
{ |
|
||||||
ApiResponse<Collaborateur> localVarResponse = await ChercherRefSuiviParDateCollabMailAsyncWithHttpInfo(mailApside, date); |
|
||||||
return localVarResponse.Data; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// rechercher le référent qui a le plus suivit rechercher le référent du collaborateur l’ayant le plus suivi depuis une date donnée à l'aide de son mail apside |
|
||||||
/// </summary> |
|
||||||
/// <exception cref="IO.Swagger.ClientCollaborateur.ApiException">Thrown when fails to make API call</exception> |
|
||||||
/// <param name="mailApside">Ce paramêtre permet de renseigner le mail apside du collaborateur recherché /!\\ \"@\" doit être changé en \"%40\" /!\\</param> |
|
||||||
/// <param name="date">Ce paramêtre permet de renseigner la date recherchée</param> |
|
||||||
/// <returns>Task of ApiResponse (Collaborateur)</returns> |
|
||||||
public async System.Threading.Tasks.Task<ApiResponse<Collaborateur>> ChercherRefSuiviParDateCollabMailAsyncWithHttpInfo (string mailApside, string date) |
|
||||||
{ |
|
||||||
// verify the required parameter 'mailApside' is set |
|
||||||
if (mailApside == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'mailApside' when calling RfrentApi->ChercherRefSuiviParDateCollabMail"); |
|
||||||
// verify the required parameter 'date' is set |
|
||||||
if (date == null) |
|
||||||
throw new ApiException(400, "Missing required parameter 'date' when calling RfrentApi->ChercherRefSuiviParDateCollabMail"); |
|
||||||
|
|
||||||
var localVarPath = "/collaborateurs/{mailApside}/referent"; |
|
||||||
var localVarPathParams = new Dictionary<String, String>(); |
|
||||||
var localVarQueryParams = new List<KeyValuePair<String, String>>(); |
|
||||||
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader); |
|
||||||
var localVarFormParams = new Dictionary<String, String>(); |
|
||||||
var localVarFileParams = new Dictionary<String, FileParameter>(); |
|
||||||
Object localVarPostBody = null; |
|
||||||
|
|
||||||
// to determine the Content-Type header |
|
||||||
String[] localVarHttpContentTypes = new String[] { |
|
||||||
}; |
|
||||||
String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); |
|
||||||
|
|
||||||
// to determine the Accept header |
|
||||||
String[] localVarHttpHeaderAccepts = new String[] { |
|
||||||
"application/json" |
|
||||||
}; |
|
||||||
String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); |
|
||||||
if (localVarHttpHeaderAccept != null) |
|
||||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); |
|
||||||
|
|
||||||
if (mailApside != null) localVarPathParams.Add("mailApside", this.Configuration.ApiClient.ParameterToString(mailApside)); // path parameter |
|
||||||
if (date != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "date", date)); // query parameter |
|
||||||
|
|
||||||
// make the HTTP request |
|
||||||
IRestResponse localVarResponse = (IRestResponse) await this.Configuration.ApiClient.CallApiAsync(localVarPath, |
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, |
|
||||||
localVarPathParams, localVarHttpContentType); |
|
||||||
|
|
||||||
int localVarStatusCode = (int) localVarResponse.StatusCode; |
|
||||||
|
|
||||||
if (ExceptionFactory != null) |
|
||||||
{ |
|
||||||
Exception exception = ExceptionFactory("ChercherRefSuiviParDateCollabMail", localVarResponse); |
|
||||||
if (exception != null) throw exception; |
|
||||||
} |
|
||||||
|
|
||||||
return new ApiResponse<Collaborateur>(localVarStatusCode, |
|
||||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), |
|
||||||
(Collaborateur) this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(Collaborateur))); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,228 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
using EPAServeur.IServices; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class CollaborateursApiController : ControllerBase |
|
||||||
{ |
|
||||||
private readonly ICollaborateurService collaborateurService; |
|
||||||
public CollaborateursApiController(ICollaborateurService _collaborateurService) |
|
||||||
{ |
|
||||||
collaborateurService = _collaborateurService; |
|
||||||
} |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer un collaboratuer par son id</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/collaborateurs/{idCollaborateur}")] |
|
||||||
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetCollaborateurById")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), 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 GetCollaborateurById([FromRoute][Required]Guid? idCollaborateur) |
|
||||||
{ |
|
||||||
//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(CollaborateurDTO)); |
|
||||||
|
|
||||||
CollaborateurDTO collaborateurDTO = collaborateurService.GetCollaborateurById(idCollaborateur); |
|
||||||
if( collaborateurDTO == null) |
|
||||||
{ |
|
||||||
ErreurDTO erreurDTO = new ErreurDTO() |
|
||||||
{ |
|
||||||
Code = "404", |
|
||||||
Message = "Le collaborateur n'existe pas", |
|
||||||
}; |
|
||||||
return NotFound(erreurDTO); |
|
||||||
} |
|
||||||
return Ok(collaborateurDTO); |
|
||||||
//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 \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\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}"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<CollaborateurDTO>(exampleJson) |
|
||||||
: default(CollaborateurDTO); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example);*/ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer un collaborateur par son mail</remarks> |
|
||||||
/// <param name="mail">mail de l'utilisateur connecté (mail obtenu via le token Keycloak)</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/collaborateurs/mail/{mail}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetCollaborateurByMail")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), 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 GetCollaborateurByMail([FromRoute][Required]string mail) |
|
||||||
{ |
|
||||||
//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(CollaborateurDTO)); |
|
||||||
|
|
||||||
//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 \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\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}"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<CollaborateurDTO>(exampleJson) |
|
||||||
: default(CollaborateurDTO); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des collaborateurs</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="fonctions">Liste des fonctions des collaborateurs que l'on veut récupérer</param> |
|
||||||
/// <param name="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="idBU">id de la business unit à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/collaborateurs")] |
|
||||||
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetCollaborateurs")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetCollaborateurs([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]List<string> fonctions, [FromQuery]int? idAgence, [FromQuery]int? idBU, [FromQuery]string texte, [FromQuery]string tri) |
|
||||||
{ |
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
return StatusCode(200, collaborateurService.GetCollaborateurs()); |
|
||||||
//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 \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\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 \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\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} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<CollaborateurDTO>>(exampleJson) |
|
||||||
: default(List<CollaborateurDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example);*/ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des collaborateurs dont le référent à la charge</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/collaborateurs/referent/{idReferent}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetCollaborateursByReferent")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), 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 GetCollaborateursByReferent([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 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(200, default(List<CollaborateurDTO>)); |
|
||||||
|
|
||||||
//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 \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\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 \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\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} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<CollaborateurDTO>>(exampleJson) |
|
||||||
: default(List<CollaborateurDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer un profil collaborateur par mail</remarks> |
|
||||||
/// <param name="mail">mail de l'utilisateur connecté (mail obtenu via le token Keycloak)</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/collaborateurs/profil/{mail}/")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetProfilCollaborateurByMail")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(ProfilDTO), 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 GetProfilCollaborateurByMail([FromRoute][Required]string mail) |
|
||||||
{ |
|
||||||
//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(ProfilDTO)); |
|
||||||
|
|
||||||
//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 \"businessUnit\" : {\n \"agence\" : {\n \"bu\" : [ null, null ],\n \"id\" : 6.027456183070403,\n \"nom\" : \"nom\"\n },\n \"id\" : 0.8008281904610115,\n \"nom\" : \"nom\"\n },\n \"mailApside\" : \"\",\n \"dateArrivee\" : \"2000-01-23T04:56:07.000+00:00\",\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n}"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<ProfilDTO>(exampleJson) |
|
||||||
: default(ProfilDTO); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,125 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class DemandesDelegationApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Faire une demande de délégation à une autre personne</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <param name="idEP">id EP</param> |
|
||||||
/// <response code="200">Demande de délégation envoyée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesdelegation/ep/{idEP}/{idCollaborateur}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("FaireDemandeDelegation")] |
|
||||||
[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 FaireDemandeDelegation([FromRoute][Required]Guid? idCollaborateur, [FromRoute][Required]int? idEP) |
|
||||||
{ |
|
||||||
//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 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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupération de la liste des demandes de délégation</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesdelegation/{idCollaborateur}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetDemandesDelegation")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeDelegationDTO>), 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 GetDemandesDelegation([FromRoute][Required]Guid? idCollaborateur) |
|
||||||
{ |
|
||||||
//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<DemandeDelegationDTO>)); |
|
||||||
|
|
||||||
//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 \"reponse\" : true,\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 1,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}, {\n \"reponse\" : true,\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 1,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<DemandeDelegationDTO>>(exampleJson) |
|
||||||
: default(List<DemandeDelegationDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Faire une demande de délégation à une autre personne</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <param name="idDemandeDelegation">id demande delegation</param> |
|
||||||
/// <response code="200">Réponse demande de délagation envoyée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpPut] |
|
||||||
[Route("/api/demandesdelegation/{idDemandeDelegation}/repondre")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("RepondreDemandeDelegation")] |
|
||||||
[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 RepondreDemandeDelegation([FromBody]CreationDemandeDelegationDTO body, [FromRoute][Required]int? idDemandeDelegation) |
|
||||||
{ |
|
||||||
//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 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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,282 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class DemandesEPIApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Annuler la demande d'EPI</remarks> |
|
||||||
/// <param name="idDemandeEPI">id demande EPI</param> |
|
||||||
/// <response code="200">demande d'EPI annulée</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesepi/{idDemandeEPI}/annuler")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("AnnulerDemandeEPI")] |
|
||||||
[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 AnnulerDemandeEPI([FromRoute][Required]int? idDemandeEPI) |
|
||||||
{ |
|
||||||
//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 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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Lancer la procedure pour un entretien professionnel intermediaire, une demande d'EPI validée est créé par la même occasion</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <param name="idReferent">id referent</param> |
|
||||||
/// <response code="200">Demande d'EPI créée avec l'EPI correspondant</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesepi/referent/{idReferent}/demande/{idCollaborateur}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("CreateEPI")] |
|
||||||
[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 CreateEPI([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); |
|
||||||
|
|
||||||
//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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Demande d'EPI par un collaborateur</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <response code="200">demande d'EPI effectuée</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesepi/collaborateur/{idCollaborateur}/demande")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("DemandeEPI")] |
|
||||||
[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 DemandeEPI([FromRoute][Required]Guid? idCollaborateur) |
|
||||||
{ |
|
||||||
//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 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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Demande d'EPI et par l'assistant et création automatique de l'EPI</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <response code="200">Demande d'EPI créée avec l'EPI correspondant</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesepi/demandeassistante/{idCollaborateur}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("DemandeEPIAssistante")] |
|
||||||
[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 DemandeEPIAssistante([FromRoute][Required]Guid? idCollaborateur) |
|
||||||
{ |
|
||||||
//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 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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupération de la liste des précédents EPI d'un collaborateur</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesepi/collaborateur/{idCollaborateur}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetEPICollaborateur")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeEPIDTO>), 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 GetEPICollaborateur([FromRoute][Required]Guid? idCollaborateur) |
|
||||||
{ |
|
||||||
//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<DemandeEPIDTO>)); |
|
||||||
|
|
||||||
//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 \"reponse\" : true,\n \"idReferent\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"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 \"statut\" : 1.4658129805029452\n },\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etat\" : 6\n}, {\n \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"reponse\" : true,\n \"idReferent\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"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 \"statut\" : 1.4658129805029452\n },\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etat\" : 6\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<DemandeEPIDTO>>(exampleJson) |
|
||||||
: default(List<DemandeEPIDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupération de l'EPI en cours d'un collaborateur</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesepi/collaborateur/{idCollaborateur}/enCours")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetEPIEnCours")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(DemandeEPIDTO), 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 GetEPIEnCours([FromRoute][Required]Guid? idCollaborateur) |
|
||||||
{ |
|
||||||
//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(DemandeEPIDTO)); |
|
||||||
|
|
||||||
//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 \"reponse\" : true,\n \"idReferent\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"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 \"statut\" : 1.4658129805029452\n },\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etat\" : 6\n}"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<DemandeEPIDTO>(exampleJson) |
|
||||||
: default(DemandeEPIDTO); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupération de la liste des précédents EPI d'un referent</remarks> |
|
||||||
/// <param name="idReferent">id referent</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/demandesepi/referent/{idReferent}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetEPIReferent")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeEPIDTO>), 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 GetEPIReferent([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<DemandeEPIDTO>)); |
|
||||||
|
|
||||||
//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 \"reponse\" : true,\n \"idReferent\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"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 \"statut\" : 1.4658129805029452\n },\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etat\" : 6\n}, {\n \"idCollaborateur\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"reponse\" : true,\n \"idReferent\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"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 \"statut\" : 1.4658129805029452\n },\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etat\" : 6\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<DemandeEPIDTO>>(exampleJson) |
|
||||||
: default(List<DemandeEPIDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Répondre à une demande EPI en attente</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <param name="idDemandeEPI">id demande EPI</param> |
|
||||||
/// <response code="200">Réponse à la demande d'EPI envoyée</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpPut] |
|
||||||
[Route("/api/demandesepi/{idDemandeEPI}/repondre")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("RepondreDemandeEPI")] |
|
||||||
[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 RepondreDemandeEPI([FromBody]DemandeEPIDTO body, [FromRoute][Required]int? idDemandeEPI) |
|
||||||
{ |
|
||||||
//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 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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,249 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class DemandesFormationApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Créer une demande de formation pour un collaborateur</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <response code="201">Demande formation créée</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpPost] |
|
||||||
[Route("/api/demandeformation")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("CreerDemandeFormation")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult CreerDemandeFormation([FromBody]CreationDemandeFormationDTO 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(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des demandes de formations</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="theme">Thème des demandes de formation à récupérer</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] |
|
||||||
[Route("/api/demandeformation")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetDemandesFormation")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeFormationDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetDemandesFormation([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]string texte, [FromQuery]int? theme, [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<DemandeFormationDTO>)); |
|
||||||
|
|
||||||
//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 \"reponse\" : true,\n \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"theme\" : {\n \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n },\n \"id\" : 7,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"statut\" : 1.4658129805029452\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}, {\n \"reponse\" : true,\n \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"theme\" : {\n \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n },\n \"id\" : 7,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"statut\" : 1.4658129805029452\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<DemandeFormationDTO>>(exampleJson) |
|
||||||
: default(List<DemandeFormationDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des demandes de formations en attente d'une réponse</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="theme">Thème des demandes de formation à récupérer</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] |
|
||||||
[Route("/api/demandeformation/enattente")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetDemandesFormationEnAttente")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeFormationDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetDemandesFormationEnAttente([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]string texte, [FromQuery]int? theme, [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<DemandeFormationDTO>)); |
|
||||||
|
|
||||||
//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 \"reponse\" : true,\n \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"theme\" : {\n \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n },\n \"id\" : 7,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"statut\" : 1.4658129805029452\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}, {\n \"reponse\" : true,\n \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"theme\" : {\n \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n },\n \"id\" : 7,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"statut\" : 1.4658129805029452\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<DemandeFormationDTO>>(exampleJson) |
|
||||||
: default(List<DemandeFormationDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des demandes de formations ayant reçu une réponse</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="theme">Thème des demandes de formation à récupérer</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] |
|
||||||
[Route("/api/demandeformation/repondus")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetDemandesFormationRepondues")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeFormationDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetDemandesFormationRepondues([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]int? idAgence, [FromQuery]string texte, [FromQuery]int? theme, [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<DemandeFormationDTO>)); |
|
||||||
|
|
||||||
//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 \"reponse\" : true,\n \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"theme\" : {\n \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n },\n \"id\" : 7,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"statut\" : 1.4658129805029452\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}, {\n \"reponse\" : true,\n \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"theme\" : {\n \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n },\n \"id\" : 7,\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 0.8008281904610115,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"type\" : 6,\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 \"statut\" : 1.4658129805029452\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<DemandeFormationDTO>>(exampleJson) |
|
||||||
: default(List<DemandeFormationDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des origines des demandes de formation</remarks> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/originesdemandesformation")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetOriginesDemandesFormation")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<OrigineDemandeFormationDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetOriginesDemandesFormation() |
|
||||||
{ |
|
||||||
//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<OrigineDemandeFormationDTO>)); |
|
||||||
|
|
||||||
//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\" : 0\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 0\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<OrigineDemandeFormationDTO>>(exampleJson) |
|
||||||
: default(List<OrigineDemandeFormationDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des thèmes des demandes de formation</remarks> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/themes")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetThemes")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<ThemeDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetThemes() |
|
||||||
{ |
|
||||||
//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<ThemeDTO>)); |
|
||||||
|
|
||||||
//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 \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n}, {\n \"id\" : 9,\n \"demandesFormation\" : [ null, null ],\n \"nom\" : \"nom\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<ThemeDTO>>(exampleJson) |
|
||||||
: default(List<ThemeDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Répondre a une demande de formation et la mettre à jour</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <param name="idDemandeFormation">id demande formation</param> |
|
||||||
/// <response code="200">demande formation mise à jour</response> |
|
||||||
/// <response code="201">Demande formation créée</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpPut] |
|
||||||
[Route("/api/demandeformation/{idDemandeFormation}/repondre")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("RepondreDemandeFormation")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult RepondreDemandeFormation([FromBody]DemandeFormationDTO body, [FromRoute][Required]int? idDemandeFormation) |
|
||||||
{ |
|
||||||
//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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,160 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class EngagementsApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des engagements</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/engagements")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetEngagements")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
||||||
[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]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<EngagementDTO>)); |
|
||||||
|
|
||||||
//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 \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2.027123023002322,\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.027123023002322,\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> |
|
||||||
/// <remarks>Récupérer la liste des engagements en attente</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/engagements/enattente")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetEngagementsEnAttente")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
||||||
[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]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<EngagementDTO>)); |
|
||||||
|
|
||||||
//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 \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2.027123023002322,\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.027123023002322,\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> |
|
||||||
/// <remarks>Récupérer la liste des engagements ayant reçu une réponse</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/engagements/repondus")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetEngagementsRepondus")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
|
||||||
[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]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<EngagementDTO>)); |
|
||||||
|
|
||||||
//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 \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2.027123023002322,\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.027123023002322,\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> |
|
||||||
/// <remarks>Donnez une réponse à un engagement</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <param name="idEngagement">id engagement</param> |
|
||||||
/// <response code="200">Engagement mise à jour</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpPut] |
|
||||||
[Route("/api/engagements/{idEngagement}/repondre")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("RepondreEngagement")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult RepondreEngagement([FromBody]EngagementDTO body, [FromRoute][Required]int? idEngagement) |
|
||||||
{ |
|
||||||
//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 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(403, default(ErreurDTO)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
File diff suppressed because one or more lines are too long
@ -1,414 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class FormationsApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Ajouter une nouvelle formation</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <response code="201">Formation créée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpPost] |
|
||||||
[Route("/api/formations")] |
|
||||||
[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(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Supprimer une formation</remarks> |
|
||||||
/// <param name="idFormation">id formation</param> |
|
||||||
/// <response code="204">Formation supprimée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpDelete] |
|
||||||
[Route("/api/formations/{idFormation}/supprimer")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("DeleteFormation")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult DeleteFormation([FromRoute][Required]decimal? 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(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer les formations annulées</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/formations/annulees")] |
|
||||||
[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'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) |
|
||||||
{ |
|
||||||
//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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer une formation par son id</remarks> |
|
||||||
/// <param name="idFormation">id formation</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/formations/{idFormation}")] |
|
||||||
[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'a pas été trouvée")] |
|
||||||
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)); |
|
||||||
|
|
||||||
//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\" : 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> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer les formations réalisées</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/formations/realisees")] |
|
||||||
[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'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) |
|
||||||
{ |
|
||||||
//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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des formations</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="statutFormation">Statut de la formation</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] |
|
||||||
[Route("/api/formations")] |
|
||||||
[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]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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <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)] |
|
||||||
[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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <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)] |
|
||||||
[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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer les formations plannifié et replannifié</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="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/formations/prochaines")] |
|
||||||
[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'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) |
|
||||||
{ |
|
||||||
//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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <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)] |
|
||||||
[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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <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)] |
|
||||||
[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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Mettre à jour une formation</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <param name="idFormation">id formation</param> |
|
||||||
/// <response code="200">formation mise à jour</response> |
|
||||||
/// <response code="201">Formation créée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpPut] |
|
||||||
[Route("/api/formations/{idFormation}/update")] |
|
||||||
[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]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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,247 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class NotesApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Supprimer une note</remarks> |
|
||||||
/// <param name="idNote">id note</param> |
|
||||||
/// <response code="204">Note supprimée</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpDelete] |
|
||||||
[Route("/api/notes/{idNote}/supprimer")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("DeleteNote")] |
|
||||||
[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 DeleteNote([FromRoute][Required]int? idNote) |
|
||||||
{ |
|
||||||
//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)); |
|
||||||
|
|
||||||
//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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer une note par son id</remarks> |
|
||||||
/// <param name="idNote">id note</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/{idNote}")] |
|
||||||
[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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer toutes les notes</remarks> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/notes/")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetNotes")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<AffichageNoteDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetNotes() |
|
||||||
{ |
|
||||||
//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>)); |
|
||||||
|
|
||||||
//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 \"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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer les notes d'une personne a écrite</remarks> |
|
||||||
/// <param name="idReferent">id referent</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/notes/auteur/{idReferent}")] |
|
||||||
[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>)); |
|
||||||
|
|
||||||
//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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer une note par son id</remarks> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <param name="idReferent">id referent</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/notes/auteur/{idReferent}/collaborateur/{idCollaborateur}")] |
|
||||||
[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>)); |
|
||||||
|
|
||||||
//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); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Ajouter une nouvelle note</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <response code="201">Note créée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpPost] |
|
||||||
[Route("/api/notes/nouvellenote")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("NouvelleNote")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult NouvelleNote([FromBody]DetailsNoteDTO 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(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Mettre à jour une note</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <param name="idNote">id note</param> |
|
||||||
/// <response code="200">Note mise à jour avec succès</response> |
|
||||||
/// <response code="201">Note créée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpPut] |
|
||||||
[Route("/api/notes/{idNote}/updateNote")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("UpdateNote")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult UpdateNote([FromBody]DetailsNoteDTO body, [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); |
|
||||||
|
|
||||||
//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(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,175 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class ParticipationsFormationsApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Consulter une évaluation d'une formation</remarks> |
|
||||||
/// <param name="idParticipationFormation">id participation formation</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/evaluations/participationformation/{idParticipationFormation}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("ConsulterEvaluation")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(EvaluationDTO), 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 ConsulterEvaluation([FromRoute][Required]decimal? idParticipationFormation) |
|
||||||
{ |
|
||||||
//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(EvaluationDTO)); |
|
||||||
|
|
||||||
//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 \"idParticipation\" : 0,\n \"saisies\" : [ {\n \"note\" : 7,\n \"texte2\" : \"texte2\",\n \"texte\" : \"texte\",\n \"id\" : \"id\",\n \"champ\" : {\n \"typeChamp\" : \"typeChamp\",\n \"ordre\" : 5.025004791520295,\n \"texte\" : \"texte\",\n \"section\" : \"section\",\n \"soussection\" : \"soussection\",\n \"id\" : 4,\n \"typeSaisie\" : \"typeSaisie\"\n },\n \"typeSaisie\" : 6,\n \"niveau\" : 1\n }, {\n \"note\" : 7,\n \"texte2\" : \"texte2\",\n \"texte\" : \"texte\",\n \"id\" : \"id\",\n \"champ\" : {\n \"typeChamp\" : \"typeChamp\",\n \"ordre\" : 5.025004791520295,\n \"texte\" : \"texte\",\n \"section\" : \"section\",\n \"soussection\" : \"soussection\",\n \"id\" : 4,\n \"typeSaisie\" : \"typeSaisie\"\n },\n \"typeSaisie\" : 6,\n \"niveau\" : 1\n } ]\n}"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<EvaluationDTO>(exampleJson) |
|
||||||
: default(EvaluationDTO); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Evaluer une formation</remarks> |
|
||||||
/// <param name="body"></param> |
|
||||||
/// <param name="idParticipationFormation">id participation formation</param> |
|
||||||
/// <response code="200">Evaluation envoyée avec succès</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpPut] |
|
||||||
[Route("/api/evaluations/participationformation/{idParticipationFormation}/evaluer")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("EvaluerFormation")] |
|
||||||
[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 EvaluerFormation([FromBody]EvaluationDTO body, [FromRoute][Required]decimal? idParticipationFormation) |
|
||||||
{ |
|
||||||
//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 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)); |
|
||||||
|
|
||||||
throw new NotImplementedException(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des formations auxquelles est inscrit le collaborateur</remarks> |
|
||||||
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</param> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <param name="numPage">Numéro de la page du tableau qui affiche les données</param> |
|
||||||
/// <param name="parPAge">Nombre d'éléments affiché sur chaque page du tableau</param> |
|
||||||
/// <param name="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/participationsformation/collaborateur/{idCollaborateur}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetParticipationByCollaborateur")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<ParticipationFormationDTO>), 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 GetParticipationByCollaborateur([FromQuery][Required()]bool? asc, [FromRoute][Required]Guid? idCollaborateur, [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<ParticipationFormationDTO>)); |
|
||||||
|
|
||||||
//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 \"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\" : 0,\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\" : 0,\n \"formation\" : \"formation\",\n \"collaborateur\" : \"collaborateur\",\n \"statut\" : \"statut\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<ParticipationFormationDTO>>(exampleJson) |
|
||||||
: default(List<ParticipationFormationDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des participants d'une formation</remarks> |
|
||||||
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</param> |
|
||||||
/// <param name="idFormation">id formation</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/participationsformation/formation/{idFormation}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetParticipationByFormation")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<ParticipationFormationDTO>), 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 GetParticipationByFormation([FromQuery][Required()]bool? asc, [FromRoute][Required]decimal? idFormation, [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<ParticipationFormationDTO>)); |
|
||||||
|
|
||||||
//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 \"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\" : 0,\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\" : 0,\n \"formation\" : \"formation\",\n \"collaborateur\" : \"collaborateur\",\n \"statut\" : \"statut\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<ParticipationFormationDTO>>(exampleJson) |
|
||||||
: default(List<ParticipationFormationDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,142 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Microsoft.AspNetCore.Mvc; |
|
||||||
using Swashbuckle.AspNetCore.Annotations; |
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen; |
|
||||||
using Newtonsoft.Json; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using IO.Swagger.Attributes; |
|
||||||
using IO.Swagger.Security; |
|
||||||
using Microsoft.AspNetCore.Authorization; |
|
||||||
using IO.Swagger.DTO; |
|
||||||
|
|
||||||
namespace IO.Swagger.Controllers |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[ApiController] |
|
||||||
public class ReferentsApiController : ControllerBase |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste des référents d'un collaborateur</remarks> |
|
||||||
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</param> |
|
||||||
/// <param name="idCollaborateur">id collaborateur</param> |
|
||||||
/// <param name="numPage">Numéro de la page du tableau qui affiche les données</param> |
|
||||||
/// <param name="parPAge">Nombre d'éléments affiché sur chaque page du tableau</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/referents/collaborateur/{idCollaborateur}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetReferentByCollaborateur")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<ReferentDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
||||||
public virtual IActionResult GetReferentByCollaborateur([FromQuery][Required()]bool? asc, [FromRoute][Required]Guid? idCollaborateur, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]string texte, [FromQuery]string tri) |
|
||||||
{ |
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(200, default(List<ReferentDTO>)); |
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(403, default(ErreurDTO)); |
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(404, default(ErreurDTO)); |
|
||||||
string exampleJson = null; |
|
||||||
exampleJson = "[ {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"collaborateur\" : [ null, null ],\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n}, {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"collaborateur\" : [ null, null ],\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<ReferentDTO>>(exampleJson) |
|
||||||
: default(List<ReferentDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer un referent par son id</remarks> |
|
||||||
/// <param name="idReferent">id referent</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
/// <response code="404">Ressource n'a pas été trouvée</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/referents/{idReferent}")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetReferentById")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(ReferentDTO), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "Ressource n'a pas été trouvée")] |
|
||||||
public virtual IActionResult GetReferentById([FromRoute][Required]Guid? idReferent) |
|
||||||
{ |
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(200, default(ReferentDTO)); |
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(403, default(ErreurDTO)); |
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(404, default(ErreurDTO)); |
|
||||||
string exampleJson = null; |
|
||||||
exampleJson = "{\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"collaborateur\" : [ null, null ],\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n}"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<ReferentDTO>(exampleJson) |
|
||||||
: default(ReferentDTO); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
/// <remarks>Récupérer la liste de tous les referents</remarks> |
|
||||||
/// <param name="asc">Préciser si les données sont dans l'ordre (true) ou dans l'ordre inverse (false)</param> |
|
||||||
/// <param name="numPage">Numéro de la page du tableau qui affiche les données</param> |
|
||||||
/// <param name="parPAge">Nombre d'éléments affiché sur chaque page du tableau</param> |
|
||||||
/// <param name="fonctions">Liste des fonctions des collaborateurs que l'on veut récupérer</param> |
|
||||||
/// <param name="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="idBU">id de la business unit à laquelle sont rattachées les données à récupérer</param> |
|
||||||
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param> |
|
||||||
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param> |
|
||||||
/// <response code="200">OK</response> |
|
||||||
/// <response code="403">Acces interdit</response> |
|
||||||
[HttpGet] |
|
||||||
[Route("/api/referents")] |
|
||||||
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
|
||||||
[ValidateModelState] |
|
||||||
[SwaggerOperation("GetReferents")] |
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(List<ReferentDTO>), description: "OK")] |
|
||||||
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")] |
|
||||||
public virtual IActionResult GetReferents([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]List<string> fonctions, [FromQuery]int? idAgence, [FromQuery]int? idBU, [FromQuery]string texte, [FromQuery]string tri) |
|
||||||
{ |
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(200, default(List<ReferentDTO>)); |
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
|
||||||
// return StatusCode(403, default(ErreurDTO)); |
|
||||||
string exampleJson = null; |
|
||||||
exampleJson = "[ {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"collaborateur\" : [ null, null ],\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n}, {\n \"mailApside\" : \"\",\n \"id\" : \"046b6c7f-0b8a-43b9-b35d-6489e6daee91\",\n \"collaborateur\" : [ null, null ],\n \"nom\" : \"nom\",\n \"prenom\" : \"prenom\"\n} ]"; |
|
||||||
|
|
||||||
var example = exampleJson != null |
|
||||||
? JsonConvert.DeserializeObject<List<ReferentDTO>>(exampleJson) |
|
||||||
: default(List<ReferentDTO>); //TODO: Change the data returned |
|
||||||
return new ObjectResult(example); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,148 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Linq; |
|
||||||
using System.IO; |
|
||||||
using System.Text; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Collections.ObjectModel; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using Newtonsoft.Json; |
|
||||||
|
|
||||||
namespace IO.Swagger.DTO |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Objet à envoyer lorsqu'un référent fait une demande de délégation |
|
||||||
/// </summary> |
|
||||||
[DataContract] |
|
||||||
public partial class CreationDemandeDelegationDTO : IEquatable<CreationDemandeDelegationDTO> |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets IdEp |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="idEp")] |
|
||||||
public int? IdEp { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets IdReferent |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="idReferent")] |
|
||||||
public CollaborateurDTO IdReferent { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets RaisonDemande |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="raisonDemande")] |
|
||||||
public string RaisonDemande { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>String presentation of the object</returns> |
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
var sb = new StringBuilder(); |
|
||||||
sb.Append("class CreationDemandeDelegationDTO {\n"); |
|
||||||
sb.Append(" IdEp: ").Append(IdEp).Append("\n"); |
|
||||||
sb.Append(" IdReferent: ").Append(IdReferent).Append("\n"); |
|
||||||
sb.Append(" RaisonDemande: ").Append(RaisonDemande).Append("\n"); |
|
||||||
sb.Append("}\n"); |
|
||||||
return sb.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the JSON string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>JSON string presentation of the object</returns> |
|
||||||
public string ToJson() |
|
||||||
{ |
|
||||||
return JsonConvert.SerializeObject(this, Formatting.Indented); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if objects are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="obj">Object to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public override bool Equals(object obj) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, obj)) return false; |
|
||||||
if (ReferenceEquals(this, obj)) return true; |
|
||||||
return obj.GetType() == GetType() && Equals((CreationDemandeDelegationDTO)obj); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if CreationDemandeDelegationDTO instances are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="other">Instance of CreationDemandeDelegationDTO to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public bool Equals(CreationDemandeDelegationDTO other) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, other)) return false; |
|
||||||
if (ReferenceEquals(this, other)) return true; |
|
||||||
|
|
||||||
return |
|
||||||
( |
|
||||||
IdEp == other.IdEp || |
|
||||||
IdEp != null && |
|
||||||
IdEp.Equals(other.IdEp) |
|
||||||
) && |
|
||||||
( |
|
||||||
IdReferent == other.IdReferent || |
|
||||||
IdReferent != null && |
|
||||||
IdReferent.Equals(other.IdReferent) |
|
||||||
) && |
|
||||||
( |
|
||||||
RaisonDemande == other.RaisonDemande || |
|
||||||
RaisonDemande != null && |
|
||||||
RaisonDemande.Equals(other.RaisonDemande) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets the hash code |
|
||||||
/// </summary> |
|
||||||
/// <returns>Hash code</returns> |
|
||||||
public override int GetHashCode() |
|
||||||
{ |
|
||||||
unchecked // Overflow is fine, just wrap |
|
||||||
{ |
|
||||||
var hashCode = 41; |
|
||||||
// Suitable nullity checks etc, of course :) |
|
||||||
if (IdEp != null) |
|
||||||
hashCode = hashCode * 59 + IdEp.GetHashCode(); |
|
||||||
if (IdReferent != null) |
|
||||||
hashCode = hashCode * 59 + IdReferent.GetHashCode(); |
|
||||||
if (RaisonDemande != null) |
|
||||||
hashCode = hashCode * 59 + RaisonDemande.GetHashCode(); |
|
||||||
return hashCode; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#region Operators |
|
||||||
#pragma warning disable 1591 |
|
||||||
|
|
||||||
public static bool operator ==(CreationDemandeDelegationDTO left, CreationDemandeDelegationDTO right) |
|
||||||
{ |
|
||||||
return Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool operator !=(CreationDemandeDelegationDTO left, CreationDemandeDelegationDTO right) |
|
||||||
{ |
|
||||||
return !Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
#pragma warning restore 1591 |
|
||||||
#endregion Operators |
|
||||||
} |
|
||||||
} |
|
@ -1,221 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Linq; |
|
||||||
using System.IO; |
|
||||||
using System.Text; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Collections.ObjectModel; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using Newtonsoft.Json; |
|
||||||
|
|
||||||
namespace IO.Swagger.DTO |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// |
|
||||||
/// </summary> |
|
||||||
[DataContract] |
|
||||||
public partial class FormationDTOParticipantsFormation : IEquatable<FormationDTOParticipantsFormation> |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Id |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="id")] |
|
||||||
public int? Id { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets DateCreation |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="dateCreation")] |
|
||||||
public DateTime? DateCreation { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Formation |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="formation")] |
|
||||||
public string Formation { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Date |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="date")] |
|
||||||
public DateTime? Date { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Statut |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="statut")] |
|
||||||
public string Statut { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets IdCollaborateur |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="idCollaborateur")] |
|
||||||
public Guid? IdCollaborateur { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Collaborateur |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="collaborateur")] |
|
||||||
public string Collaborateur { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets EstEvaluee |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="estEvaluee")] |
|
||||||
public bool? EstEvaluee { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>String presentation of the object</returns> |
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
var sb = new StringBuilder(); |
|
||||||
sb.Append("class FormationDTOParticipantsFormation {\n"); |
|
||||||
sb.Append(" Id: ").Append(Id).Append("\n"); |
|
||||||
sb.Append(" DateCreation: ").Append(DateCreation).Append("\n"); |
|
||||||
sb.Append(" Formation: ").Append(Formation).Append("\n"); |
|
||||||
sb.Append(" Date: ").Append(Date).Append("\n"); |
|
||||||
sb.Append(" Statut: ").Append(Statut).Append("\n"); |
|
||||||
sb.Append(" IdCollaborateur: ").Append(IdCollaborateur).Append("\n"); |
|
||||||
sb.Append(" Collaborateur: ").Append(Collaborateur).Append("\n"); |
|
||||||
sb.Append(" EstEvaluee: ").Append(EstEvaluee).Append("\n"); |
|
||||||
sb.Append("}\n"); |
|
||||||
return sb.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the JSON string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>JSON string presentation of the object</returns> |
|
||||||
public string ToJson() |
|
||||||
{ |
|
||||||
return JsonConvert.SerializeObject(this, Formatting.Indented); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if objects are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="obj">Object to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public override bool Equals(object obj) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, obj)) return false; |
|
||||||
if (ReferenceEquals(this, obj)) return true; |
|
||||||
return obj.GetType() == GetType() && Equals((FormationDTOParticipantsFormation)obj); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if FormationDTOParticipantsFormation instances are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="other">Instance of FormationDTOParticipantsFormation to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public bool Equals(FormationDTOParticipantsFormation other) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, other)) return false; |
|
||||||
if (ReferenceEquals(this, other)) return true; |
|
||||||
|
|
||||||
return |
|
||||||
( |
|
||||||
Id == other.Id || |
|
||||||
Id != null && |
|
||||||
Id.Equals(other.Id) |
|
||||||
) && |
|
||||||
( |
|
||||||
DateCreation == other.DateCreation || |
|
||||||
DateCreation != null && |
|
||||||
DateCreation.Equals(other.DateCreation) |
|
||||||
) && |
|
||||||
( |
|
||||||
Formation == other.Formation || |
|
||||||
Formation != null && |
|
||||||
Formation.Equals(other.Formation) |
|
||||||
) && |
|
||||||
( |
|
||||||
Date == other.Date || |
|
||||||
Date != null && |
|
||||||
Date.Equals(other.Date) |
|
||||||
) && |
|
||||||
( |
|
||||||
Statut == other.Statut || |
|
||||||
Statut != null && |
|
||||||
Statut.Equals(other.Statut) |
|
||||||
) && |
|
||||||
( |
|
||||||
IdCollaborateur == other.IdCollaborateur || |
|
||||||
IdCollaborateur != null && |
|
||||||
IdCollaborateur.Equals(other.IdCollaborateur) |
|
||||||
) && |
|
||||||
( |
|
||||||
Collaborateur == other.Collaborateur || |
|
||||||
Collaborateur != null && |
|
||||||
Collaborateur.Equals(other.Collaborateur) |
|
||||||
) && |
|
||||||
( |
|
||||||
EstEvaluee == other.EstEvaluee || |
|
||||||
EstEvaluee != null && |
|
||||||
EstEvaluee.Equals(other.EstEvaluee) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets the hash code |
|
||||||
/// </summary> |
|
||||||
/// <returns>Hash code</returns> |
|
||||||
public override int GetHashCode() |
|
||||||
{ |
|
||||||
unchecked // Overflow is fine, just wrap |
|
||||||
{ |
|
||||||
var hashCode = 41; |
|
||||||
// Suitable nullity checks etc, of course :) |
|
||||||
if (Id != null) |
|
||||||
hashCode = hashCode * 59 + Id.GetHashCode(); |
|
||||||
if (DateCreation != null) |
|
||||||
hashCode = hashCode * 59 + DateCreation.GetHashCode(); |
|
||||||
if (Formation != null) |
|
||||||
hashCode = hashCode * 59 + Formation.GetHashCode(); |
|
||||||
if (Date != null) |
|
||||||
hashCode = hashCode * 59 + Date.GetHashCode(); |
|
||||||
if (Statut != null) |
|
||||||
hashCode = hashCode * 59 + Statut.GetHashCode(); |
|
||||||
if (IdCollaborateur != null) |
|
||||||
hashCode = hashCode * 59 + IdCollaborateur.GetHashCode(); |
|
||||||
if (Collaborateur != null) |
|
||||||
hashCode = hashCode * 59 + Collaborateur.GetHashCode(); |
|
||||||
if (EstEvaluee != null) |
|
||||||
hashCode = hashCode * 59 + EstEvaluee.GetHashCode(); |
|
||||||
return hashCode; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#region Operators |
|
||||||
#pragma warning disable 1591 |
|
||||||
|
|
||||||
public static bool operator ==(FormationDTOParticipantsFormation left, FormationDTOParticipantsFormation right) |
|
||||||
{ |
|
||||||
return Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool operator !=(FormationDTOParticipantsFormation left, FormationDTOParticipantsFormation right) |
|
||||||
{ |
|
||||||
return !Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
#pragma warning restore 1591 |
|
||||||
#endregion Operators |
|
||||||
} |
|
||||||
} |
|
@ -1,193 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Linq; |
|
||||||
using System.IO; |
|
||||||
using System.Text; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Collections.ObjectModel; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using Newtonsoft.Json; |
|
||||||
|
|
||||||
namespace IO.Swagger.DTO |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Les informations d'un collaborateur |
|
||||||
/// </summary> |
|
||||||
[DataContract] |
|
||||||
public partial class ReferentDTO : IEquatable<ReferentDTO> |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Id |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="id")] |
|
||||||
public Guid? Id { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Nom |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="nom")] |
|
||||||
public string Nom { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Prenom |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="prenom")] |
|
||||||
public string Prenom { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets MailApside |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="mailApside")] |
|
||||||
public string MailApside { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets BusinessUnit |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="businessUnit")] |
|
||||||
public BusinessUnitDTO BusinessUnit { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Collaborateur |
|
||||||
/// </summary> |
|
||||||
[DataMember(Name="collaborateurs")] |
|
||||||
public List<CollaborateurDTO> Collaborateurs { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>String presentation of the object</returns> |
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
var sb = new StringBuilder(); |
|
||||||
sb.Append("class ReferentDTO {\n"); |
|
||||||
sb.Append(" Id: ").Append(Id).Append("\n"); |
|
||||||
sb.Append(" Nom: ").Append(Nom).Append("\n"); |
|
||||||
sb.Append(" Prenom: ").Append(Prenom).Append("\n"); |
|
||||||
sb.Append(" MailApside: ").Append(MailApside).Append("\n"); |
|
||||||
sb.Append(" BusinessUnit: ").Append(BusinessUnit).Append("\n"); |
|
||||||
sb.Append(" Collaborateur: ").Append(Collaborateurs).Append("\n"); |
|
||||||
sb.Append("}\n"); |
|
||||||
return sb.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the JSON string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>JSON string presentation of the object</returns> |
|
||||||
public string ToJson() |
|
||||||
{ |
|
||||||
return JsonConvert.SerializeObject(this, Formatting.Indented); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if objects are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="obj">Object to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public override bool Equals(object obj) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, obj)) return false; |
|
||||||
if (ReferenceEquals(this, obj)) return true; |
|
||||||
return obj.GetType() == GetType() && Equals((ReferentDTO)obj); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if ReferentDTO instances are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="other">Instance of ReferentDTO to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public bool Equals(ReferentDTO other) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, other)) return false; |
|
||||||
if (ReferenceEquals(this, other)) return true; |
|
||||||
|
|
||||||
return |
|
||||||
( |
|
||||||
Id == other.Id || |
|
||||||
Id != null && |
|
||||||
Id.Equals(other.Id) |
|
||||||
) && |
|
||||||
( |
|
||||||
Nom == other.Nom || |
|
||||||
Nom != null && |
|
||||||
Nom.Equals(other.Nom) |
|
||||||
) && |
|
||||||
( |
|
||||||
Prenom == other.Prenom || |
|
||||||
Prenom != null && |
|
||||||
Prenom.Equals(other.Prenom) |
|
||||||
) && |
|
||||||
( |
|
||||||
MailApside == other.MailApside || |
|
||||||
MailApside != null && |
|
||||||
MailApside.Equals(other.MailApside) |
|
||||||
) && |
|
||||||
( |
|
||||||
BusinessUnit == other.BusinessUnit || |
|
||||||
BusinessUnit != null && |
|
||||||
BusinessUnit.Equals(other.BusinessUnit) |
|
||||||
) && |
|
||||||
( |
|
||||||
Collaborateurs == other.Collaborateurs || |
|
||||||
Collaborateurs != null && |
|
||||||
Collaborateurs.SequenceEqual(other.Collaborateurs) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets the hash code |
|
||||||
/// </summary> |
|
||||||
/// <returns>Hash code</returns> |
|
||||||
public override int GetHashCode() |
|
||||||
{ |
|
||||||
unchecked // Overflow is fine, just wrap |
|
||||||
{ |
|
||||||
var hashCode = 41; |
|
||||||
// Suitable nullity checks etc, of course :) |
|
||||||
if (Id != null) |
|
||||||
hashCode = hashCode * 59 + Id.GetHashCode(); |
|
||||||
if (Nom != null) |
|
||||||
hashCode = hashCode * 59 + Nom.GetHashCode(); |
|
||||||
if (Prenom != null) |
|
||||||
hashCode = hashCode * 59 + Prenom.GetHashCode(); |
|
||||||
if (MailApside != null) |
|
||||||
hashCode = hashCode * 59 + MailApside.GetHashCode(); |
|
||||||
if (BusinessUnit != null) |
|
||||||
hashCode = hashCode * 59 + BusinessUnit.GetHashCode(); |
|
||||||
if (Collaborateurs != null) |
|
||||||
hashCode = hashCode * 59 + Collaborateurs.GetHashCode(); |
|
||||||
return hashCode; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#region Operators |
|
||||||
#pragma warning disable 1591 |
|
||||||
|
|
||||||
public static bool operator ==(ReferentDTO left, ReferentDTO right) |
|
||||||
{ |
|
||||||
return Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool operator !=(ReferentDTO left, ReferentDTO right) |
|
||||||
{ |
|
||||||
return !Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
#pragma warning restore 1591 |
|
||||||
#endregion Operators |
|
||||||
} |
|
||||||
} |
|
@ -1,150 +0,0 @@ |
|||||||
/* |
|
||||||
* API du serveur de l'application de digitalisation des EP |
|
||||||
* |
|
||||||
* 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.1 |
|
||||||
* |
|
||||||
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.Linq; |
|
||||||
using System.IO; |
|
||||||
using System.Text; |
|
||||||
using System.Collections; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Collections.ObjectModel; |
|
||||||
using System.ComponentModel.DataAnnotations; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using Newtonsoft.Json; |
|
||||||
|
|
||||||
namespace IO.Swagger.DTO |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Thème d'une demande de formation |
|
||||||
/// </summary> |
|
||||||
[DataContract] |
|
||||||
public partial class ThemeDTO : IEquatable<ThemeDTO> |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Id |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="id")] |
|
||||||
public int? Id { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets Nom |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="nom")] |
|
||||||
public string Nom { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets or Sets DemandesFormation |
|
||||||
/// </summary> |
|
||||||
[Required] |
|
||||||
[DataMember(Name="demandesFormation")] |
|
||||||
public List<DemandeFormationDTO> DemandesFormation { get; set; } |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>String presentation of the object</returns> |
|
||||||
public override string ToString() |
|
||||||
{ |
|
||||||
var sb = new StringBuilder(); |
|
||||||
sb.Append("class ThemeDTO {\n"); |
|
||||||
sb.Append(" Id: ").Append(Id).Append("\n"); |
|
||||||
sb.Append(" Nom: ").Append(Nom).Append("\n"); |
|
||||||
sb.Append(" DemandesFormation: ").Append(DemandesFormation).Append("\n"); |
|
||||||
sb.Append("}\n"); |
|
||||||
return sb.ToString(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns the JSON string presentation of the object |
|
||||||
/// </summary> |
|
||||||
/// <returns>JSON string presentation of the object</returns> |
|
||||||
public string ToJson() |
|
||||||
{ |
|
||||||
return JsonConvert.SerializeObject(this, Formatting.Indented); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if objects are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="obj">Object to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public override bool Equals(object obj) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, obj)) return false; |
|
||||||
if (ReferenceEquals(this, obj)) return true; |
|
||||||
return obj.GetType() == GetType() && Equals((ThemeDTO)obj); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Returns true if ThemeDTO instances are equal |
|
||||||
/// </summary> |
|
||||||
/// <param name="other">Instance of ThemeDTO to be compared</param> |
|
||||||
/// <returns>Boolean</returns> |
|
||||||
public bool Equals(ThemeDTO other) |
|
||||||
{ |
|
||||||
if (ReferenceEquals(null, other)) return false; |
|
||||||
if (ReferenceEquals(this, other)) return true; |
|
||||||
|
|
||||||
return |
|
||||||
( |
|
||||||
Id == other.Id || |
|
||||||
Id != null && |
|
||||||
Id.Equals(other.Id) |
|
||||||
) && |
|
||||||
( |
|
||||||
Nom == other.Nom || |
|
||||||
Nom != null && |
|
||||||
Nom.Equals(other.Nom) |
|
||||||
) && |
|
||||||
( |
|
||||||
DemandesFormation == other.DemandesFormation || |
|
||||||
DemandesFormation != null && |
|
||||||
DemandesFormation.SequenceEqual(other.DemandesFormation) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Gets the hash code |
|
||||||
/// </summary> |
|
||||||
/// <returns>Hash code</returns> |
|
||||||
public override int GetHashCode() |
|
||||||
{ |
|
||||||
unchecked // Overflow is fine, just wrap |
|
||||||
{ |
|
||||||
var hashCode = 41; |
|
||||||
// Suitable nullity checks etc, of course :) |
|
||||||
if (Id != null) |
|
||||||
hashCode = hashCode * 59 + Id.GetHashCode(); |
|
||||||
if (Nom != null) |
|
||||||
hashCode = hashCode * 59 + Nom.GetHashCode(); |
|
||||||
if (DemandesFormation != null) |
|
||||||
hashCode = hashCode * 59 + DemandesFormation.GetHashCode(); |
|
||||||
return hashCode; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
#region Operators |
|
||||||
#pragma warning disable 1591 |
|
||||||
|
|
||||||
public static bool operator ==(ThemeDTO left, ThemeDTO right) |
|
||||||
{ |
|
||||||
return Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
public static bool operator !=(ThemeDTO left, ThemeDTO right) |
|
||||||
{ |
|
||||||
return !Equals(left, right); |
|
||||||
} |
|
||||||
|
|
||||||
#pragma warning restore 1591 |
|
||||||
#endregion Operators |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,637 @@ |
|||||||
|
using EPAServeur.Context; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using EPAServeur.Models.Formation; |
||||||
|
using EPAServeur.Services; |
||||||
|
using IO.Swagger.Controllers; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using Microsoft.Extensions.DependencyInjection; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Moq; |
||||||
|
using IO.Swagger.ApiCollaborateur; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
|
||||||
|
namespace EPAServeur.Tests.Controllers |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class DemandeFormationApiTests |
||||||
|
{ |
||||||
|
#region Variables |
||||||
|
|
||||||
|
private IDemandeFormationService demandeFormationService; |
||||||
|
private Mock<IWebHostEnvironment> mockEnvironment; |
||||||
|
private EpContext epContext; |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Setup |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
// Création d'une collection de services pour l'injection de dépendance |
||||||
|
var services = new ServiceCollection(); |
||||||
|
|
||||||
|
// Utilisation d'une base de données en mémoire |
||||||
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
||||||
|
.UseInMemoryDatabase("server_ep_test") |
||||||
|
.Options; |
||||||
|
|
||||||
|
services.AddDbContext<EpContext>(b => b.UseInMemoryDatabase("server_ep_test")); |
||||||
|
|
||||||
|
epContext = new EpContext(optionBuider); |
||||||
|
|
||||||
|
epContext.Database.EnsureDeleted(); |
||||||
|
epContext.Database.EnsureCreated(); |
||||||
|
epContext.SaveChanges(); |
||||||
|
|
||||||
|
// Ajout du jeu de données pour les tests |
||||||
|
DataSeeder.AddFormations(epContext); |
||||||
|
|
||||||
|
// Détache les entités du context car la base de données InMemory créé des conflits |
||||||
|
// entre les clés primaires lors d'un Update ou d'un Insert |
||||||
|
foreach (var entity in epContext.ChangeTracker.Entries()) |
||||||
|
{ |
||||||
|
entity.State = EntityState.Detached; |
||||||
|
} |
||||||
|
|
||||||
|
services.AddScoped<ITransformDTO, TransformDTO>(); |
||||||
|
services.AddScoped<ICollaborateurApi, CollaborateurApi>(); |
||||||
|
services.AddScoped<ICollaborateurService, CollaborateurService>(); |
||||||
|
services.AddScoped<IDemandeFormationService, DemandeFormationService>(); |
||||||
|
|
||||||
|
// Récupère le service qui sera utilsé pour tester le contrôleur |
||||||
|
var serviceProvider = services.BuildServiceProvider(); |
||||||
|
demandeFormationService = serviceProvider.GetService<IDemandeFormationService>(); |
||||||
|
|
||||||
|
// Simule l'interface IWebHostEnvironment avec Moq |
||||||
|
mockEnvironment = new Mock<IWebHostEnvironment>(); |
||||||
|
|
||||||
|
mockEnvironment |
||||||
|
.Setup(m => m.EnvironmentName) |
||||||
|
.Returns("Development"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetDemandesFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetDemandesFormation_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = DemandesFormationApiController.GetDemandesFormation(null, null, null, null, null, null, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetDemandesFormation_PasseDesParamsPresentsDansLaBDD_RetourneLesCinqPremieresDemandesDeFormations() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
int nbDemandeFormation = 5; |
||||||
|
int idFirstDemandeFormation = 1; |
||||||
|
int idLastDemandeFormation = 3; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = DemandesFormationApiController.GetDemandesFormation(null, null, null, null, 1, 5, null, null, null, null).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<DemandeFormationDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbDemandeFormation, (okResult.Value as IEnumerable<DemandeFormationDTO>).Count()); |
||||||
|
Assert.AreEqual(idFirstDemandeFormation, (okResult.Value as IEnumerable<DemandeFormationDTO>).First().Id); |
||||||
|
Assert.AreEqual(idLastDemandeFormation, (okResult.Value as IEnumerable<DemandeFormationDTO>).Last().Id); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetDemandesFormationCount |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetDemandesFormationCount_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = DemandesFormationApiController.GetDemandesFormationCount(null, null, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetDemandesFormationCount_PasseDesParamsPresentsDansLaBDD_RetourneLeBonNombreDeDemandeDeFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
int nbDemandeFormation = 12; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = DemandesFormationApiController.GetDemandesFormationCount(null, null, null, null, null, null).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<long>(okResult.Value); |
||||||
|
Assert.AreEqual(nbDemandeFormation, (long)okResult.Value); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetOriginesDemandeFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetOriginesDemandeFormation_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = DemandesFormationApiController.GetOriginesDemandeFormation(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetOriginesDemandeFormation_RetourneToutesLesOriginesDeDemande() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
int nbOrigineDemande = 5; |
||||||
|
// Act |
||||||
|
var okResult = DemandesFormationApiController.GetOriginesDemandeFormation().Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<OrigineDemandeFormationDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbOrigineDemande, (okResult.Value as IEnumerable<OrigineDemandeFormationDTO>).Count()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests AddDemandeFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AddDemandeFormation_AjouteUneDemandeDeFormationAvecUnCollaborateurNull_RetourneUnObjetObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationApside = new OrigineDemandeFormationDTO { Id = 5, Libelle = "Demande Apside" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = null; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Libelle = "Formation React", |
||||||
|
Description = "Demande de formation React avec Redux", |
||||||
|
DemandeRH = true, |
||||||
|
DateDemande = DateTime.Now, |
||||||
|
EtatDemande = EtatDemande.EnAttente, |
||||||
|
Origine = origineDemandeFormationApside, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = DemandesFormationApiController.AddDemandeFormation(demandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AddDemandeFormation_AjouteUneDemandeDeFormationValide_RetourneUnObjetCreatedResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationApside = new OrigineDemandeFormationDTO { Id = 5, Libelle = "Demande Apside" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = new CollaborateurDTO |
||||||
|
{ |
||||||
|
Id = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"), |
||||||
|
BusinessUnit = new BusinessUnitDTO { Id = 2, Nom = "Orléans", Agence = new AgenceDTO { Id = 1, Nom = "TOP", Bu = Bus } }, |
||||||
|
Nom = "Lemoine", |
||||||
|
Prenom = "Coty", |
||||||
|
MailApside = "coty.lemoine@apside-groupe.com", |
||||||
|
DateArrivee = new DateTime(2017, 2, 10, 20, 37, 58, 741), |
||||||
|
DateDepart = null, |
||||||
|
}; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Libelle = "Formation React", |
||||||
|
Description = "Demande de formation React avec Redux", |
||||||
|
DemandeRH = true, |
||||||
|
DateDemande = DateTime.Now, |
||||||
|
EtatDemande = EtatDemande.EnAttente, |
||||||
|
Origine = origineDemandeFormationApside, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var createdResult = DemandesFormationApiController.AddDemandeFormation(demandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<CreatedResult>(createdResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AddDemandeFormation_AjouteUneDemandeDeFormationValide_RetourneLaDemandeDeFormationCreee() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationApside = new OrigineDemandeFormationDTO { Id = 5, Libelle = "Demande Apside" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = new CollaborateurDTO |
||||||
|
{ |
||||||
|
Id = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"), |
||||||
|
BusinessUnit = new BusinessUnitDTO { Id = 2, Nom = "Orléans", Agence = new AgenceDTO { Id = 1, Nom = "TOP", Bu = Bus } }, |
||||||
|
Nom = "Lemoine", |
||||||
|
Prenom = "Coty", |
||||||
|
MailApside = "coty.lemoine@apside-groupe.com", |
||||||
|
DateArrivee = new DateTime(2017, 2, 10, 20, 37, 58, 741), |
||||||
|
DateDepart = null, |
||||||
|
}; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Libelle = "Formation React", |
||||||
|
Description = "Demande de formation React avec Redux", |
||||||
|
DemandeRH = true, |
||||||
|
DateDemande = DateTime.Now, |
||||||
|
EtatDemande = EtatDemande.EnAttente, |
||||||
|
Origine = origineDemandeFormationApside, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var createdResult = DemandesFormationApiController.AddDemandeFormation(demandeFormation).Result as CreatedResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<DemandeFormationDTO>(createdResult.Value); |
||||||
|
Assert.AreEqual("Formation React", (createdResult.Value as DemandeFormationDTO).Libelle); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests UpdateDemandeFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateDemandeFormation_AccepteUneDemandeAvecUneFormationNull_RetourneUnObjetObjectResultDansCatchDemandeFormationInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 3; |
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationClient = new OrigineDemandeFormationDTO { Id = 3, Libelle = "Exigence Client" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = new CollaborateurDTO |
||||||
|
{ |
||||||
|
Id = Guid.Parse("a0f40e2a-cc03-4032-a627-5389e1281c64"), |
||||||
|
BusinessUnit = new BusinessUnitDTO { Id = 2, Nom = "Orléans", Agence = new AgenceDTO { Id = 1, Nom = "TOP", Bu = Bus } }, |
||||||
|
Nom = "Vasseur", |
||||||
|
Prenom = "Florencio", |
||||||
|
MailApside = "florencio.vasseur@apside-groupe.com", |
||||||
|
DateArrivee = new DateTime(2016, 1, 15, 10, 22, 30, 778), |
||||||
|
DateDepart = null, |
||||||
|
}; |
||||||
|
|
||||||
|
FormationDetailsDTO formation = null; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Id = idDemandeFormation, |
||||||
|
Libelle = "Formation C#", |
||||||
|
Description = "Demande de formation C# avec WPF", |
||||||
|
DemandeRH = false, |
||||||
|
DateDemande = new DateTime(2020, 3, 22, 9, 0, 0), |
||||||
|
EtatDemande = EtatDemande.Validee, |
||||||
|
Origine = origineDemandeFormationClient, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
Formation = formation, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = DemandesFormationApiController.UpdateDemandeFormation(demandeFormation, idDemandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateDemandeFormation_AccepteUneDemandeAvecUnIdDemandeFormationNull_RetourneUnObjetObjectResultDansCatchDemandeFormationIncompatibleIdException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 1; |
||||||
|
long? idDemandeFormationIncorrecte = null; |
||||||
|
int nbParticipant = 1; |
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationClient = new OrigineDemandeFormationDTO { Id = 3, Libelle = "Exigence Client" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = new CollaborateurDTO |
||||||
|
{ |
||||||
|
Id = Guid.Parse("a0f40e2a-cc03-4032-a627-5389e1281c64"), |
||||||
|
BusinessUnit = new BusinessUnitDTO { Id = 2, Nom = "Orléans", Agence = new AgenceDTO { Id = 1, Nom = "TOP", Bu = Bus } }, |
||||||
|
Nom = "Vasseur", |
||||||
|
Prenom = "Florencio", |
||||||
|
MailApside = "florencio.vasseur@apside-groupe.com", |
||||||
|
DateArrivee = new DateTime(2016, 1, 15, 10, 22, 30, 778), |
||||||
|
DateDepart = null, |
||||||
|
}; |
||||||
|
|
||||||
|
FormationDetailsDTO formation = new FormationDetailsDTO |
||||||
|
{ |
||||||
|
Id = 3, |
||||||
|
Intitule = "Apprendre C# et le développement de logiciels avec WPF", |
||||||
|
DateDebut = new DateTime(2020, 5, 25, 14, 0, 0), |
||||||
|
DateFin = new DateTime(2020, 5, 27), |
||||||
|
Organisme = "Organisme2", |
||||||
|
Origine = new OrigineFormationDTO { Id = 3, Libelle = "Exigence Apside" }, |
||||||
|
Statut = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }, |
||||||
|
EstCertifiee = true, |
||||||
|
NbParticipations = nbParticipant |
||||||
|
}; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Id = idDemandeFormationIncorrecte, |
||||||
|
Libelle = "Formation C#", |
||||||
|
Description = "Demande de formation C# avec WPF", |
||||||
|
DemandeRH = false, |
||||||
|
DateDemande = new DateTime(2020, 3, 22, 9, 0, 0), |
||||||
|
EtatDemande = EtatDemande.Validee, |
||||||
|
Origine = origineDemandeFormationClient, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
Formation = formation, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = DemandesFormationApiController.UpdateDemandeFormation(demandeFormation, idDemandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateDemandeFormation_AccepteUneDemandeInexistante_RetourneUnObjetObjectResultDansCatchDemandeFormationNotFoundExceptionn() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 0; |
||||||
|
int nbParticipant = 1; |
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationClient = new OrigineDemandeFormationDTO { Id = 3, Libelle = "Exigence Client" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = new CollaborateurDTO |
||||||
|
{ |
||||||
|
Id = Guid.Parse("a0f40e2a-cc03-4032-a627-5389e1281c64"), |
||||||
|
BusinessUnit = new BusinessUnitDTO { Id = 2, Nom = "Orléans", Agence = new AgenceDTO { Id = 1, Nom = "TOP", Bu = Bus } }, |
||||||
|
Nom = "Vasseur", |
||||||
|
Prenom = "Florencio", |
||||||
|
MailApside = "florencio.vasseur@apside-groupe.com", |
||||||
|
DateArrivee = new DateTime(2016, 1, 15, 10, 22, 30, 778), |
||||||
|
DateDepart = null, |
||||||
|
}; |
||||||
|
|
||||||
|
FormationDetailsDTO formation = new FormationDetailsDTO |
||||||
|
{ |
||||||
|
Id = 3, |
||||||
|
Intitule = "Apprendre C# et le développement de logiciels avec WPF", |
||||||
|
DateDebut = new DateTime(2020, 5, 25, 14, 0, 0), |
||||||
|
DateFin = new DateTime(2020, 5, 27), |
||||||
|
Organisme = "Organisme2", |
||||||
|
Origine = new OrigineFormationDTO { Id = 3, Libelle = "Exigence Apside" }, |
||||||
|
Statut = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }, |
||||||
|
EstCertifiee = true, |
||||||
|
NbParticipations = nbParticipant |
||||||
|
}; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Id = idDemandeFormation, |
||||||
|
Libelle = "Formation C#", |
||||||
|
Description = "Demande de formation C# avec WPF", |
||||||
|
DemandeRH = false, |
||||||
|
DateDemande = new DateTime(2020, 3, 22, 9, 0, 0), |
||||||
|
EtatDemande = EtatDemande.Validee, |
||||||
|
Origine = origineDemandeFormationClient, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
Formation = formation, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = DemandesFormationApiController.UpdateDemandeFormation(demandeFormation, idDemandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateDemandeFormation_AccepteUneDemandeDeDemandeFormation_RetourneUnObjetOkObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 1; |
||||||
|
int nbParticipant = 0; |
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationApside = new OrigineDemandeFormationDTO { Id = 5, Libelle = "Demande Apside" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = new CollaborateurDTO |
||||||
|
{ |
||||||
|
Id = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"), |
||||||
|
BusinessUnit = new BusinessUnitDTO { Id = 2, Nom = "Orléans", Agence = new AgenceDTO { Id = 1, Nom = "TOP", Bu = Bus } }, |
||||||
|
Nom = "Lemoine", |
||||||
|
Prenom = "Coty", |
||||||
|
MailApside = "coty.lemoine@apside-groupe.com", |
||||||
|
DateArrivee = new DateTime(2017, 2, 10, 20, 37, 58, 741), |
||||||
|
DateDepart = null, |
||||||
|
}; |
||||||
|
|
||||||
|
FormationDetailsDTO formation = new FormationDetailsDTO |
||||||
|
{ |
||||||
|
Id = 1, |
||||||
|
Intitule = "Formation Mainframe Complète", |
||||||
|
DateDebut = new DateTime(2020, 1, 25, 10, 0, 0), |
||||||
|
DateFin = new DateTime(2020, 1, 27), |
||||||
|
Organisme = "Organisme1", |
||||||
|
Origine = new OrigineFormationDTO { Id = 2, Libelle = "Exigence client" }, |
||||||
|
Statut = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }, |
||||||
|
EstCertifiee = false, |
||||||
|
NbParticipations = nbParticipant |
||||||
|
}; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Id = idDemandeFormation, |
||||||
|
Libelle = "Formation Cobol", |
||||||
|
Description = "Demande de formation Cobol avec Mainframe", |
||||||
|
DemandeRH = false, |
||||||
|
DateDemande = new DateTime(2020, 1, 22, 9, 0, 0), |
||||||
|
EtatDemande = EtatDemande.Validee, |
||||||
|
Origine = origineDemandeFormationApside, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
Formation = formation, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = DemandesFormationApiController.UpdateDemandeFormation(demandeFormation, idDemandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okObjectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateDemandeFormation_AccepteUneDemandeDeDemandeFormation_RetourneLaDemandeDeFormationAcceptee() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 1; |
||||||
|
int nbParticipant = 0; |
||||||
|
OrigineDemandeFormationDTO origineDemandeFormationApside = new OrigineDemandeFormationDTO { Id = 5, Libelle = "Demande Apside" }; |
||||||
|
|
||||||
|
List<BusinessUnitDTO> Bus = new List<BusinessUnitDTO>() { |
||||||
|
new BusinessUnitDTO { Id = 1, Nom = "Tours" }, |
||||||
|
new BusinessUnitDTO { Id = 2, Nom = "Orléans" }, |
||||||
|
}; |
||||||
|
|
||||||
|
CollaborateurDTO collaborateur = new CollaborateurDTO |
||||||
|
{ |
||||||
|
Id = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"), |
||||||
|
BusinessUnit = new BusinessUnitDTO { Id = 2, Nom = "Orléans", Agence = new AgenceDTO { Id = 1, Nom = "TOP", Bu = Bus } }, |
||||||
|
Nom = "Lemoine", |
||||||
|
Prenom = "Coty", |
||||||
|
MailApside = "coty.lemoine@apside-groupe.com", |
||||||
|
DateArrivee = new DateTime(2017, 2, 10, 20, 37, 58, 741), |
||||||
|
DateDepart = null, |
||||||
|
}; |
||||||
|
|
||||||
|
FormationDetailsDTO formation = new FormationDetailsDTO |
||||||
|
{ |
||||||
|
Id = 1, |
||||||
|
Intitule = "Formation Mainframe Complète", |
||||||
|
DateDebut = new DateTime(2020, 1, 25, 10, 0, 0), |
||||||
|
DateFin = new DateTime(2020, 1, 27), |
||||||
|
Organisme = "Organisme1", |
||||||
|
Origine = new OrigineFormationDTO { Id = 2, Libelle = "Exigence client" }, |
||||||
|
Statut = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }, |
||||||
|
EstCertifiee = false, |
||||||
|
NbParticipations = nbParticipant |
||||||
|
}; |
||||||
|
|
||||||
|
DemandeFormationDTO demandeFormation = new DemandeFormationDTO |
||||||
|
{ |
||||||
|
Id = idDemandeFormation, |
||||||
|
Libelle = "Formation Cobol", |
||||||
|
Description = "Demande de formation Cobol avec Mainframe", |
||||||
|
DemandeRH = false, |
||||||
|
DateDemande = new DateTime(2020, 1, 22, 9, 0, 0), |
||||||
|
EtatDemande = EtatDemande.Validee, |
||||||
|
Origine = origineDemandeFormationApside, |
||||||
|
Collaborateur = collaborateur, |
||||||
|
Formation = formation, |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = DemandesFormationApiController.UpdateDemandeFormation(demandeFormation, idDemandeFormation).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<DemandeFormationDTO>(okObjectResult.Value); |
||||||
|
Assert.AreEqual("Formation Cobol", (okObjectResult.Value as DemandeFormationDTO).Libelle); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests DeleteDemandeFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DeleteDemandeFormation_SupprimeUneDemandeDeFormationInexistante_RetourneUnObjetNotFoundObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 0; |
||||||
|
|
||||||
|
// Act |
||||||
|
var notFoundObjectResult = DemandesFormationApiController.DeleteDemandeFormation(idDemandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<NotFoundObjectResult>(notFoundObjectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DeleteDemandeFormation_SupprimeUneDemandeDeFormationConcernantUnEpSigne_RetourneUnObjetObjectResultDansCatchDemandeFormationInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 2; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = DemandesFormationApiController.DeleteDemandeFormation(idDemandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DeleteDemandeFormation_SupprimeUneDemandeDeFormation_RetourneUnObjetNoContentResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
DemandesFormationApiController DemandesFormationApiController = new DemandesFormationApiController(demandeFormationService, new NullLogger<DemandesFormationApiController>(), mockEnvironment.Object); |
||||||
|
long idDemandeFormation = 5; |
||||||
|
|
||||||
|
// Act |
||||||
|
var noContentResult = DemandesFormationApiController.DeleteDemandeFormation(idDemandeFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<NoContentResult>(noContentResult.Result); |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,341 @@ |
|||||||
|
using EPAServeur.Context; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using EPAServeur.Models.Formation; |
||||||
|
using EPAServeur.Services; |
||||||
|
using IO.Swagger.Controllers; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using Microsoft.Extensions.DependencyInjection; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Moq; |
||||||
|
using IO.Swagger.ApiCollaborateur; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
|
||||||
|
namespace EPAServeur.Tests.Controllers |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class EngagementsApiTests |
||||||
|
{ |
||||||
|
#region Variables |
||||||
|
|
||||||
|
private IEngagementService engagementService; |
||||||
|
private Mock<IWebHostEnvironment> mockEnvironment; |
||||||
|
private EpContext epContext; |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Setup |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
// Création d'une collection de services pour l'injection de dépendance |
||||||
|
var services = new ServiceCollection(); |
||||||
|
|
||||||
|
// Utilisation d'une base de données en mémoire |
||||||
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
||||||
|
.UseInMemoryDatabase("server_ep_test") |
||||||
|
.Options; |
||||||
|
|
||||||
|
services.AddDbContext<EpContext>(b => b.UseInMemoryDatabase("server_ep_test")); |
||||||
|
|
||||||
|
epContext = new EpContext(optionBuider); |
||||||
|
|
||||||
|
epContext.Database.EnsureDeleted(); |
||||||
|
epContext.Database.EnsureCreated(); |
||||||
|
epContext.SaveChanges(); |
||||||
|
|
||||||
|
// Ajout du jeu de données pour les tests |
||||||
|
DataSeeder.AddEngagements(epContext); |
||||||
|
|
||||||
|
// Détache les entités du context car la base de données InMemory créé des conflits |
||||||
|
// entre les clés primaires lors d'un Update ou d'un Insert |
||||||
|
foreach (var entity in epContext.ChangeTracker.Entries()) |
||||||
|
{ |
||||||
|
entity.State = EntityState.Detached; |
||||||
|
} |
||||||
|
|
||||||
|
services.AddScoped<ITransformDTO, TransformDTO>(); |
||||||
|
services.AddScoped<ICollaborateurApi, CollaborateurApi>(); |
||||||
|
services.AddScoped<ICollaborateurService, CollaborateurService>(); |
||||||
|
services.AddScoped<IEngagementService, EngagementService>(); |
||||||
|
|
||||||
|
// Récupère le service qui sera utilsé pour tester le contrôleur |
||||||
|
var serviceProvider = services.BuildServiceProvider(); |
||||||
|
engagementService = serviceProvider.GetService<IEngagementService>(); |
||||||
|
|
||||||
|
// Simule l'interface IWebHostEnvironment avec Moq |
||||||
|
mockEnvironment = new Mock<IWebHostEnvironment>(); |
||||||
|
|
||||||
|
mockEnvironment |
||||||
|
.Setup(m => m.EnvironmentName) |
||||||
|
.Returns("Development"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
|
||||||
|
#region Tests GetEngagements |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEngagements_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
List<long> idBUs = new List<long> { 1, 2 }; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = engagementsApiController.GetEngagements(idBUs, null, true, 1, 5, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEngagements_PasseDesParamsPresentsDansLaBDD_RetourneLesCinqPremiersEngagements() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
List<long> idBUs = new List<long> { 1, 2 }; |
||||||
|
int nbEngagement = 5; |
||||||
|
int idFirstEngagement = 8; |
||||||
|
int idLastEngagement = 4; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = engagementsApiController.GetEngagements(idBUs, null, true, 1, 5, null, null).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<EngagementDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbEngagement, (okResult.Value as IEnumerable<EngagementDTO>).Count()); |
||||||
|
Assert.AreEqual(idFirstEngagement, (okResult.Value as IEnumerable<EngagementDTO>).First().Id); |
||||||
|
Assert.AreEqual(idLastEngagement, (okResult.Value as IEnumerable<EngagementDTO>).Last().Id); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetEngagementsCount |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEngagementsCount_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
List<long> idBUs = new List<long> { 1, 2 }; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = engagementsApiController.GetEngagementsCount(idBUs, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEngagementsCount_PasseDesParamsPresentsDansLaBDD_RetourneLeBonNombreDEngagement() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
List<long> idBUs = new List<long> { 1, 2 }; |
||||||
|
int nbEngagement = 12; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = engagementsApiController.GetEngagementsCount(idBUs, null, null).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<long>(okResult.Value); |
||||||
|
Assert.AreEqual(nbEngagement, (long)okResult.Value); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests UpdateEngagement |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void UpdateEngagement_ModifieUnEngagementAvecUnEPInvalide_RetourneUnObjetObjectResultDansCatchEngagementInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idEngagement = 1; |
||||||
|
EtatEngagement reponse = EtatEngagement.Respecte; |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
EpInformationDTO epInformationDTO = null; |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = reponse, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = engagementsApiController.UpdateEngagement(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void UpdateEngagement_ModifieUnEngagementAvecUnIdEngagementInvalide_RetourneUnObjetObjectResultDansCatchEngagementIncompatibleIdException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idEngagement = 1; |
||||||
|
long idEngagementIncorrecte = 2; |
||||||
|
long idEp = 9; |
||||||
|
EtatEngagement reponse = EtatEngagement.Respecte; |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagementIncorrecte, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = reponse, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = engagementsApiController.UpdateEngagement(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void UpdateEngagement_ModifieUnEngagementInexistant_RetourneUnObjetObjectResultDansCatchEngagementNotFoundExceptionn() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idEngagementInexistant = 999; |
||||||
|
long idEp = 9; |
||||||
|
EtatEngagement reponse = EtatEngagement.Respecte; |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagementInexistant, |
||||||
|
Action = "Toto.", |
||||||
|
Dispositif = "Tata.", |
||||||
|
Modalite = "Titi", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = reponse, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = engagementsApiController.UpdateEngagement(engagementDTO, idEngagementInexistant); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void UpdateEngagement_ModifieUnEngagementValide_RetourneUnObjetOkObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idEngagement = 1; |
||||||
|
long idEp = 9; |
||||||
|
EtatEngagement reponse = EtatEngagement.Respecte; |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = reponse, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = engagementsApiController.UpdateEngagement(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okObjectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void UpdateEngagement_ModifieUnEngagementValide_RetourneLEngagementModifie() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idEngagement = 1; |
||||||
|
long idEp = 9; |
||||||
|
EtatEngagement reponse = EtatEngagement.Respecte; |
||||||
|
EngagementsApiController engagementsApiController = new EngagementsApiController(engagementService, new NullLogger<EngagementsApiController>(), mockEnvironment.Object); |
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = reponse, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = engagementsApiController.UpdateEngagement(engagementDTO, idEngagement).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<EngagementDTO>(okObjectResult.Value); |
||||||
|
Assert.AreEqual(reponse, (okObjectResult.Value as EngagementDTO).EtatEngagement); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,607 @@ |
|||||||
|
using EPAServeur.Context; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using EPAServeur.Models.Formation; |
||||||
|
using EPAServeur.Services; |
||||||
|
using IO.Swagger.Controllers; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using Microsoft.Extensions.DependencyInjection; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Moq; |
||||||
|
using IO.Swagger.ApiCollaborateur; |
||||||
|
|
||||||
|
namespace EPAServeur.Tests.Controllers |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class FormationApiTests |
||||||
|
{ |
||||||
|
#region Variables |
||||||
|
|
||||||
|
private IFormationService formationService; |
||||||
|
private Mock<IWebHostEnvironment> mockEnvironment; |
||||||
|
private EpContext epContext; |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Setup |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
// Création d'une collection de services pour l'injection de dépendance |
||||||
|
var services = new ServiceCollection(); |
||||||
|
|
||||||
|
// Utilisation d'une base de données en mémoire |
||||||
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
||||||
|
.UseInMemoryDatabase("server_ep_test") |
||||||
|
.Options; |
||||||
|
|
||||||
|
services.AddDbContext<EpContext>(b => b.UseInMemoryDatabase("server_ep_test")); |
||||||
|
|
||||||
|
epContext = new EpContext(optionBuider); |
||||||
|
|
||||||
|
epContext.Database.EnsureDeleted(); |
||||||
|
epContext.Database.EnsureCreated(); |
||||||
|
epContext.SaveChanges(); |
||||||
|
|
||||||
|
// Ajout du jeu de données pour les tests |
||||||
|
DataSeeder.AddFormations(epContext); |
||||||
|
|
||||||
|
// Détache les entités du context car la base de données InMemory créé des conflits |
||||||
|
// entre les clés primaires lors d'un Update ou d'un Insert |
||||||
|
foreach (var entity in epContext.ChangeTracker.Entries()) |
||||||
|
{ |
||||||
|
entity.State = EntityState.Detached; |
||||||
|
} |
||||||
|
|
||||||
|
services.AddScoped<ITransformDTO, TransformDTO>(); |
||||||
|
services.AddScoped<ICollaborateurApi, CollaborateurApi>(); |
||||||
|
services.AddScoped<ICollaborateurService, CollaborateurService>(); |
||||||
|
services.AddScoped<IFormationService, FormationService>(); |
||||||
|
|
||||||
|
// Récupère le service qui sera utilsé pour tester le contrôleur |
||||||
|
var serviceProvider = services.BuildServiceProvider(); |
||||||
|
formationService = serviceProvider.GetService<IFormationService>(); |
||||||
|
|
||||||
|
// Simule l'interface IWebHostEnvironment avec Moq |
||||||
|
mockEnvironment = new Mock<IWebHostEnvironment>(); |
||||||
|
|
||||||
|
mockEnvironment |
||||||
|
.Setup(m => m.EnvironmentName) |
||||||
|
.Returns("Development"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetFormationById |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetById_PasseEnParamUnIdInconnu_RetourneUnObjetNotFoundResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var notFoundResult = formationsApiController.GetFormationById(99999); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<NotFoundObjectResult>(notFoundResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetFormationById_PasseEnParamUnIdConnu_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetFormationById(1); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetFormationById_PasseEnParamUnIdConnu_RetourneLaBonneFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
long idFormation = 1; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetFormationById(idFormation).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<FormationDTO>(okResult.Value); |
||||||
|
Assert.AreEqual(idFormation, (okResult.Value as FormationDTO).Id); |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetFormations |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetFormations_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
List<int?> idStatuts = new List<int?> { 1, 2, 3 }; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetFormations(1, idStatuts, true, 1, 5, "formation", null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetFormations_PasseDesParamsPresentsDansLaBDD_RetourneLesCinqPremieresFormations() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
List<int?> idStatuts = new List<int?> { 1, 2, 3 }; |
||||||
|
int nbFormation = 5; |
||||||
|
int idFirstFormation = 5; |
||||||
|
int idLastFormation = 1; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetFormations(1, idStatuts, true, 1, 5, "formation", null, null, null).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<FormationDetailsDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbFormation, (okResult.Value as IEnumerable<FormationDetailsDTO>).Count()); |
||||||
|
Assert.AreEqual(idFirstFormation, (okResult.Value as IEnumerable<FormationDetailsDTO>).First().Id); |
||||||
|
Assert.AreEqual(idLastFormation, (okResult.Value as IEnumerable<FormationDetailsDTO>).Last().Id); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetFormationsCount |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetFormationsCount_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
List<int?> idStatuts = new List<int?> { 1, 2, 3 }; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetFormationsCount(1, idStatuts, "formation", null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetFormationsCount_PasseDesParamsPresentsDansLaBDD_RetourneLeBonNombreDeFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
List<int?> idStatuts = new List<int?> { 1, 2, 3 }; |
||||||
|
int nbFormation = 8; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetFormationsCount(1, idStatuts, "formation", null, null).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<long>(okResult.Value); |
||||||
|
Assert.AreEqual(nbFormation, (long)okResult.Value); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetModesFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetModesFormation_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetModesFormation(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetModesFormation_RetourneTousLesModes() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
int nbModeFormation = 4; |
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetModesFormation().Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<ModeFormationDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbModeFormation, (okResult.Value as IEnumerable<ModeFormationDTO>).Count()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetOriginesFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetOriginesFormation_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetOriginesFormation(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetOriginesFormation_RetourneToutesLesOrigines() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
int nbOrigineFormation = 4; |
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetOriginesFormation().Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<OrigineFormationDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbOrigineFormation, (okResult.Value as IEnumerable<OrigineFormationDTO>).Count()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetStatutsFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetStatusFormation_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetStatutsFormation(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetStatutsFormation_RetourneTousLesStatuts() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
int nbStatutFormation = 4; |
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetStatutsFormation().Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<StatutFormationDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbStatutFormation, (okResult.Value as IEnumerable<StatutFormationDTO>).Count()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetTypesFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetTypesFormation_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetTypesFormation(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetTypesFormation_RetourneTousLesTypes() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
int nbTypeFormation = 4; |
||||||
|
// Act |
||||||
|
var okResult = formationsApiController.GetTypesFormation().Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<TypeFormationDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbTypeFormation, (okResult.Value as IEnumerable<TypeFormationDTO>).Count()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests AddFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AddFormation_AjouteUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
ModeFormationDTO modeExterne = new ModeFormationDTO { Id = 0, Libelle = "Externe" }; |
||||||
|
StatutFormationDTO statutPlanifie = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }; |
||||||
|
TypeFormationDTO typeELearning = new TypeFormationDTO { Id = 3, Libelle = "E-learning" }; |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = new OrigineFormationDTO { Id = 1, Libelle = "Demande collaborateur" }; |
||||||
|
|
||||||
|
FormationDTO formation = new FormationDTO |
||||||
|
{ |
||||||
|
Intitule = "Test Formation", |
||||||
|
IdAgence = 1, |
||||||
|
DateDebut = new DateTime(2020, 10, 31), |
||||||
|
DateFin = new DateTime(2020, 11, 02), |
||||||
|
Heure = 2, |
||||||
|
Jour = 1, |
||||||
|
Mode = modeExterne, |
||||||
|
Type = typeELearning, |
||||||
|
Organisme = "Apside", |
||||||
|
Origine = origineFormationCollaborateur, |
||||||
|
Statut = statutPlanifie, |
||||||
|
EstCertifiee = false |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = formationsApiController.AddFormation(formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AddFormation_AjouteUneFormationValide_RetourneUnObjetCreatedResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
ModeFormationDTO modeExterne = new ModeFormationDTO { Id = 1, Libelle = "Externe" }; |
||||||
|
StatutFormationDTO statutPlanifie = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }; |
||||||
|
TypeFormationDTO typeELearning = new TypeFormationDTO { Id = 3, Libelle = "E-learning" }; |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = new OrigineFormationDTO { Id = 1, Libelle = "Demande collaborateur" }; |
||||||
|
|
||||||
|
FormationDTO formation = new FormationDTO |
||||||
|
{ |
||||||
|
Intitule = "Test Formation", |
||||||
|
IdAgence = 1, |
||||||
|
DateDebut = new DateTime(2020, 10, 31), |
||||||
|
DateFin = new DateTime(2020, 11, 02), |
||||||
|
Heure = 2, |
||||||
|
Jour = 1, |
||||||
|
Mode = modeExterne, |
||||||
|
Type = typeELearning, |
||||||
|
Organisme = "Apside", |
||||||
|
Origine = origineFormationCollaborateur, |
||||||
|
Statut = statutPlanifie, |
||||||
|
EstCertifiee = false |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var createdResult = formationsApiController.AddFormation(formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<CreatedResult>(createdResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AddFormation_AjouteUneFormationValide_RetourneLaFormationCreee() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
|
||||||
|
ModeFormationDTO modeExterne = new ModeFormationDTO { Id = 1, Libelle = "Externe" }; |
||||||
|
StatutFormationDTO statutPlanifie = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }; |
||||||
|
TypeFormationDTO typeELearning = new TypeFormationDTO { Id = 3, Libelle = "E-learning" }; |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = new OrigineFormationDTO { Id = 1, Libelle = "Demande collaborateur" }; |
||||||
|
|
||||||
|
FormationDTO formation = new FormationDTO |
||||||
|
{ |
||||||
|
Intitule = "Test Formation", |
||||||
|
IdAgence = 1, |
||||||
|
DateDebut = new DateTime(2020, 10, 31), |
||||||
|
DateFin = new DateTime(2020, 11, 02), |
||||||
|
Heure = 2, |
||||||
|
Jour = 1, |
||||||
|
Mode = modeExterne, |
||||||
|
Type = typeELearning, |
||||||
|
Organisme = "Apside", |
||||||
|
Origine = origineFormationCollaborateur, |
||||||
|
Statut = statutPlanifie, |
||||||
|
EstCertifiee = false |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
var createdResult = formationsApiController.AddFormation(formation).Result as CreatedResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<FormationDTO>(createdResult.Value); |
||||||
|
Assert.AreEqual("Test Formation", (createdResult.Value as FormationDTO).Intitule); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests UpdateFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateFormation_ModifieUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchFormationInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idFormation = 1; |
||||||
|
string nouvelleIntitule = "Formation modifiée"; |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
formation.Intitule = nouvelleIntitule; |
||||||
|
formation.Mode.Id = 0; |
||||||
|
formation.Statut.Id = 0; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = formationsApiController.UpdateFormation(formation, idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateFormation_ModifieUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchFormationIncompatibleIdException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idFormation = 1; |
||||||
|
string nouvelleIntitule = "Formation modifiée"; |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
idFormation = 2; |
||||||
|
formation.Intitule = nouvelleIntitule; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = formationsApiController.UpdateFormation(formation, idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateFormation_ModifieUneFormatioInexistante_RetourneUnObjetObjectResultDansCatchFormationNotFoundExceptionn() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idFormationExistant = 1; |
||||||
|
long idFormationInexistant = 999; |
||||||
|
string nouvelleIntitule = "Formation modifiée"; |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormationExistant); |
||||||
|
|
||||||
|
formation.Id = idFormationInexistant; |
||||||
|
formation.Intitule = nouvelleIntitule; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = formationsApiController.UpdateFormation(formation, idFormationInexistant); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateFormation_ModifieUneFormationValide_RetourneUnObjetOkObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idFormation = 1; |
||||||
|
string nouvelleIntitule = "Formation modifiée"; |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == 2) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == 2) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == 1) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == 1) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
formation.Intitule = nouvelleIntitule; |
||||||
|
formation.Mode = modeExterne; |
||||||
|
formation.Type = typeELearning; |
||||||
|
formation.Origine = origineFormationCollaborateur; |
||||||
|
formation.Statut = statutPlanifie; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = formationsApiController.UpdateFormation(formation, idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okObjectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task UpdateFormation_ModifieUneFormationValide_RetourneLaFormationModifiee() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idFormation = 1; |
||||||
|
string nouvelleIntitule = "Formation modifiée"; |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == 2) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == 2) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == 1) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == 1) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
formation.Intitule = nouvelleIntitule; |
||||||
|
formation.Mode = modeExterne; |
||||||
|
formation.Type = typeELearning; |
||||||
|
formation.Origine = origineFormationCollaborateur; |
||||||
|
formation.Statut = statutPlanifie; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = formationsApiController.UpdateFormation(formation, idFormation).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<FormationDTO>(okObjectResult.Value); |
||||||
|
Assert.AreEqual(nouvelleIntitule, (okObjectResult.Value as FormationDTO).Intitule); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests DeleteFormationById |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DeleteFormation_PasseEnParamUnIdFormationInexistant_RetourneUnObjetNotFoundObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
int idFormation = 999; |
||||||
|
|
||||||
|
// Act |
||||||
|
var notFoundObjectResult = formationsApiController.DeleteFormation(idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<NotFoundObjectResult>(notFoundObjectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DeleteFormation_PasseEnParamUnIdFormationExistant_RetourneUnObjetNoContentResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
int idFormation = 1; |
||||||
|
|
||||||
|
// Act |
||||||
|
var noContentResult = formationsApiController.DeleteFormation(idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<NoContentResult>(noContentResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task DeleteFormation_PasseEnParamUnIdFormationExistant_SupprimeBienUneFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); |
||||||
|
int idFormation = 1; |
||||||
|
long nbFormationAvantSuppression = await formationService.GetFormationsCountAsync(null, null, null, null, null); |
||||||
|
|
||||||
|
// Act |
||||||
|
var noContentResult = formationsApiController.DeleteFormation(idFormation).Result as NoContentResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
long nbFormationApresSuppression = await formationService.GetFormationsCountAsync(null, null, null, null, null); |
||||||
|
|
||||||
|
Assert.AreEqual(nbFormationAvantSuppression -1, nbFormationApresSuppression); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,439 @@ |
|||||||
|
using EPAServeur.Context; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using EPAServeur.Models.Formation; |
||||||
|
using EPAServeur.Services; |
||||||
|
using IO.Swagger.Controllers; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using Microsoft.Extensions.DependencyInjection; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Moq; |
||||||
|
using IO.Swagger.ApiCollaborateur; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
|
||||||
|
namespace EPAServeur.Tests.Controllers |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ParticipationFormationApiTests |
||||||
|
{ |
||||||
|
#region Variables |
||||||
|
|
||||||
|
private IParticipationFormationService participationFormationService; |
||||||
|
private Mock<IWebHostEnvironment> mockEnvironment; |
||||||
|
private EpContext epContext; |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Setup |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
// Création d'une collection de services pour l'injection de dépendance |
||||||
|
var services = new ServiceCollection(); |
||||||
|
|
||||||
|
// Utilisation d'une base de données en mémoire |
||||||
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
||||||
|
.UseInMemoryDatabase("server_ep_test") |
||||||
|
.Options; |
||||||
|
|
||||||
|
services.AddDbContext<EpContext>(b => b.UseInMemoryDatabase("server_ep_test")); |
||||||
|
|
||||||
|
epContext = new EpContext(optionBuider); |
||||||
|
|
||||||
|
epContext.Database.EnsureDeleted(); |
||||||
|
epContext.Database.EnsureCreated(); |
||||||
|
epContext.SaveChanges(); |
||||||
|
|
||||||
|
// Ajout du jeu de données pour les tests |
||||||
|
DataSeeder.AddFormations(epContext); |
||||||
|
DataSeeder.AddChamps(epContext); |
||||||
|
|
||||||
|
// Détache les entités du context car la base de données InMemory créé des conflits |
||||||
|
// entre les clés primaires lors d'un Update ou d'un Insert |
||||||
|
foreach (var entity in epContext.ChangeTracker.Entries()) |
||||||
|
{ |
||||||
|
entity.State = EntityState.Detached; |
||||||
|
} |
||||||
|
|
||||||
|
services.AddScoped<ITransformDTO, TransformDTO>(); |
||||||
|
services.AddScoped<ICollaborateurApi, CollaborateurApi>(); |
||||||
|
services.AddScoped<ICollaborateurService, CollaborateurService>(); |
||||||
|
services.AddScoped<IParticipationFormationService, ParticipationFormationService>(); |
||||||
|
|
||||||
|
// Récupère le service qui sera utilsé pour tester le contrôleur |
||||||
|
var serviceProvider = services.BuildServiceProvider(); |
||||||
|
participationFormationService = serviceProvider.GetService<IParticipationFormationService>(); |
||||||
|
|
||||||
|
// Simule l'interface IWebHostEnvironment avec Moq |
||||||
|
mockEnvironment = new Mock<IWebHostEnvironment>(); |
||||||
|
|
||||||
|
mockEnvironment |
||||||
|
.Setup(m => m.EnvironmentName) |
||||||
|
.Returns("Development"); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetEvaluationCollaborateur |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEvaluationCollaborateur_PasseEnParamUnIdInconnu_RetourneUnObjetNotFoundResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
long idParticipationFormation = 99999; |
||||||
|
|
||||||
|
// Act |
||||||
|
var notFoundResult = ParticipationsFormationsApiController.GetEvaluationCollaborateur(idParticipationFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<NotFoundObjectResult>(notFoundResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEvaluationCollaborateur_PasseEnParamUnIdConnu_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = ParticipationsFormationsApiController.GetEvaluationCollaborateur(idParticipationFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEvaluationCollaborateur_PasseEnParamUnIdConnu_RetourneLaBonneEvaluation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = ParticipationsFormationsApiController.GetEvaluationCollaborateur(idParticipationFormation).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<EvaluationDTO>(okResult.Value); |
||||||
|
Assert.AreEqual(idParticipationFormation, (okResult.Value as EvaluationDTO).Id); |
||||||
|
} |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetParticipationsByCollaborateur |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetParticipationByCollaborateur_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
Guid idCollaborateur = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = ParticipationsFormationsApiController.GetParticipationsByCollaborateur(idCollaborateur); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetParticipationByCollaborateur_PasseDesParamsPresentsDansLaBDD_RetourneLesParticipationsDUnCollaborateur() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
Guid idCollaborateur = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"); |
||||||
|
int nbFormation = 1; |
||||||
|
int idFirstParticipationFormation = 5; |
||||||
|
|
||||||
|
// Act |
||||||
|
var okResult = ParticipationsFormationsApiController.GetParticipationsByCollaborateur(idCollaborateur).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<IEnumerable<ParticipationFormationDTO>>(okResult.Value); |
||||||
|
Assert.AreEqual(nbFormation, (okResult.Value as IEnumerable<ParticipationFormationDTO>).Count()); |
||||||
|
Assert.AreEqual(idFirstParticipationFormation, (okResult.Value as IEnumerable<ParticipationFormationDTO>).First().Id); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests EvaluerFormation |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormation_EvaluerUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idParticipationFormation = 5; |
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormation_EvaluerUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchParticipationFormationIncompatibleIdException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idParticipationFormation = 5; |
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
idParticipationFormation = 1; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormation_EvaluerUneFormationInexistante_RetourneUnObjetObjectResultDansCatchParticipationFormationNotFoundExceptionn() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idParticipationFormation = 5; |
||||||
|
long idParticipationFormationInexistant = 999; |
||||||
|
|
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
evaluationDTO.Id = idParticipationFormationInexistant; |
||||||
|
|
||||||
|
// Act |
||||||
|
var objectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormationInexistant); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<ObjectResult>(objectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormation_EvaluerUneFormationValide_RetourneUnObjetOkObjectResult() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<OkObjectResult>(okObjectResult.Result); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormation_EvaluerUneFormationValide_RetourneLEvaluationEvaluee() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
ParticipationsFormationsApiController ParticipationsFormationsApiController = new ParticipationsFormationsApiController(participationFormationService, new NullLogger<ParticipationsFormationsApiController>(), mockEnvironment.Object); |
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
|
||||||
|
// Act |
||||||
|
var okObjectResult = ParticipationsFormationsApiController.EvaluerFormation(evaluationDTO, idParticipationFormation).Result as OkObjectResult; |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsInstanceOf<EvaluationDTO>(okObjectResult.Value); |
||||||
|
Assert.AreEqual(idParticipationFormation, (okObjectResult.Value as EvaluationDTO).Id); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
{ |
||||||
|
"profiles": { |
||||||
|
"EPAServeur.Tests": { |
||||||
|
"commandName": "Project" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,639 @@ |
|||||||
|
using EPAServeur.Context; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using EPAServeur.Models.Formation; |
||||||
|
using EPAServeur.Services; |
||||||
|
using IO.Swagger.ApiCollaborateur; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace EPAServeur.Tests.Services |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class EngagementServiceTests |
||||||
|
{ |
||||||
|
#region Variables |
||||||
|
|
||||||
|
private EpContext epContext; |
||||||
|
private ICollaborateurApi collaborateurApi; |
||||||
|
private ICollaborateurService collaborateurService; |
||||||
|
private ITransformDTO transformDTO; |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Setup |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
// Utilisation d'une base de données en mémoire |
||||||
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
||||||
|
.UseInMemoryDatabase("server_ep_test") |
||||||
|
.Options; |
||||||
|
|
||||||
|
epContext = new EpContext(optionBuider); |
||||||
|
collaborateurApi = new CollaborateurApi(); |
||||||
|
transformDTO = new TransformDTO(); |
||||||
|
collaborateurService = new CollaborateurService(collaborateurApi, epContext, transformDTO); |
||||||
|
epContext.Database.EnsureDeleted(); |
||||||
|
epContext.Database.EnsureCreated(); |
||||||
|
epContext.SaveChanges(); |
||||||
|
|
||||||
|
// Ajout du jeu de données pour les tests |
||||||
|
DataSeeder.AddEngagements(epContext); |
||||||
|
|
||||||
|
// Détache les entités du context car la base de données InMemory créé des conflits |
||||||
|
// entre les clés primaires lors d'un Update ou d'un Insert |
||||||
|
foreach (var entity in epContext.ChangeTracker.Entries()) |
||||||
|
{ |
||||||
|
entity.State = EntityState.Detached; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetEngagementsAsync |
||||||
|
|
||||||
|
[TestCase(new long[] { 1, 2 })] |
||||||
|
public async Task GetEngagementsAsync_PasseDesParamsDesIdBUValides_RetourneDesEngagements(long[] arrIdBUs) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = arrIdBUs.Select(x => x).ToList(); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, null, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Less(0, engagementDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(new EtatEngagement[] { EtatEngagement.EnAttente, EtatEngagement.Respecte })] |
||||||
|
[TestCase(new EtatEngagement[] { EtatEngagement.DateLimitePassee })] |
||||||
|
public async Task GetEngagementsAsync_PasseDesParamsDesEtatsDEngagementsValides_RetourneDesEngagements(EtatEngagement[] arrEtatsEngagement) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
List<EtatEngagement> etatEngagements = arrEtatsEngagement.Select(x => x).ToList(); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, etatEngagements, null, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Less(0, engagementDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(1, 5)] |
||||||
|
[TestCase(1, 10)] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesEngagements(int? numPage, int? parPage) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, null, numPage, parPage, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(parPage, engagementDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(2, 5)] |
||||||
|
[TestCase(2, 6)] |
||||||
|
[TestCase(2, 10)] |
||||||
|
[TestCase(2, 15)] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamNumPageEtParPage_RetourneLaDeuxiemePageDesFormations(int? numPage, int? parPage) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
int? nbEngagementDeuxiemePage; |
||||||
|
|
||||||
|
switch (parPage) |
||||||
|
{ |
||||||
|
case 5: |
||||||
|
nbEngagementDeuxiemePage = 5; |
||||||
|
break; |
||||||
|
case 6: |
||||||
|
nbEngagementDeuxiemePage = 6; |
||||||
|
break; |
||||||
|
case 10: |
||||||
|
nbEngagementDeuxiemePage = 2; |
||||||
|
break; |
||||||
|
default: |
||||||
|
nbEngagementDeuxiemePage = 0; |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, null, numPage, parPage, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(nbEngagementDeuxiemePage, engagementDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(true, "action")] |
||||||
|
[TestCase(true, null)] |
||||||
|
[TestCase(true, "toto")] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParActionCroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Je m'engage à attribuer 5 jours de congés supplémentaire.", engagementDTOs.First().Action); |
||||||
|
Assert.AreEqual("Je m'engage à trouver une formation sur le Cobol.", engagementDTOs.Last().Action); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(false, "action")] |
||||||
|
[TestCase(false, null)] |
||||||
|
[TestCase(false, "toto")] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParActionDecroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Je m'engage à trouver une formation sur le Cobol.", engagementDTOs.First().Action); |
||||||
|
Assert.AreEqual("Je m'engage à attribuer 5 jours de congés supplémentaire.", engagementDTOs.Last().Action); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDispositifCroissant() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
bool? asc = true; |
||||||
|
string tri = "dispositif"; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Contacter le client pour planifier un rendez-vous.", engagementDTOs.First().Dispositif); |
||||||
|
Assert.AreEqual("Planifier un point hebdomadaire sur Teams.", engagementDTOs.Last().Dispositif); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDispositifDecroissant() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
bool? asc = false; |
||||||
|
string tri = "dispositif"; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Planifier un point hebdomadaire sur Teams.", engagementDTOs.First().Dispositif); |
||||||
|
Assert.AreEqual("Contacter le client pour planifier un rendez-vous.", engagementDTOs.Last().Dispositif); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParModaliteCroissante() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
bool? asc = true; |
||||||
|
string tri = "modalite"; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Hors temps", engagementDTOs.First().Modalite); |
||||||
|
Assert.AreEqual("Sur temps de travail", engagementDTOs.Last().Modalite); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParModaliteDecroissante() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
bool? asc = false; |
||||||
|
string tri = "modalite"; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Sur temps de travail", engagementDTOs.First().Modalite); |
||||||
|
Assert.AreEqual("Hors temps", engagementDTOs.Last().Modalite); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDateCroissante() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
bool? asc = true; |
||||||
|
string tri = "date"; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(new DateTime(2020, 9, 1), engagementDTOs.First().DateLimite); |
||||||
|
Assert.AreEqual(new DateTime(2021, 1, 31), engagementDTOs.Last().DateLimite); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetEngagementsAsync_PasseEnParamAscEtTri_RetourneDesEngagementsOrdonnancesParDateDecroissante() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>() { 1, 2, 3 }; |
||||||
|
bool? asc = false; |
||||||
|
string tri = "date"; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, asc, null, null, null, tri); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(new DateTime(2021, 1, 31), engagementDTOs.First().DateLimite); |
||||||
|
Assert.AreEqual(new DateTime(2020, 9, 1), engagementDTOs.Last().DateLimite); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(new long[] { 0 }, null )] |
||||||
|
[TestCase(new long[] { 4 }, null)] |
||||||
|
[TestCase(new long[] { 1, 2 }, "azerty")] |
||||||
|
|
||||||
|
public async Task GetEngagementsAsync_PasseDesParamsInvalides_RetourneZeroEngagement(long[] arrIdBUs, string texte) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs; |
||||||
|
|
||||||
|
if (arrIdBUs != null) |
||||||
|
idBUs = arrIdBUs.Select(x => x).ToList(); |
||||||
|
else |
||||||
|
idBUs = new List<long>(); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<EngagementDTO> engagementDTOs = await engagementService.GetEngagementsAsync(idBUs, null, null, null, null, texte, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(0, engagementDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEngagementsAsync_PasseDesParamsUneListeDIdsBUVide_LeveUneEngagementInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = new List<long>(); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => engagementService.GetEngagementsAsync(idBUs, null, null, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(EngagementInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetEngagementsAsync_PasseDesParamsUneListeDIdsBUNull_LeveUneEngagementInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs = null; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => engagementService.GetEngagementsAsync(idBUs, null, null, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(EngagementInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetEngagementsCountAsync |
||||||
|
|
||||||
|
[TestCase(new long[] { 1, 2, 3 }, "Coty")] |
||||||
|
[TestCase(new long[] { 1 }, null)] |
||||||
|
public async Task GetEngagementsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDEngagements(long[] arrIdBUs, string texte) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs; |
||||||
|
|
||||||
|
if (arrIdBUs != null) |
||||||
|
idBUs = arrIdBUs.Select(x => x).ToList(); |
||||||
|
else |
||||||
|
idBUs = new List<long>(); |
||||||
|
|
||||||
|
// Act |
||||||
|
long count = await engagementService.GetEngagementsCountAsync(idBUs, null, texte); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Less(0, count); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(new long[] { 0 }, null)] |
||||||
|
[TestCase(new long[] { 4 }, null)] |
||||||
|
[TestCase(new long[] { 1, 2 }, "azerty")] |
||||||
|
public async Task GetEngagementsCountAsync_PasseDesParamsInvalides_RetourneZero(long[] arrIdBUs, string texte) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
List<long> idBUs; |
||||||
|
|
||||||
|
if (arrIdBUs != null) |
||||||
|
idBUs = arrIdBUs.Select(x => x).ToList(); |
||||||
|
else |
||||||
|
idBUs = new List<long>(); |
||||||
|
|
||||||
|
// Act |
||||||
|
long count = await engagementService.GetEngagementsCountAsync(idBUs, null, texte); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(0, count); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests RepondreEngagementAsync |
||||||
|
|
||||||
|
[TestCase(1, 9, EtatEngagement.Respecte, null)] |
||||||
|
[TestCase(1, 9, EtatEngagement.EnAttente, null)] |
||||||
|
[TestCase(2, 9, EtatEngagement.NonRealisable, "Impossible de respecter cet engagement car hors budget.")] |
||||||
|
public async Task RepondreEngagementAsync_ModifieUnEngagementValide_EngagementModifieAvecSucces(long idEngagement, long idEp, EtatEngagement etatEngagement, string raisonNonRealisable) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO =new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = etatEngagement, |
||||||
|
RaisonNonRealisable = raisonNonRealisable, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
EngagementDTO engagementModifie = await engagementService.RepondreEngagementAsync(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(engagementModifie); |
||||||
|
Assert.AreEqual(idEngagement, engagementModifie.Id); |
||||||
|
Assert.AreEqual(engagementDTO.Id, engagementModifie.Id); |
||||||
|
Assert.AreEqual(engagementDTO.EtatEngagement, engagementModifie.EtatEngagement); |
||||||
|
Assert.AreEqual(engagementDTO.RaisonNonRealisable, engagementModifie.RaisonNonRealisable); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task RepondreEngagementAsync_ModifieUnEngagementAvecUneDateLimitePasseeValide_EngagementModifieAvecSucces() |
||||||
|
{ |
||||||
|
long idEngagement = 3; |
||||||
|
long idEp = 9; |
||||||
|
EtatEngagement etatEngagement = EtatEngagement.DateLimitePassee; |
||||||
|
string raisonNonRealisableAvantUpdate = null; |
||||||
|
string raisonNonRealisableApresUpdate = "La date limite pour respecter l'engagement est passée."; |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = etatEngagement, |
||||||
|
RaisonNonRealisable = raisonNonRealisableAvantUpdate, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
EngagementDTO engagementModifie = await engagementService.RepondreEngagementAsync(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(engagementModifie); |
||||||
|
Assert.AreEqual(idEngagement, engagementModifie.Id); |
||||||
|
Assert.AreEqual(engagementDTO.Id, engagementModifie.Id); |
||||||
|
Assert.AreEqual(engagementDTO.EtatEngagement, engagementModifie.EtatEngagement); |
||||||
|
Assert.AreEqual(raisonNonRealisableApresUpdate, engagementModifie.RaisonNonRealisable); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(1, 0, "Je m'engage à trouver une formation sur l'Asp.Net Core.", "Demande de formation RH.", "Sur temps de travail", "2020-9-11", EtatEngagement.Respecte, null)] |
||||||
|
[TestCase(1, 11, "Je m'engage à trouver une formation sur l'Asp.Net Core.", "Demande de formation RH.", "Sur temps de travail", "2020-9-11", EtatEngagement.Respecte, null)] |
||||||
|
[TestCase(1, 9, "", "Demande de formation RH.", "Sur temps de travail", "2020-9-11", EtatEngagement.Respecte, null)] |
||||||
|
[TestCase(1, 9, "Je m'engage à trouver une formation sur l'Asp.Net Core.", "", "Sur temps de travail", "2020-9-11", EtatEngagement.Respecte, null)] |
||||||
|
[TestCase(1, 9, "Je m'engage à trouver une formation sur l'Asp.Net Core.", "Demande de formation RH.", "", "2020-9-11", EtatEngagement.Respecte, null)] |
||||||
|
[TestCase(1, 9, "Je m'engage à trouver une formation sur l'Asp.Net Core.", "Demande de formation RH.", "Sur temps de travail", null, EtatEngagement.Respecte, null)] |
||||||
|
[TestCase(1, 9, "Je m'engage à trouver une formation sur l'Asp.Net Core.", "Demande de formation RH.", "Sur temps de travail", "2020-9-11", EtatEngagement.NonRealisable, null)] |
||||||
|
public void RepondreEngagementAsync_ModifieUnEngagementAvecDesProprietesInvalide_LeveUneEngagementInvalidException(long idEngagement, long idEp, string action, string dispositif, string modalite, DateTime? dateLimite, EtatEngagement etatEngagement, string raisonNonRealisable) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = action, |
||||||
|
Dispositif = dispositif, |
||||||
|
Modalite = modalite, |
||||||
|
DateLimite = dateLimite, |
||||||
|
EtatEngagement = etatEngagement, |
||||||
|
RaisonNonRealisable = raisonNonRealisable, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => engagementService.RepondreEngagementAsync(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(EngagementInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void RepondreEngagementAsync_ModifieUnEngagementNull_LeveUneEngagementInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
EngagementDTO engagementDTO = null; |
||||||
|
long idEngagement = 1; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => engagementService.RepondreEngagementAsync(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(EngagementInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void RepondreEngagementAsync_ModifieUnEngagementAvecUnEPInexistantDansLaBDD_LeveUneEngagementInvalidException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
long idEngagement = 1; |
||||||
|
EpInformationDTO epInformationDTO = new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = 999, |
||||||
|
Type = TypeEp.EPA, |
||||||
|
Statut = StatutEp.Signe, |
||||||
|
DateDisponibilite = DateTime.Now, |
||||||
|
DatePrevisionnelle = DateTime.Now, |
||||||
|
Obligatoire = false |
||||||
|
}; |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = EtatEngagement.Respecte, |
||||||
|
RaisonNonRealisable = null, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => engagementService.RepondreEngagementAsync(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(EngagementInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[TestCase(1)] |
||||||
|
[TestCase(null)] |
||||||
|
public void RepondreEngagementAsync_ModifieUnEngagementAvecUnIdIncorrecte_LeveUneEngagementnIncompatibleIdException(long? idEngagement) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idEngagementIncorrecte = 2; |
||||||
|
long idEp = 9; |
||||||
|
|
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = EtatEngagement.Respecte, |
||||||
|
RaisonNonRealisable = null, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => engagementService.RepondreEngagementAsync(engagementDTO, idEngagementIncorrecte); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(EngagementIncompatibleIdException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void RepondreEngagementAsync_ModifieUnEngagementAvecUnIdInexistant_LeveUneEngagementNotFoundException() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
long idEngagement = 0; |
||||||
|
long idEp = 9; |
||||||
|
|
||||||
|
EngagementService engagementService = new EngagementService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
EpInformationDTO epInformationDTO = epContext.Ep.Where(ep => ep.IdEP == idEp) |
||||||
|
.Select(ep => new EpInformationDTO |
||||||
|
{ |
||||||
|
Id = ep.IdEP, |
||||||
|
Type = ep.TypeEP, |
||||||
|
Statut = ep.Statut, |
||||||
|
DateDisponibilite = ep.DateDisponibilite, |
||||||
|
DatePrevisionnelle = ep.DatePrevisionnelle, |
||||||
|
Obligatoire = ep.Obligatoire |
||||||
|
}).FirstOrDefault(); |
||||||
|
|
||||||
|
EngagementDTO engagementDTO = new EngagementDTO |
||||||
|
{ |
||||||
|
Id = idEngagement, |
||||||
|
Action = "Je m'engage à trouver une formation sur l'Asp.Net Core.", |
||||||
|
Dispositif = "Demande de formation RH.", |
||||||
|
Modalite = "Sur temps de travail", |
||||||
|
DateLimite = new DateTime(2020, 9, 1), |
||||||
|
EtatEngagement = EtatEngagement.Respecte, |
||||||
|
RaisonNonRealisable = null, |
||||||
|
Ep = epInformationDTO |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => engagementService.RepondreEngagementAsync(engagementDTO, idEngagement); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(EngagementNotFoundException), throwException); |
||||||
|
} |
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,983 @@ |
|||||||
|
using EPAServeur.Context; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using EPAServeur.Models.Formation; |
||||||
|
using EPAServeur.Services; |
||||||
|
using IO.Swagger.ApiCollaborateur; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace EPAServeur.Tests.Services |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class FormationServiceTests |
||||||
|
{ |
||||||
|
#region Variables |
||||||
|
|
||||||
|
private EpContext epContext; |
||||||
|
private ICollaborateurApi collaborateurApi; |
||||||
|
private ICollaborateurService collaborateurService; |
||||||
|
private ITransformDTO transformDTO; |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Setup |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
// Utilisation d'une base de données en mémoire |
||||||
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
||||||
|
.UseInMemoryDatabase("server_ep_test") |
||||||
|
.Options; |
||||||
|
|
||||||
|
epContext = new EpContext(optionBuider); |
||||||
|
collaborateurApi = new CollaborateurApi(); |
||||||
|
transformDTO = new TransformDTO(); |
||||||
|
collaborateurService = new CollaborateurService(collaborateurApi, epContext, transformDTO); |
||||||
|
epContext.Database.EnsureDeleted(); |
||||||
|
epContext.Database.EnsureCreated(); |
||||||
|
epContext.SaveChanges(); |
||||||
|
|
||||||
|
// Ajout du jeu de données pour les tests |
||||||
|
DataSeeder.AddFormations(epContext); |
||||||
|
|
||||||
|
// Détache les entités du context car la base de données InMemory créé des conflits |
||||||
|
// entre les clés primaires lors d'un Update ou d'un Insert |
||||||
|
foreach (var entity in epContext.ChangeTracker.Entries()) |
||||||
|
{ |
||||||
|
entity.State = EntityState.Detached; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetFormationByIdAsync |
||||||
|
[Test] |
||||||
|
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
FormationDTO formationDTO = await formationService.GetFormationByIdAsync(3); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(3, formationDTO.Id); |
||||||
|
Assert.AreEqual("Apprendre C# et le développement de logiciels avec WPF", formationDTO.Intitule); |
||||||
|
Assert.AreEqual(1, formationDTO.IdAgence); |
||||||
|
Assert.AreEqual(new DateTime(2020, 5, 25, 14, 0, 0), formationDTO.DateDebut); |
||||||
|
Assert.AreEqual(new DateTime(2020, 5, 27), formationDTO.DateFin); |
||||||
|
Assert.AreEqual(4, formationDTO.Heure); |
||||||
|
Assert.AreEqual(2, formationDTO.Jour); |
||||||
|
Assert.AreEqual("Organisme2", formationDTO.Organisme); |
||||||
|
Assert.True(formationDTO.EstCertifiee); |
||||||
|
Assert.IsNotNull(formationDTO.Participations); |
||||||
|
Assert.AreEqual(new OrigineFormationDTO { Id = 3, Libelle = "Exigence Apside" }, formationDTO.Origine); |
||||||
|
Assert.AreEqual(new StatutFormationDTO { Id = 1, Libelle = "Planifiée" }, formationDTO.Statut); |
||||||
|
Assert.AreEqual(new ModeFormationDTO { Id = 4, Libelle = "E-learning" }, formationDTO.Mode); |
||||||
|
Assert.AreEqual(new TypeFormationDTO { Id = 3, Libelle = "E-learning" }, formationDTO.Type); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetFormationByIdAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneFormationSansParticipation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idFormation = 11; |
||||||
|
|
||||||
|
// Act |
||||||
|
FormationDTO formationDTO = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(idFormation, formationDTO.Id); |
||||||
|
Assert.AreEqual("Formation Clean Architecture .Net Core", formationDTO.Intitule); |
||||||
|
Assert.AreEqual(1, formationDTO.IdAgence); |
||||||
|
Assert.AreEqual(new DateTime(2020, 04, 6, 9, 0, 0), formationDTO.DateDebut); |
||||||
|
Assert.AreEqual(new DateTime(2020, 04, 11), formationDTO.DateFin); |
||||||
|
Assert.AreEqual(15, formationDTO.Heure); |
||||||
|
Assert.AreEqual(5, formationDTO.Jour); |
||||||
|
Assert.AreEqual("Organisme1", formationDTO.Organisme); |
||||||
|
Assert.False(formationDTO.EstCertifiee); |
||||||
|
Assert.IsNull(formationDTO.Participations); |
||||||
|
Assert.AreEqual(new OrigineFormationDTO { Id = 4, Libelle = "Formation réglementaire" }, formationDTO.Origine); |
||||||
|
Assert.AreEqual(new StatutFormationDTO { Id = 4, Libelle = "Annulée" }, formationDTO.Statut); |
||||||
|
Assert.AreEqual(new ModeFormationDTO { Id = 3, Libelle = "Présentiel" }, formationDTO.Mode); |
||||||
|
Assert.AreEqual(new TypeFormationDTO { Id = 2, Libelle = "Interne" }, formationDTO.Type); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(-1)] |
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(999999)] |
||||||
|
public void GetFormationByIdAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneFormationNotFoundException(long idFormation) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationNotFoundException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetFormationsAsync |
||||||
|
|
||||||
|
[TestCase(1, new int[] { 1, 2, 3 }, true, 1, 5, "formation", null, null, null)] |
||||||
|
[TestCase(1, new int[] { 1 }, false, 1, 5, "Formation Mainframe Complète", null, null, null)] |
||||||
|
[TestCase(null, null, null, 2, 10, null, null, null, null)] |
||||||
|
[TestCase(null, new int[] { 1 }, null, 1, 10, null, null, null, null)] |
||||||
|
[TestCase(1, null, null, 1, 10, "for", null, null, null)] |
||||||
|
[TestCase(1, new int[] { }, null, 1, 10, "for", null, null, null)] |
||||||
|
public async Task GetFormationsAsync_PasseDesParamsValides_RetourneDesFormations(long? idAgence, int[] arrIdStatuts, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
List<int?> idStatuts; |
||||||
|
|
||||||
|
if (arrIdStatuts != null) |
||||||
|
idStatuts = arrIdStatuts.Select(x => (int?)x).ToList(); |
||||||
|
else |
||||||
|
idStatuts = null; |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(idAgence, idStatuts, asc, numPage, parPAge, texte, tri, dateDebut, dateFin); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Less(0, formationDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(1, 5)] |
||||||
|
[TestCase(1, 10)] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaPremierePageDesFormations(int? numPage, int? parPAge) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, numPage, parPAge, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(parPAge, formationDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(2, 5)] |
||||||
|
[TestCase(2, 6)] |
||||||
|
[TestCase(2, 10)] |
||||||
|
[TestCase(2, 15)] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamNumPageEtParPage_RetourneLaDeuxiemePageDesFormations(int? numPage, int? parPAge) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
int? nbFormationDeuxiemePage; |
||||||
|
|
||||||
|
switch (parPAge) |
||||||
|
{ |
||||||
|
case 5: |
||||||
|
nbFormationDeuxiemePage = 5; |
||||||
|
break; |
||||||
|
case 6: |
||||||
|
nbFormationDeuxiemePage = 5; |
||||||
|
break; |
||||||
|
case 10: |
||||||
|
nbFormationDeuxiemePage = 1; |
||||||
|
break; |
||||||
|
default: |
||||||
|
nbFormationDeuxiemePage = 0; |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, numPage, parPAge, null, null, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(nbFormationDeuxiemePage, formationDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(true, "intitule")] |
||||||
|
[TestCase(true, null)] |
||||||
|
[TestCase(true, "toto")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleCroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Apprendre C# et le développement de logiciels avec WPF", formationDTOs.First().Intitule); |
||||||
|
Assert.AreEqual("Formation Xamarin, Développer des applications mobiles en C# pour iOS et Android", formationDTOs.Last().Intitule); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(false, "intitule")] |
||||||
|
[TestCase(false, null)] |
||||||
|
[TestCase(false, "toto")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParIntituleDecroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Formation Xamarin, Développer des applications mobiles en C# pour iOS et Android", formationDTOs.First().Intitule); |
||||||
|
Assert.AreEqual("Apprendre C# et le développement de logiciels avec WPF", formationDTOs.Last().Intitule); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(true, "statut")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutCroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Annulée", formationDTOs.First().Statut.Libelle); |
||||||
|
Assert.AreEqual("Replanifiée", formationDTOs.Last().Statut.Libelle); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(false, "statut")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParStatutDecroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Replanifiée", formationDTOs.First().Statut.Libelle); |
||||||
|
Assert.AreEqual("Annulée", formationDTOs.Last().Statut.Libelle); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(true, "participants")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsCroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(0, formationDTOs.First().NbParticipations); |
||||||
|
Assert.AreEqual(2, formationDTOs.Last().NbParticipations); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(false, "participants")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParNombreDeParticipantsDecroissant(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(2, formationDTOs.First().NbParticipations); |
||||||
|
Assert.AreEqual(0, formationDTOs.Last().NbParticipations); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(true, "origine")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineCroissante(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Demande collaborateur", formationDTOs.First().Origine.Libelle); |
||||||
|
Assert.AreEqual("Formation réglementaire", formationDTOs.Last().Origine.Libelle); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(false, "origine")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParOrigineDecroissante(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual("Formation réglementaire", formationDTOs.First().Origine.Libelle); |
||||||
|
Assert.AreEqual("Demande collaborateur", formationDTOs.Last().Origine.Libelle); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(true, "date")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateCroissante(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(new DateTime(2020, 1, 25, 10, 0, 0), formationDTOs.First().DateDebut); |
||||||
|
Assert.AreEqual(new DateTime(2020, 12, 25, 14, 0, 0), formationDTOs.Last().DateDebut); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(false, "date")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParDateDecroissante(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(new DateTime(2020, 12, 25, 14, 0, 0), formationDTOs.First().DateDebut); |
||||||
|
Assert.AreEqual(new DateTime(2020, 1, 25, 10, 0, 0), formationDTOs.Last().DateDebut); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(true, "certification")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationCroissante(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(false, formationDTOs.First().EstCertifiee); |
||||||
|
Assert.AreEqual(true, formationDTOs.Last().EstCertifiee); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(false, "certification")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamAscEtTri_RetourneDesFormationsOrdonnanceeParCertificationDecroissante(bool? asc, string tri) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, asc, null, null, null, tri, null, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(true, formationDTOs.First().EstCertifiee); |
||||||
|
Assert.AreEqual(false, formationDTOs.Last().EstCertifiee); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[TestCase("2020-10-01")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebut_RetourneDesFormationsAvecUneDateDeDebutSuperieur(DateTime dateDebut) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, null); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Greater(formationDTOs.First().DateDebut, dateDebut); |
||||||
|
Assert.GreaterOrEqual(formationDTOs.Last().DateDebut, dateDebut); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase("2020-10-01")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamUneDateDeFin_RetourneDesFormationsAvecUneDateDeFinInferieur(DateTime dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, null, dateFin); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Less(formationDTOs.First().DateFin, dateFin); |
||||||
|
Assert.LessOrEqual(formationDTOs.Last().DateFin, dateFin); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase("2020-11-01", "2020-12-01")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutEtUneDateDeFin_RetourneDesFormationsAvecUneDateDeDebutSuperieurUneDateDeFinInferieur(DateTime dateDebut, DateTime dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, dateFin); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Greater(formationDTOs.First().DateDebut, dateDebut); |
||||||
|
Assert.Less(formationDTOs.First().DateFin, dateFin); |
||||||
|
|
||||||
|
Assert.GreaterOrEqual(formationDTOs.Last().DateDebut, dateDebut); |
||||||
|
Assert.LessOrEqual(formationDTOs.Last().DateFin, dateFin); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
[TestCase("2020-11-01", "2020-10-01")] |
||||||
|
public async Task GetFormationsAsync_PasseEnParamUneDateDeDebutSuperieurEtUneDateDeFinInferieur_RetourneZeroFormation(DateTime dateDebut, DateTime dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(null, null, null, null, null, null, null, dateDebut, dateFin); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(0, formationDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(1, new int[] { 1 }, true, 1, 15, "azerty", null, null, null)] |
||||||
|
[TestCase(-1, new int[] { -1 }, null, -1, -1, "azerty", null, null, null)] |
||||||
|
[TestCase(0, new int[] { 0 }, null, 0, 0, null, null, null, null)] |
||||||
|
public async Task GetFormationsAsync_PasseDesParamsInvalides_RetourneZeroFormation(long? idAgence, int[] arrIdStatuts, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
List<int?> idStatuts; |
||||||
|
|
||||||
|
if (arrIdStatuts != null) |
||||||
|
idStatuts = arrIdStatuts.Select(x => (int?)x).ToList(); |
||||||
|
else |
||||||
|
idStatuts = null; |
||||||
|
|
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<FormationDetailsDTO> formationDTOs = await formationService.GetFormationsAsync(idAgence, idStatuts, asc, numPage, parPAge, texte, tri, dateDebut, dateFin); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(0, formationDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetFormationsCountAsync |
||||||
|
|
||||||
|
[TestCase(1, new int[] { 1, 2, 3 }, "formation", "2020-09-30", "2020-11-30")] |
||||||
|
[TestCase(1, new int[] { 1 }, "Formation Mainframe Complète", null, null)] |
||||||
|
[TestCase(null, null, null, null, null)] |
||||||
|
[TestCase(null, new int[] { 1 }, null, null, null)] |
||||||
|
[TestCase(1, null, "for", null, null)] |
||||||
|
[TestCase(1, new int[] { }, "for", null, null)] |
||||||
|
public async Task GetFormationsCountAsync_PasseDesParamsValides_RetourneLeNombreTotalDeFormations(long? idAgence, int[] arrIdStatuts, string texte, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
List<int?> idStatuts; |
||||||
|
|
||||||
|
if (arrIdStatuts != null) |
||||||
|
idStatuts = arrIdStatuts.Select(x => (int?)x).ToList(); |
||||||
|
else |
||||||
|
idStatuts = null; |
||||||
|
|
||||||
|
// Act |
||||||
|
long count = await formationService.GetFormationsCountAsync(idAgence, idStatuts, texte, dateDebut, dateFin); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Less(0, count); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(1, new int[] { 1 }, "azerty", null, null)] |
||||||
|
[TestCase(-1, new int[] { -1 }, "azerty", null, null)] |
||||||
|
[TestCase(0, new int[] { 0 }, null, null, null)] |
||||||
|
public async Task GetFormationsCountAsync_PasseDesParamsInvalides_RetourneZero(long? idAgence, int[] arrIdStatuts, string texte, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
List<int?> idStatuts; |
||||||
|
|
||||||
|
if (arrIdStatuts != null) |
||||||
|
idStatuts = arrIdStatuts.Select(x => (int?)x).ToList(); |
||||||
|
else |
||||||
|
idStatuts = null; |
||||||
|
|
||||||
|
// Act |
||||||
|
long count = await formationService.GetFormationsCountAsync(idAgence, idStatuts, texte, dateDebut, dateFin); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(0, count); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
|
||||||
|
#region Tests GetModesFormationAsync |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetModesFormationAsync_RetourneTousLesModesDeFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<ModeFormationDTO> modeFormationDTOs = await formationService.GetModesFormationAsync(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(modeFormationDTOs); |
||||||
|
Assert.AreEqual(4, modeFormationDTOs.Count()); // Nombre total de mode de formation dans la classe DataSeeder le 2020-10-31 |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetOriginesFormationAsync |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetOriginesAsyncFormation_RetourneToutesLesOriginesDeFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<OrigineFormationDTO> origineFormationDTOs = await formationService.GetOriginesFormationAsync(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(origineFormationDTOs); |
||||||
|
Assert.AreEqual(4, origineFormationDTOs.Count()); // Nombre total d'origine de formation dans la classe DataSeeder le 2020-10-31 |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetStatutsFormationAsync |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetStatutsFormationAsyncFormation_RetourneTousLesStatutsDeFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<StatutFormationDTO> statutFormationDTOs = await formationService.GetStatutsFormationAsync(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(statutFormationDTOs); |
||||||
|
Assert.AreEqual(4, statutFormationDTOs.Count()); // Nombre total de statut de formation dans la classe DataSeeder le 2020-10-31 |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetTypesFormationAsync |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task GetTypesFormationAsync_RetourneTousLesTypesDeFormation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<TypeFormationDTO> typeFormationDTOs = await formationService.GetTypesFormationAsync(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(typeFormationDTOs); |
||||||
|
Assert.AreEqual(4, typeFormationDTOs.Count()); // Nombre total de type de formation dans la classe DataSeeder le 2020-10-31 |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests AddFormationAsync |
||||||
|
|
||||||
|
[TestCase(1, 1, 3, 1, 1, "Test ajout formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 1, 1, "Test ajout formation", "Apside", "2020-10-31", "2020-10-31")] |
||||||
|
[TestCase(1, 1, 3, 1, 1, "Test ajout formation", "Apside", "2020-11-02", "2020-11-02")] |
||||||
|
public async Task AddFormationAsync_AjouteUneFormationValide_FormationAjouteeAvecSucces(int? idMode, int? idStatut, int? idType, long? idOrigine, long? idAgence, string intitule, string organisme, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == idMode) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == idStatut) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == idType) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
|
||||||
|
FormationDTO formation = new FormationDTO |
||||||
|
{ |
||||||
|
Intitule = intitule, |
||||||
|
IdAgence = idAgence, |
||||||
|
DateDebut = dateDebut, |
||||||
|
DateFin = dateFin, |
||||||
|
Heure = 2, |
||||||
|
Jour = 1, |
||||||
|
Mode = modeExterne, |
||||||
|
Type = typeELearning, |
||||||
|
Organisme = organisme, |
||||||
|
Origine = origineFormationCollaborateur, |
||||||
|
Statut = statutPlanifie, |
||||||
|
EstCertifiee = false |
||||||
|
}; |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
FormationDTO formationAjoute = await formationService.AddFormationAsync(formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(formationAjoute); |
||||||
|
Assert.AreEqual(12, formationAjoute.Id); |
||||||
|
Assert.AreEqual(formation.Intitule, formationAjoute.Intitule); |
||||||
|
Assert.AreEqual(formation.IdAgence, formationAjoute.IdAgence); |
||||||
|
Assert.AreEqual(formation.DateDebut, formationAjoute.DateDebut); |
||||||
|
Assert.AreEqual(formation.DateFin, formationAjoute.DateFin); |
||||||
|
Assert.AreEqual(formation.Heure, formationAjoute.Heure); |
||||||
|
Assert.AreEqual(formation.Jour, formationAjoute.Jour); |
||||||
|
Assert.AreEqual(formation.Mode, formationAjoute.Mode); |
||||||
|
Assert.AreEqual(formation.Type, formationAjoute.Type); |
||||||
|
Assert.AreEqual(formation.Organisme, formationAjoute.Organisme); |
||||||
|
Assert.AreEqual(formation.Origine, formationAjoute.Origine); |
||||||
|
Assert.AreEqual(formation.Statut, formationAjoute.Statut); |
||||||
|
Assert.AreEqual(formation.EstCertifiee, formationAjoute.EstCertifiee); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void AddFormationAsync_AjouteUneFormationNull_LeveUneFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
FormationDTO formation = null; |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(1, 1, 3, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-10-30")] |
||||||
|
[TestCase(0, 1, 3, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 0, 3, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 0, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 0, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 1, 0, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 1, 1, "", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 1, 1, "Test Formation", "", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 1, null, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 1, 1, null, "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 3, 1, 1, "Test Formation", null, "2020-10-31", "2020-11-02")] |
||||||
|
public void AddFormationAsync_AjouteUneFormationAvecDesProprietesInvalides_LeveUneFormationInvalidException(int? idMode, int? idStatut, int? idType, int? idOrigine, long? idAgence, string intitule, string organisme, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == idMode) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == idStatut) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == idType) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
|
||||||
|
FormationDTO formation = new FormationDTO |
||||||
|
{ |
||||||
|
Intitule = intitule, |
||||||
|
IdAgence = idAgence, |
||||||
|
DateDebut = dateDebut, |
||||||
|
DateFin = dateFin, |
||||||
|
Heure = 2, |
||||||
|
Jour = 1, |
||||||
|
Mode = modeExterne, |
||||||
|
Type = typeELearning, |
||||||
|
Organisme = organisme, |
||||||
|
Origine = origineFormationCollaborateur, |
||||||
|
Statut = statutPlanifie, |
||||||
|
EstCertifiee = false |
||||||
|
}; |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0, 1, 3, 1, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 0, 3, 1, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, 0, 1, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, 3, 0, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(null, 1, 3, 1, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, null, 3, 1, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, null, 1, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, 3, null, "Externe", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, 3, 1, "Externez", "Planifiée", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, 3, 1, "Externe", "Planifiées", "E-learning", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, 3, 1, "Externe", "Planifiée", "E-learnings", "Demande collaborateur")] |
||||||
|
[TestCase(1, 1, 3, 1, "Externe", "Planifiée", "E-learning", "Demande collaborateurs")] |
||||||
|
public void AddFormationAsync_AjouteUneFormationAvecDesObjetsEnfantsInvalides_LeveUneFormationInvalidException(int? idMode, int? idStatut, int? idType, int? idOrigine, string libelleMode, string libelleStatut, string libelleType, string libelleOrigine) |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ModeFormationDTO modeExterne = new ModeFormationDTO { Id = idMode, Libelle = libelleMode }; |
||||||
|
StatutFormationDTO statutPlanifie = new StatutFormationDTO { Id = idStatut, Libelle = libelleStatut }; |
||||||
|
TypeFormationDTO typeELearning = new TypeFormationDTO { Id = idType, Libelle = libelleType }; |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = new OrigineFormationDTO { Id = idOrigine, Libelle = libelleOrigine }; |
||||||
|
|
||||||
|
FormationDTO formation = new FormationDTO |
||||||
|
{ |
||||||
|
Intitule = "Test Formation", |
||||||
|
IdAgence = 1, |
||||||
|
DateDebut = new DateTime(2020, 10, 31), |
||||||
|
DateFin = new DateTime(2020, 11, 02), |
||||||
|
Heure = 2, |
||||||
|
Jour = 1, |
||||||
|
Mode = modeExterne, |
||||||
|
Type = typeELearning, |
||||||
|
Organisme = "Apside", |
||||||
|
Origine = origineFormationCollaborateur, |
||||||
|
Statut = statutPlanifie, |
||||||
|
EstCertifiee = false |
||||||
|
}; |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.AddFormationAsync(formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests UpdateFormationAsync |
||||||
|
|
||||||
|
[TestCase(1, 2, 2, 1, 1, 2, "Test modification formation", "Apside", "2020-10-31", "2020-11-04")] |
||||||
|
public async Task UpdateFormationAsync_ModifieUneFormationValide_FormationModifieeAvecSucces(long idFormation, int? idMode, int? idStatut, int? idType, int? idOrigine, long? idAgence, string intitule, string organisme, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == idMode) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == idStatut) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == idType) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
formation.Intitule = intitule; |
||||||
|
formation.IdAgence = idAgence; |
||||||
|
formation.DateDebut = dateDebut; |
||||||
|
formation.DateFin = dateFin; |
||||||
|
formation.Heure = 2; |
||||||
|
formation.Jour = 1; |
||||||
|
formation.Mode = modeExterne; |
||||||
|
formation.Type = typeELearning; |
||||||
|
formation.Organisme = organisme; |
||||||
|
formation.Origine = origineFormationCollaborateur; |
||||||
|
formation.Statut = statutPlanifie; |
||||||
|
formation.EstCertifiee = false; |
||||||
|
|
||||||
|
|
||||||
|
// Act |
||||||
|
FormationDTO formationModifie = await formationService.UpdateFormationAsync(idFormation, formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(formationModifie); |
||||||
|
Assert.AreEqual(idFormation, formationModifie.Id); |
||||||
|
Assert.AreEqual(formation.Intitule, formationModifie.Intitule); |
||||||
|
Assert.AreEqual(formation.IdAgence, formationModifie.IdAgence); |
||||||
|
Assert.AreEqual(formation.DateDebut, formationModifie.DateDebut); |
||||||
|
Assert.AreEqual(formation.DateFin, formationModifie.DateFin); |
||||||
|
Assert.AreEqual(formation.Heure, formationModifie.Heure); |
||||||
|
Assert.AreEqual(formation.Jour, formationModifie.Jour); |
||||||
|
Assert.AreEqual(formation.Mode, formationModifie.Mode); |
||||||
|
Assert.AreEqual(formation.Type, formationModifie.Type); |
||||||
|
Assert.AreEqual(formation.Organisme, formationModifie.Organisme); |
||||||
|
Assert.AreEqual(formation.Origine, formationModifie.Origine); |
||||||
|
Assert.AreEqual(formation.Statut, formationModifie.Statut); |
||||||
|
Assert.AreEqual(formation.EstCertifiee, formationModifie.EstCertifiee); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(1, 1, 1, 3, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-10-30")] |
||||||
|
[TestCase(1, 0, 1, 3, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 0, 3, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 0, 1, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 0, 1, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, 0, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, 1, "", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, 1, "Test Formation", "", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, null, "Test Formation", "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, 1, null, "Apside", "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, 1, "Test Formation", null, "2020-10-31", "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, 1, "Test Formation", "Apside", null, "2020-11-02")] |
||||||
|
[TestCase(1, 1, 1, 3, 1, 1, "Test Formation", "Apside", "2020-10-31", null)] |
||||||
|
public async Task UpdateFormationAsync_ModifieUneFormationAvecDesProprietesInvalides_LeveUneFormationInvalidException(long idFormation, int? idMode, int? idStatut, int? idType, int? idOrigine, long? idAgence, string intitule, string organisme, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == idMode) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == idStatut) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == idType) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
formation.Intitule = intitule; |
||||||
|
formation.IdAgence = idAgence; |
||||||
|
formation.DateDebut = dateDebut; |
||||||
|
formation.DateFin = dateFin; |
||||||
|
formation.Heure = 2; |
||||||
|
formation.Jour = 1; |
||||||
|
formation.Mode = modeExterne; |
||||||
|
formation.Type = typeELearning; |
||||||
|
formation.Organisme = organisme; |
||||||
|
formation.Origine = origineFormationCollaborateur; |
||||||
|
formation.Statut = statutPlanifie; |
||||||
|
formation.EstCertifiee = false; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.UpdateFormationAsync(idFormation, formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(2, 2, 2, 1, 1, 2, "Test modification formation", "Apside", "2020-10-31", "2020-11-04")] |
||||||
|
[TestCase(0, 2, 2, 1, 1, 2, "Test modification formation", "Apside", "2020-10-31", "2020-11-04")] |
||||||
|
[TestCase(null, 2, 2, 1, 1, 2, "Test modification formation", "Apside", "2020-10-31", "2020-11-04")] |
||||||
|
public async Task UpdateFormationAsync_ModifieUneFormationAvecUnIdIncorrecte_LeveUneFormationIncompatibleIdException(long? idFormation, int? idMode, int? idStatut, int? idType, int? idOrigine, long? idAgence, string intitule, string organisme, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == idMode) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == idStatut) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == idType) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
FormationDTO formation = await formationService.GetFormationByIdAsync(1); |
||||||
|
|
||||||
|
formation.Id = idFormation; |
||||||
|
formation.Intitule = intitule; |
||||||
|
formation.IdAgence = idAgence; |
||||||
|
formation.DateDebut = dateDebut; |
||||||
|
formation.DateFin = dateFin; |
||||||
|
formation.Heure = 2; |
||||||
|
formation.Jour = 1; |
||||||
|
formation.Mode = modeExterne; |
||||||
|
formation.Type = typeELearning; |
||||||
|
formation.Organisme = organisme; |
||||||
|
formation.Origine = origineFormationCollaborateur; |
||||||
|
formation.Statut = statutPlanifie; |
||||||
|
formation.EstCertifiee = false; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.UpdateFormationAsync(1, formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationIncompatibleIdException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0, 2, 2, 1, 1, 2, "Test modification formation", "Apside", "2020-10-31", "2020-11-04")] |
||||||
|
public void UpdateFormationAsync_ModifieUneFormationAvecUnIdInexistant_RetourneUnObjetNull(long idFormation, int? idMode, int? idStatut, int? idType, int? idOrigine, long? idAgence, string intitule, string organisme, DateTime? dateDebut, DateTime? dateFin) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == idMode) |
||||||
|
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == idStatut) |
||||||
|
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == idType) |
||||||
|
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == idOrigine) |
||||||
|
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault(); |
||||||
|
|
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
FormationDTO formation = new FormationDTO |
||||||
|
{ |
||||||
|
Id = idFormation, |
||||||
|
Intitule = intitule, |
||||||
|
IdAgence = idAgence, |
||||||
|
DateDebut = dateDebut, |
||||||
|
DateFin = dateFin, |
||||||
|
Heure = 2, |
||||||
|
Jour = 1, |
||||||
|
Mode = modeExterne, |
||||||
|
Type = typeELearning, |
||||||
|
Organisme = organisme, |
||||||
|
Origine = origineFormationCollaborateur, |
||||||
|
Statut = statutPlanifie, |
||||||
|
EstCertifiee = false |
||||||
|
}; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.UpdateFormationAsync(idFormation, formation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationNotFoundException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests DeleteFormationById et DeleteFormationByIdAsync |
||||||
|
|
||||||
|
[TestCase(1)] |
||||||
|
[TestCase(2)] |
||||||
|
public async Task DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdValide_FormationSupprimeAvecSucces(long idFormation) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
bool existFormation = true; |
||||||
|
|
||||||
|
// Act |
||||||
|
FormationDTO formationSupprime = await formationService.DeleteFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
existFormation = await epContext.Formation.AnyAsync(formation => formation.IdFormation == formationSupprime.Id.Value); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsFalse(existFormation); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(-1)] |
||||||
|
public void DeleteFormationByIdAsync_SupprimeUneFormationAvecUnIdInvalide_LeveUneFormationNotFoundException(long idFormation) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
FormationService formationService = new FormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => formationService.DeleteFormationByIdAsync(idFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(FormationNotFoundException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,763 @@ |
|||||||
|
using EPAServeur.Context; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using EPAServeur.Models.Formation; |
||||||
|
using EPAServeur.Services; |
||||||
|
using IO.Swagger.ApiCollaborateur; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace EPAServeur.Tests.Services |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ParticipationFormationServiceTests |
||||||
|
{ |
||||||
|
#region Variables |
||||||
|
|
||||||
|
private EpContext epContext; |
||||||
|
private ICollaborateurApi collaborateurApi; |
||||||
|
private ICollaborateurService collaborateurService; |
||||||
|
private ITransformDTO transformDTO; |
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Setup |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Setup() |
||||||
|
{ |
||||||
|
// Utilisation d'une base de données en mémoire |
||||||
|
var optionBuider = new DbContextOptionsBuilder<EpContext>() |
||||||
|
.UseInMemoryDatabase("server_ep_test") |
||||||
|
.Options; |
||||||
|
|
||||||
|
epContext = new EpContext(optionBuider); |
||||||
|
collaborateurApi = new CollaborateurApi(); |
||||||
|
transformDTO = new TransformDTO(); |
||||||
|
collaborateurService = new CollaborateurService(collaborateurApi, epContext, transformDTO); |
||||||
|
epContext.Database.EnsureDeleted(); |
||||||
|
epContext.Database.EnsureCreated(); |
||||||
|
epContext.SaveChanges(); |
||||||
|
|
||||||
|
// Ajout du jeu de données pour les tests |
||||||
|
DataSeeder.AddFormations(epContext); |
||||||
|
DataSeeder.AddChamps(epContext); |
||||||
|
|
||||||
|
// Détache les entités du context car la base de données InMemory créé des conflits |
||||||
|
// entre les clés primaires lors d'un Update ou d'un Insert |
||||||
|
foreach (var entity in epContext.ChangeTracker.Entries()) |
||||||
|
{ |
||||||
|
entity.State = EntityState.Detached; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetEvaluationCollaborateurAsync |
||||||
|
[Test] |
||||||
|
public async Task GetEvaluationCollaborateurAsync_PasseEnParamUnIdExistantDansLeJeuDeDonneesFictif_RetourneUneEvaluation() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
// Act |
||||||
|
EvaluationDTO evaluationDTO = await participationFormationService.GetEvaluationCollaborateurAsync(idParticipationFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(idParticipationFormation, evaluationDTO.Id); |
||||||
|
Assert.AreEqual(new DateTime(2020, 5, 25, 14, 0, 0), evaluationDTO.DateDebut); |
||||||
|
Assert.True(evaluationDTO.EstCertifiee); |
||||||
|
Assert.AreEqual("Apprendre C# et le développement de logiciels avec WPF", evaluationDTO.Intitule); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(-1)] |
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(999999)] |
||||||
|
public void GetEvaluationCollaborateurAsync_PasseEnParamUnIdInexistantDansLeJeuDeDonneesFictif_LeveUneParticipationFormationNotFoundException(long idParticipationFormation) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.GetEvaluationCollaborateurAsync(idParticipationFormation); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationNotFoundException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests GetParticipationsByCollaborateurAsync |
||||||
|
|
||||||
|
[TestCase("842650db-a548-4472-a3af-4c5fff3c1ab8")] |
||||||
|
[TestCase("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491")] |
||||||
|
public async Task GetParticipationByCollaborateurAsync_PasseDesParamsValides_RetourneDesParticipationsFormations(Guid idCollaborateur) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<ParticipationFormationDTO> participationFormationDTOs = await participationFormationService.GetParticipationsByCollaborateurAsync(idCollaborateur); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.Less(0, participationFormationDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase("e7820f92-eab1-42f5-ae96-5c16e71ff1e6")] |
||||||
|
[TestCase("b5254c6c-7caa-435f-a4bb-e0cf92559832")] |
||||||
|
public async Task GetParticipationByCollaborateurAsync_PasseDesParamsInvalides_RetourneZeroParticipation(Guid idCollaborateur) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
|
||||||
|
// Act |
||||||
|
IEnumerable<ParticipationFormationDTO> participationFormationDTOs = await participationFormationService.GetParticipationsByCollaborateurAsync(idCollaborateur); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.AreEqual(0, participationFormationDTOs.Count()); |
||||||
|
} |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
#region Tests EvaluerFormationAsync |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationValide_EvaluationRealiseeAvecSucces() |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
|
||||||
|
// Act |
||||||
|
EvaluationDTO evaluationModifiee = await participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
bool EstEvaluee = await epContext.ParticipationFormation.Where(p => p.IdParticipationFormation == idParticipationFormation).Select(p => p.EstEvaluee).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.IsNotNull(evaluationModifiee); |
||||||
|
Assert.True(EstEvaluee); |
||||||
|
Assert.AreEqual(evaluationDTO.Id, evaluationModifiee.Id); |
||||||
|
Assert.AreEqual(evaluationDTO.Intitule, evaluationModifiee.Intitule); |
||||||
|
Assert.AreEqual(evaluationDTO.Saisies.Count, evaluationModifiee.Saisies.Count); |
||||||
|
Assert.AreEqual(evaluationDTO.DateDebut, evaluationModifiee.DateDebut); |
||||||
|
Assert.AreEqual(evaluationDTO.EstCertifiee, evaluationModifiee.EstCertifiee); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[TestCase(null)] |
||||||
|
[TestCase("")] |
||||||
|
[TestCase(" ")] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationSansIntitule_LeveUneParticipationFormationInvalidException(string intitule) |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
evaluationDTO.Intitule = intitule; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationSansEstCertifiee_LeveUneParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
bool? estCertifiee = null; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
evaluationDTO.EstCertifiee = estCertifiee; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationSansDateDebut_LeveUneParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
DateTime? dateDebut = null; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
evaluationDTO.DateDebut = dateDebut; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationSansSaisie_LeveUneParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
evaluationDTO.Saisies = null; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecZeroSaisie_LeveUneParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
evaluationDTO.Saisies = new List<SaisieDTO>(); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecDesSaisiesSansNotesEtUnTypeDeSaisieCompetence_LeveUneParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = null, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecDesSaisiesSansNotesEtUnTypeDeSaisieNotation_LeveUneParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Notation }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = null, Texte = "", TypeSaisie = TypeSaisie.Notation, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
[Test] |
||||||
|
public void EvaluerFormationAsync_EvaluerUneFormationAvecUnDTONull_LeveUneParticipationFormationInvalidException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
EvaluationDTO evaluationDTO = null; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationInvalidException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(6)] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecUnIdIncorrecte_LeveUneParticipationFormationIncompatibleIdException(long idParticipationFormationIncompatible) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormationIncompatible, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationIncompatibleIdException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[TestCase(0)] |
||||||
|
[TestCase(6)] |
||||||
|
[TestCase(null)] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecUnIdIncorrecteAuNiveauDuDTO_LeveUneParticipationFormationIncompatibleIdException(long? idParticipationFormationIncompatible) |
||||||
|
{ |
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
evaluationDTO.Id = idParticipationFormationIncompatible; |
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormation, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationIncompatibleIdException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public async Task EvaluerFormationAsync_EvaluerUneFormationAvecUnIdInexistant_LeveUneParticipationFormationNotFoundException() |
||||||
|
{ |
||||||
|
|
||||||
|
// Arrange |
||||||
|
ParticipationFormationService participationFormationService = new ParticipationFormationService(epContext, collaborateurService, transformDTO); |
||||||
|
long idParticipationFormation = 5; |
||||||
|
long idParticipationFormationInexistant = 0; |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO = await epContext.ParticipationFormation.Include(p => p.Formation) |
||||||
|
.Where(p => p.IdParticipationFormation == idParticipationFormation) |
||||||
|
.Select(p => new EvaluationDTO() |
||||||
|
{ |
||||||
|
Id = p.IdParticipationFormation, |
||||||
|
Intitule = p.Formation.Intitule, |
||||||
|
DateDebut = p.Formation.DateDebut, |
||||||
|
EstCertifiee = p.Formation.EstCertifiee, |
||||||
|
Saisies = new List<SaisieDTO>() |
||||||
|
}).FirstOrDefaultAsync(); |
||||||
|
|
||||||
|
ChampDTO c1 = new ChampDTO { Id = 35, Section = "Evaluation", Ordre = 0, Texte = "Accueil et organisation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c2 = new ChampDTO { Id = 36, Section = "Evaluation", Ordre = 1, Texte = "Compétences animateur", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c3 = new ChampDTO { Id = 37, Section = "Evaluation", Ordre = 2, Texte = "Pédagogie/Animation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c4 = new ChampDTO { Id = 38, Section = "Evaluation", Ordre = 3, Texte = "Exhaustivité des sujets traités", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c5 = new ChampDTO { Id = 39, Section = "Evaluation", Ordre = 4, Texte = "Utilité/Apport de la formation", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c6 = new ChampDTO { Id = 40, Section = "Evaluation", Ordre = 5, Texte = "Contenu théorique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c7 = new ChampDTO { Id = 41, Section = "Evaluation", Ordre = 6, Texte = "Contenu pratique", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c8 = new ChampDTO { Id = 42, Section = "Evaluation", Ordre = 7, Texte = "Equilibre pratique/théorie", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c9 = new ChampDTO { Id = 43, Section = "Evaluation", Ordre = 8, Texte = "Support de cours", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
ChampDTO c10 = new ChampDTO { Id = 44, Section = "Evaluation", Ordre = 9, Texte = "Durée", TypeChamp = TypeChamps.Evaluation, TypeSaisie = TypeSaisie.Competence }; |
||||||
|
|
||||||
|
SaisieDTO s1 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c1 }; |
||||||
|
SaisieDTO s2 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c2 }; |
||||||
|
SaisieDTO s3 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c3 }; |
||||||
|
SaisieDTO s4 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c4 }; |
||||||
|
SaisieDTO s5 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c5 }; |
||||||
|
SaisieDTO s6 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c6 }; |
||||||
|
SaisieDTO s7 = new SaisieDTO { Note = 4, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c7 }; |
||||||
|
SaisieDTO s8 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c8 }; |
||||||
|
SaisieDTO s9 = new SaisieDTO { Note = 3, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c9 }; |
||||||
|
SaisieDTO s10 = new SaisieDTO { Note = 5, Texte = "", TypeSaisie = TypeSaisie.Competence, Champ = c10 }; |
||||||
|
|
||||||
|
evaluationDTO.Saisies.Add(s1); |
||||||
|
evaluationDTO.Saisies.Add(s2); |
||||||
|
evaluationDTO.Saisies.Add(s3); |
||||||
|
evaluationDTO.Saisies.Add(s4); |
||||||
|
evaluationDTO.Saisies.Add(s5); |
||||||
|
evaluationDTO.Saisies.Add(s6); |
||||||
|
evaluationDTO.Saisies.Add(s7); |
||||||
|
evaluationDTO.Saisies.Add(s8); |
||||||
|
evaluationDTO.Saisies.Add(s9); |
||||||
|
evaluationDTO.Saisies.Add(s10); |
||||||
|
|
||||||
|
evaluationDTO.Id = idParticipationFormationInexistant; |
||||||
|
|
||||||
|
|
||||||
|
// Act |
||||||
|
AsyncTestDelegate throwException = () => participationFormationService.EvaluerFormationAsync(idParticipationFormationInexistant, evaluationDTO); |
||||||
|
|
||||||
|
// Assert |
||||||
|
Assert.ThrowsAsync(typeof(ParticipationFormationNotFoundException), throwException); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,596 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using IO.Swagger.ClientCollaborateur; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class CollaborateursApiController : ControllerBase |
||||||
|
{ |
||||||
|
|
||||||
|
private readonly ICollaborateurService collaborateurService; |
||||||
|
private readonly ILogger<CollaborateursApiController> logger; |
||||||
|
private readonly IAuthorizationService authorizationService; |
||||||
|
|
||||||
|
public CollaborateursApiController(ICollaborateurService _collaborateurService, ILogger<CollaborateursApiController> _logger, IAuthorizationService _authorizationService) |
||||||
|
{ |
||||||
|
collaborateurService = _collaborateurService; |
||||||
|
logger = _logger; |
||||||
|
authorizationService = _authorizationService; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer un collaborateur par son id.</remarks> |
||||||
|
/// <param name="idCollaborateur">Id du collaborateur</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/collaborateurs/{idCollaborateur}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetCollaborateurById")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetCollaborateurById([FromRoute][Required]Guid? idCollaborateur) |
||||||
|
{ |
||||||
|
CollaborateurDTO collaborateurDTO; |
||||||
|
try |
||||||
|
{ |
||||||
|
collaborateurDTO = await collaborateurService.GetCollaborateurByIdAsync(idCollaborateur); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs" |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch (CollaborateurNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
//TODO : vérifier des cas d'erreur possible avant ?... |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur interne est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
|
||||||
|
// Si l'utilisateur connecté est un collaborateur, on vérifie si il est autorisé à accéder au détail du collaborateur |
||||||
|
if (User.IsInRole("Collaborateur")) |
||||||
|
{ |
||||||
|
//Le collaborateur récupère ses informations |
||||||
|
if (!(await authorizationService.AuthorizeAsync(User, collaborateurDTO, "SameMailRequirement")).Succeeded) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 403, |
||||||
|
Message = "Accès interdit", |
||||||
|
}; |
||||||
|
return StatusCode(403, erreurDTO); |
||||||
|
} |
||||||
|
|
||||||
|
//TODO : Le collaborateur récupère les informations d'un collaborateur dont il est référentEP |
||||||
|
|
||||||
|
//TODO : Le collaborateur récupère les informations d'un collaborateur dont il est référent de l'EP actuel |
||||||
|
} |
||||||
|
return Ok(collaborateurDTO); |
||||||
|
|
||||||
|
//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(CollaborateurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer un collaborateur par son mail.</remarks> |
||||||
|
/// <param name="mail">Mail de l'utilisateur connecté (mail obtenu via le token Keycloak)</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/collaborateurs/{mail}/mail")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetCollaborateurByMail")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetCollaborateurByMail([FromRoute][Required]string mail) |
||||||
|
{ |
||||||
|
|
||||||
|
CollaborateurDTO collaborateurDTO; |
||||||
|
try |
||||||
|
{ |
||||||
|
collaborateurDTO = await collaborateurService.GetCollaborateurByMailAsync(mail); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs" |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch (CollaborateurNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
//TODO : vérifier des cas d'erreur possible avant ?... |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur interne est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
|
||||||
|
// Si l'utilisateur connecté est un collaborateur, on vérifie si il est autorisé à accéder au détail du collaborateur |
||||||
|
if (User.IsInRole("Collaborateur")) |
||||||
|
{ |
||||||
|
//Le collaborateur récupère ses informations |
||||||
|
if (!(await authorizationService.AuthorizeAsync(User, collaborateurDTO, "SameMailRequirement")).Succeeded) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 403, |
||||||
|
Message = "Accès interdit", |
||||||
|
}; |
||||||
|
return StatusCode(403, erreurDTO); |
||||||
|
} |
||||||
|
|
||||||
|
//TODO : Le collaborateur récupère les informations d'un collaborateur dont il est référentEP |
||||||
|
|
||||||
|
//TODO : Le collaborateur récupère les informations d'un collaborateur dont il est référent de l'EP actuel |
||||||
|
} |
||||||
|
|
||||||
|
return Ok(collaborateurDTO); |
||||||
|
//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(CollaborateurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer une liste de collaborateurs.</remarks> |
||||||
|
/// <param name="roles">Liste des rôles auquels appartiennent les collaborateurs (e.g [”CP”, ”Commerciaux”,”RA”])</param> |
||||||
|
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="asc">Indique si les données sont récupérées dans l'ordre croissant ou non</param> |
||||||
|
/// <param name="numPage">Numéro de la page du tableau à afficher</param> |
||||||
|
/// <param name="parPage">Nombre d’élément maximum à afficher dans le tableau</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="tri">Colonne du tableau sur lequel le tri devra être effectué</param> |
||||||
|
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param> |
||||||
|
/// <param name="dateFin">Date jusqu'à laquelle les données sont récupérées</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/collaborateurs")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetCollaborateurs")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetCollaborateurs([FromQuery]List<string> roles, [FromQuery]List<long?> idBUs, [FromQuery]bool? asc, [FromQuery]int? numPage, [FromQuery][Range(5, 100)]int? parPage, [FromQuery]string texte, [FromQuery]string tri, [FromQuery]DateTime? dateDebut, [FromQuery]DateTime? dateFin) |
||||||
|
{ |
||||||
|
IEnumerable<CollaborateurDTO> collaborateurs; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
collaborateurs = await collaborateurService.GetCollaborateursAsync(roles, idBUs, asc, numPage, parPage, texte, tri, dateDebut, dateFin); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs" |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur interne est survenue", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
return Ok(collaborateurs); |
||||||
|
//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<CollaborateurDTO>)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des collaborateurs d’un référent.</remarks> |
||||||
|
/// <param name="idReferent">Id d'un référent</param> |
||||||
|
/// <param name="asc">Indique si les données sont récupérées dans l'ordre croissant ou non</param> |
||||||
|
/// <param name="numPage">Numéro de la page du tableau à afficher</param> |
||||||
|
/// <param name="parPage">Nombre d’élément maximum à afficher dans le tableau</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="tri">Colonne du tableau sur lequel le tri devra être effectué</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/collaborateurs/referent/{idReferent}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetCollaborateursByReferent")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetCollaborateursByReferent([FromRoute][Required]Guid? idReferent, [FromQuery]bool? asc, [FromQuery]int? numPage, [FromQuery][Range(5, 100)]int? parPage, [FromQuery]string texte, [FromQuery]string tri) |
||||||
|
{ |
||||||
|
IEnumerable<CollaborateurDTO> collaborateurs; |
||||||
|
try |
||||||
|
{ |
||||||
|
collaborateurs = await collaborateurService.GetCollaborateursByReferentAsync(idReferent, asc, numPage, parPage, texte, tri); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs" |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch (ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
//TODO : vérifier des cas d'erreur possible avant ?... |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur interne est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
return Ok(collaborateurs); |
||||||
|
|
||||||
|
//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<CollaborateurDTO>)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total de collaborateurs d’un référent.</remarks> |
||||||
|
/// <param name="idReferent">Id d'un référent</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/collaborateurs/referent/{idReferent}/count")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetCollaborateursByReferentCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetCollaborateursByReferentCount([FromRoute][Required]Guid? idReferent, [FromQuery]string texte) |
||||||
|
{ |
||||||
|
int collaborateurs; |
||||||
|
try |
||||||
|
{ |
||||||
|
collaborateurs = await collaborateurService.GetCollaborateursCountByReferentAsync(idReferent, texte); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs" |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch (ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
//TODO : vérifier des cas d'erreur possible avant ?... |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur interne est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
return Ok(collaborateurs); |
||||||
|
//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(long?)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total de collaborateurs.</remarks> |
||||||
|
/// <param name="roles">Liste des rôles auquels appartiennent les collaborateurs (e.g [”CP”, ”Commerciaux”,”RA”])</param> |
||||||
|
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param> |
||||||
|
/// <param name="dateFin">Date jusqu'à laquelle les données sont récupérées</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/collaborateurs/count")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetCollaborateursCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetCollaborateursCount([FromQuery]List<string> roles, [FromQuery]List<long?> idBUs, [FromQuery]string texte, [FromQuery]DateTime? dateDebut, [FromQuery]DateTime? dateFin) |
||||||
|
{ |
||||||
|
int collaborateurs; |
||||||
|
try |
||||||
|
{ |
||||||
|
collaborateurs = await collaborateurService.GetCollaborateursCountAsync(roles, idBUs, texte, dateDebut, dateFin); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs" |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
//TODO : vérifier des cas d'erreur possible avant ?... |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur interne est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
return Ok(collaborateurs); |
||||||
|
//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(long?)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des référents des précédents EP du collaborateur.</remarks> |
||||||
|
/// <param name="idCollaborateur">Id du collaborateur</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/collaborateurs/{idCollaborateur}/ep/referents")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetReferentsPrecedentEPCollaborateur")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetReferentsPrecedentEPCollaborateur([FromRoute][Required]Guid? idCollaborateur) |
||||||
|
{ |
||||||
|
IEnumerable<CollaborateurDTO> referents = null; |
||||||
|
try |
||||||
|
{ |
||||||
|
referents = await collaborateurService.GetReferentsPrecedentsEPAsync(idCollaborateur); |
||||||
|
} |
||||||
|
catch (CollaborateurNotFoundException e) { |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs" |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
//TODO : vérifier des cas d'erreur possible avant ?... |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur interne est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
return Ok(referents); |
||||||
|
//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<CollaborateurDTO>)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,223 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class DemandesDelegationApiController : ControllerBase |
||||||
|
{ |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Services des demandes de délégation |
||||||
|
/// </summary> |
||||||
|
private readonly IDemandeDelegationService demandeDelegationService; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Logger du contrôleur |
||||||
|
/// </summary> |
||||||
|
private readonly ILogger<DemandesDelegationApiController> logger; |
||||||
|
|
||||||
|
public DemandesDelegationApiController(IDemandeDelegationService _demandeDelegationService, ILogger<DemandesDelegationApiController> _logger) |
||||||
|
{ |
||||||
|
demandeDelegationService = _demandeDelegationService; |
||||||
|
logger = _logger; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des demandes de délégation d’un référent.</remarks> |
||||||
|
/// <param name="idReferent">Id d'un référent</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/demandesdelegation/referent/{idReferent}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetDemandesDelegationReferent")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeDelegationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetDemandesDelegationReferent([FromRoute][Required]Guid? idReferent) |
||||||
|
{ |
||||||
|
IEnumerable<DemandeDelegationDTO> demandeDelegations; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
demandeDelegations = await demandeDelegationService.RecupererDemandesDelegation(idReferent); |
||||||
|
} |
||||||
|
catch (ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
return Ok(demandeDelegations); |
||||||
|
|
||||||
|
//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<DemandeDelegationDTO>)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Répondre à une demande de délégation.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idDemandeDelegation">Id d'une demande delegation</param> |
||||||
|
/// <response code="200">Demande de délégation mise à jour avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/demandesdelegation/{idDemandeDelegation}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateDemandeDelegation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(DemandeDelegationDTO), description: "Demande de délégation mise à jour avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> UpdateDemandeDelegation([FromBody]DemandeDelegationDTO body, [FromRoute][Required]long? idDemandeDelegation) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
body = await demandeDelegationService.UpdateDemandeDelegation(idDemandeDelegation, body); |
||||||
|
} |
||||||
|
catch (DemandeDelegationIncompatibleException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DemandeDelegationInvalidException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DemandeDelegationNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
return Ok(body); |
||||||
|
//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(DemandeDelegationDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,440 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class DemandesEPIApiController : ControllerBase |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Effectuer la création d’une demande d’EPI par l'assistant ou bien un responsable d'agence.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <response code="201">Demande d'EPI créée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPost] |
||||||
|
[Route("/api/demandesepi/demande/assistant")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("AddDemandeEpiAssistant")] |
||||||
|
[SwaggerResponse(statusCode: 201, type: typeof(DemandeEPIDTO), description: "Demande d'EPI créée avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult AddDemandeEpiAssistant([FromBody]DemandeEPIDTO 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, default(DemandeEPIDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "{\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<DemandeEPIDTO>(exampleJson) |
||||||
|
: default(DemandeEPIDTO); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Effectuer la création d’une demande d’EPI par le collaborateur.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <response code="201">Demande d'EPI créée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPost] |
||||||
|
[Route("/api/demandesepi/demande/collaborateur")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("AddDemandeEpiCollaborateur")] |
||||||
|
[SwaggerResponse(statusCode: 201, type: typeof(DemandeEPIDTO), description: "Demande d'EPI créée avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult AddDemandeEpiCollaborateur([FromBody]DemandeEPIDTO 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, default(DemandeEPIDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "{\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<DemandeEPIDTO>(exampleJson) |
||||||
|
: default(DemandeEPIDTO); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Effectuer la création d’une demande d’EPI par le référent.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <response code="201">Demande d'EPI créée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPost] |
||||||
|
[Route("/api/demandesepi/demande/referent")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("AddDemandeEpiReferent")] |
||||||
|
[SwaggerResponse(statusCode: 201, type: typeof(DemandeEPIDTO), description: "Demande d'EPI créée avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult AddDemandeEpiReferent([FromBody]DemandeEPIDTO 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, default(DemandeEPIDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "{\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<DemandeEPIDTO>(exampleJson) |
||||||
|
: default(DemandeEPIDTO); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Annuler une demande d’EPI.</remarks> |
||||||
|
/// <param name="idDemandeEPI">Id d'une demande d'EPI</param> |
||||||
|
/// <response code="204">Demande annulée</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpDelete] |
||||||
|
[Route("/api/demandesepi/{idDemandeEPI}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("DeleteDemandeEPI")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult DeleteDemandeEPI([FromRoute][Required]long? idDemandeEPI) |
||||||
|
{ |
||||||
|
//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 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
|
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des demandes d’EPI d’un collaborateur.</remarks> |
||||||
|
/// <param name="idCollaborateur">Id du collaborateur</param> |
||||||
|
/// <param name="etatsDemande">Liste des états des demandes à afficher</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/demandesepi/collaborateur/{idCollaborateur}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetDemandeEPICollaborateur")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeEPIDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult GetDemandeEPICollaborateur([FromRoute][Required]Guid? idCollaborateur, [FromQuery]List<EtatDemande> etatsDemande) |
||||||
|
{ |
||||||
|
//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<DemandeEPIDTO>)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "[ {\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}, {\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n} ]"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<List<DemandeEPIDTO>>(exampleJson) |
||||||
|
: default(List<DemandeEPIDTO>); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total de demandes d’EPI d’un collaborateur.</remarks> |
||||||
|
/// <param name="idCollaborateur">Id du collaborateur</param> |
||||||
|
/// <param name="etatsDemande">Liste des états des demandes à afficher</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/demandesepi/collaborateur/{idCollaborateur}/count")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetDemandeEPICollaborateurCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult GetDemandeEPICollaborateurCount([FromRoute][Required]Guid? idCollaborateur, [FromQuery]List<EtatDemande> etatsDemande) |
||||||
|
{ |
||||||
|
//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(long?)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "0"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<long?>(exampleJson) |
||||||
|
: default(long?); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des demandes d’EPI qu’un référent a reçu.</remarks> |
||||||
|
/// <param name="idReferent">Id d'un référent</param> |
||||||
|
/// <param name="etatsDemande">Liste des états des demandes à afficher</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/demandesepi/referent/{idReferent}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetDemandeEPIReferent")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeEPIDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult GetDemandeEPIReferent([FromRoute][Required]Guid? idReferent, [FromQuery]List<EtatDemande> etatsDemande) |
||||||
|
{ |
||||||
|
//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<DemandeEPIDTO>)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "[ {\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}, {\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n} ]"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<List<DemandeEPIDTO>>(exampleJson) |
||||||
|
: default(List<DemandeEPIDTO>); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total de demandes d’EPI qu’un référent a reçu.</remarks> |
||||||
|
/// <param name="idReferent">Id d'un référent</param> |
||||||
|
/// <param name="etatsDemande">Liste des états des demandes à afficher</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/demandesepi/referent/{idReferent}/count")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetDemandeEPIReferentCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult GetDemandeEPIReferentCount([FromRoute][Required]Guid? idReferent, [FromQuery]List<EtatDemande> etatsDemande) |
||||||
|
{ |
||||||
|
//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(long?)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "0"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<long?>(exampleJson) |
||||||
|
: default(long?); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Répondre à une demande d’EPI.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idDemandeEPI">Id d'une demande d'EPI</param> |
||||||
|
/// <response code="200">Demande mise à jour</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/demandesepi/{idDemandeEPI}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateDemandeEPI")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(DemandeEPIDTO), description: "Demande mise à jour")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual IActionResult UpdateDemandeEPI([FromBody]DemandeEPIDTO body, [FromRoute][Required]long? idDemandeEPI) |
||||||
|
{ |
||||||
|
//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(DemandeEPIDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
string exampleJson = null; |
||||||
|
exampleJson = "{\n \"raisonRefus\" : \"raisonRefus\",\n \"dateReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 8,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\"\n}"; |
||||||
|
|
||||||
|
var example = exampleJson != null |
||||||
|
? JsonConvert.DeserializeObject<DemandeEPIDTO>(exampleJson) |
||||||
|
: default(DemandeEPIDTO); //TODO: Change the data returned |
||||||
|
return new ObjectResult(example); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,494 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using Microsoft.AspNetCore.Http; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class DemandesFormationApiController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly IDemandeFormationService demandeFormationService; |
||||||
|
private readonly ILogger<DemandesFormationApiController> logger; |
||||||
|
private readonly IWebHostEnvironment env; |
||||||
|
|
||||||
|
public DemandesFormationApiController(IDemandeFormationService _demandeFormationService, ILogger<DemandesFormationApiController> _logger, IWebHostEnvironment _env) |
||||||
|
{ |
||||||
|
demandeFormationService = _demandeFormationService; |
||||||
|
logger = _logger; |
||||||
|
env = _env; |
||||||
|
|
||||||
|
} |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Créer demande de formation pour un collaborateur.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <response code="201">Demande formation créée</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPost] |
||||||
|
[Route("/api/demandesformation")] |
||||||
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("AddDemandeFormation")] |
||||||
|
[SwaggerResponse(statusCode: 201, type: typeof(DemandeFormationDTO), description: "Demande formation créée")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> AddDemandeFormation([FromBody] DemandeFormationDTO body) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Ajout d'une nouvelle demande de formation."); |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
body = await demandeFormationService.AddDemandeFormationAsync(body); |
||||||
|
} |
||||||
|
catch (DemandeFormationInvalidException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de l'ajout de la demande de formation.", |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur.", |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Nouvelle demande de formation ajoutée."); |
||||||
|
|
||||||
|
return Created("", body); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Supprimer une demande de formation.</remarks> |
||||||
|
/// <param name="idDemandeFormation">Id d'une demande de formation</param> |
||||||
|
/// <response code="204">Demande de formation supprimée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpDelete] |
||||||
|
[Route("/api/demandesformation/{idDemandeFormation}")] |
||||||
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("DeleteDemandeFormation")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> DeleteDemandeFormation([FromRoute][Required] long idDemandeFormation) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Suppression de la demande de formation {idDemandeFormation}.", idDemandeFormation); |
||||||
|
|
||||||
|
bool demandeFormationSupprimee = await demandeFormationService.DeleteDemandeFormationAsync(idDemandeFormation); |
||||||
|
} |
||||||
|
catch (DemandeFormationNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (DemandeFormationInvalidException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = string.Format("La demande de formation {0} n'a pas pu être supprimée car elle est prise par une autre ressource.", idDemandeFormation) |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de la suppression de la demande de formation." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Demande de formation {idDemandeFormation} supprimée avec succès.", idDemandeFormation); |
||||||
|
|
||||||
|
return NoContent(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des demandes de formation.</remarks> |
||||||
|
/// <param name="etatsDemande">Liste des états des demandes à afficher</param> |
||||||
|
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="statutsEp">Liste des statuts d'EP auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="asc">Indique si les données sont récupérées dans l'ordre croissant ou non</param> |
||||||
|
/// <param name="numPage">Numéro de la page du tableau à afficher</param> |
||||||
|
/// <param name="parPAge">Nombre d’élément maximum à afficher dans le tableau</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="tri">Colonne du tableau sur lequel le tri devra être effectué</param> |
||||||
|
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param> |
||||||
|
/// <param name="dateFin">Date jusqu'à laquelle les données sont récupérées</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/demandesformation")] |
||||||
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetDemandesFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeFormationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetDemandesFormation([FromQuery] List<EtatDemande> etatsDemande, [FromQuery] List<long?> idBUs, [FromQuery] List<StatutEp> statutsEp, [FromQuery] bool? asc, [FromQuery] int? numPage, [FromQuery][Range(5, 100)] int? parPAge, [FromQuery] string texte, [FromQuery] string tri, [FromQuery] DateTime? dateDebut, [FromQuery] DateTime? dateFin) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des demandes de formation."); |
||||||
|
|
||||||
|
IEnumerable<DemandeFormationDTO> demandeFormations; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
demandeFormations = await demandeFormationService.GetDemandesFormationAsync(etatsDemande, idBUs, statutsEp, asc, numPage, parPAge, texte, tri, dateDebut, dateFin); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des demandes de formation récupérée."); |
||||||
|
|
||||||
|
return Ok(demandeFormations); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total de demandes de formation.</remarks> |
||||||
|
/// <param name="etatsDemande">Liste des états des demandes à afficher</param> |
||||||
|
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="statutsEp">Liste des statuts d'EP auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param> |
||||||
|
/// <param name="dateFin">Date jusqu'à laquelle les données sont récupérées</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/demandesformation/count")] |
||||||
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetDemandesFormationCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetDemandesFormationCount([FromQuery] List<EtatDemande> etatsDemande, [FromQuery] List<long?> idBUs, [FromQuery] List<StatutEp> statutsEp, [FromQuery] string texte, [FromQuery] DateTime? dateDebut, [FromQuery] DateTime? dateFin) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération du nombre total de demandes de formation."); |
||||||
|
|
||||||
|
long count; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
count = await demandeFormationService.GetDemandesFormationCountAsync(etatsDemande, idBUs, statutsEp, texte, dateDebut, dateFin); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Nombre total de demandes de formation récupéré."); |
||||||
|
|
||||||
|
return Ok(count); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des origines des demandes de formation.</remarks> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/originesdemandeformation")] |
||||||
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetOriginesDemandeFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<OrigineDemandeFormationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetOriginesDemandeFormation() |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des origines de demande de formation."); |
||||||
|
|
||||||
|
IEnumerable<OrigineDemandeFormationDTO> origineDemandes; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
origineDemandes = await demandeFormationService.GetOriginesDemandeFormationAsync(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des origines de demande de formation récupérée."); |
||||||
|
|
||||||
|
return Ok(origineDemandes); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Répondre à une demande de formation.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idDemandeFormation">Id d'une demande de formation</param> |
||||||
|
/// <response code="200">demande formation mise à jour</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/demandesformation/{idDemandeFormation}")] |
||||||
|
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateDemandeFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(DemandeFormationDTO), description: "demande formation mise à jour")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> UpdateDemandeFormation([FromBody] DemandeFormationDTO body, [FromRoute][Required] long idDemandeFormation) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Mise à jour de la demande de formation d'id {idDemandeFormation}.", idDemandeFormation); |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
body = await demandeFormationService.UpdateDemandeFormationAsync(idDemandeFormation, body); |
||||||
|
} |
||||||
|
catch (DemandeFormationInvalidException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (DemandeFormationIncompatibleIdException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (DemandeFormationNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = string.Format("La demande de formation {0} n'a pas pu être mise à jour car elle est prise par une autre ressource.", idDemandeFormation) |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de la mise à jour de la demande de formation." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Update effectué avec succès"); |
||||||
|
|
||||||
|
return Ok(body); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,270 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using IO.Swagger.Enum; |
||||||
|
using EPAServeur.Attributes; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using Microsoft.AspNetCore.Http; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class EngagementsApiController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly IEngagementService engagementService; |
||||||
|
private readonly ILogger<EngagementsApiController> logger; |
||||||
|
private readonly IWebHostEnvironment env; |
||||||
|
|
||||||
|
public EngagementsApiController(IEngagementService _engagementService, ILogger<EngagementsApiController> _logger, IWebHostEnvironment _env) |
||||||
|
{ |
||||||
|
engagementService = _engagementService; |
||||||
|
logger = _logger; |
||||||
|
env = _env; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des engagements.</remarks> |
||||||
|
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="etatsEngagement">Etats de l'engagement</param> |
||||||
|
/// <param name="asc">Indique si les données sont récupérées dans l'ordre croissant ou non</param> |
||||||
|
/// <param name="numPage">Numéro de la page du tableau à afficher</param> |
||||||
|
/// <param name="parPage">Nombre d’élément maximum à afficher dans le tableau</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="tri">Colonne du tableau sur lequel le tri devra être effectué</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/engagements")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetEngagements")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetEngagements([FromQuery][CannotBeEmpty] List<long> idBUs, [FromQuery]List<EtatEngagement> etatsEngagement, [FromQuery]bool? asc, [FromQuery]int? numPage, [FromQuery][Range(5, 100)]int? parPage, [FromQuery]string texte, [FromQuery]string tri) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des engagements."); |
||||||
|
|
||||||
|
IEnumerable<EngagementDTO> engagements; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
engagements = await engagementService.GetEngagementsAsync(idBUs, etatsEngagement, asc, numPage, parPage, texte, tri); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des engagements récupérée."); |
||||||
|
|
||||||
|
return Ok(engagements); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total d’engagements.</remarks> |
||||||
|
/// <param name="idBUs">liste des ids des BU auxquelles les données sont rattachées</param> |
||||||
|
/// <param name="etatsEngagement">Etats de l'engagement</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/engagements/count")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetEngagementsCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetEngagementsCount([FromQuery][CannotBeEmpty]List<long> idBUs, [FromQuery]List<EtatEngagement> etatsEngagement, [FromQuery]string texte) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération du nombre total d'engagements."); |
||||||
|
|
||||||
|
long count; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
count = await engagementService.GetEngagementsCountAsync(idBUs, etatsEngagement, texte); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Nombre total d'engagement récupéré."); |
||||||
|
|
||||||
|
return Ok(count); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Répondre à un engagement.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idEngagement">Id d'un engagement</param> |
||||||
|
/// <response code="200">Engagement modifié avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/engagements/{idEngagement}")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateEngagement")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(EngagementDTO), description: "Engagement modifié avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> UpdateEngagement([FromBody]EngagementDTO body, [FromRoute][Required]long idEngagement) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Mise à jour de l'engagement d'id {idEngagement}.", idEngagement); |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
body = await engagementService.RepondreEngagementAsync(body, idEngagement); |
||||||
|
} |
||||||
|
catch (EngagementInvalidException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (EngagementIncompatibleIdException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (EngagementNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = string.Format("L'engagement {0} n'a pas pu être mise à jour car il est pris par une autre ressource.", idEngagement) |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de la mise à jour de l'engagement." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Update effectué avec succès."); |
||||||
|
|
||||||
|
return Ok(body); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,681 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using System.ComponentModel; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using Microsoft.AspNetCore.Http; |
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class FormationsApiController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly IFormationService formationService; |
||||||
|
private readonly ILogger<FormationsApiController> logger; |
||||||
|
private readonly IWebHostEnvironment env; |
||||||
|
|
||||||
|
public FormationsApiController(IFormationService _formationService, ILogger<FormationsApiController> _logger, IWebHostEnvironment _env) |
||||||
|
{ |
||||||
|
formationService = _formationService; |
||||||
|
logger = _logger; |
||||||
|
env = _env; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Créer une nouvelle formation.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <response code="201">Formation créée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPost] |
||||||
|
[Route("/api/formations")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("AddFormation")] |
||||||
|
[SwaggerResponse(statusCode: 201, type: typeof(FormationDTO), description: "Formation créée avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> AddFormation([FromBody] FormationDTO body) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Ajout d'une nouvelle formation."); |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
body = await formationService.AddFormationAsync(body); |
||||||
|
} |
||||||
|
catch (FormationInvalidException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de l'ajout de la formation.", |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur.", |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Nouvelle formation ajoutée."); |
||||||
|
|
||||||
|
return Created("", body); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Supprimer une formation par son id.</remarks> |
||||||
|
/// <param name="idFormation">Id d'une formation</param> |
||||||
|
/// <response code="204">Formation supprimée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpDelete] |
||||||
|
[Route("/api/formations/{idFormation}")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("DeleteFormation")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> DeleteFormation([FromRoute][Required] long idFormation) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Suppresion de la formation {idFormation}.", idFormation); |
||||||
|
|
||||||
|
FormationDTO formation = await formationService.DeleteFormationByIdAsync(idFormation); |
||||||
|
} |
||||||
|
catch (FormationNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = string.Format("La formation {0} n'a pas pu être supprimée car elle est prise par une autre ressource.", idFormation) |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de la suppression de la formation." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Formation {idFormation} supprimée avec succès.", idFormation); |
||||||
|
|
||||||
|
return NoContent(); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer une formation par son id.</remarks> |
||||||
|
/// <param name="idFormation">Id d'une formation</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/formations/{idFormation}")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetFormationById")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(FormationDTO), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetFormationById([FromRoute][Required] long idFormation) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la formation {idFormation}.", idFormation); |
||||||
|
|
||||||
|
FormationDTO formationDTO; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
formationDTO = await formationService.GetFormationByIdAsync(idFormation); |
||||||
|
} |
||||||
|
catch (FormationNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Formation {idFormation} récupérée.", idFormation); |
||||||
|
|
||||||
|
return Ok(formationDTO); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des formations.</remarks> |
||||||
|
/// <param name="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
||||||
|
/// <param name="idStatuts">liste des ids des statuts des formations à récupérer</param> |
||||||
|
/// <param name="asc">Indique si les données sont récupérées dans l'ordre croissant ou non</param> |
||||||
|
/// <param name="numPage">Numéro de la page du tableau à afficher</param> |
||||||
|
/// <param name="parPage">Nombre d’élément maximum à afficher dans le tableau</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="tri">Colonne du tableau sur lequel le tri devra être effectué</param> |
||||||
|
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param> |
||||||
|
/// <param name="dateFin">Date jusqu'à laquelle les données sont récupérées</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/formations")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetFormations")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<FormationDetailsDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetFormations([FromQuery] long? idAgence, [FromQuery] List<int?> idStatuts, [FromQuery] bool? asc, [FromQuery] int? numPage, [FromQuery][Range(5, 100)][DefaultValue(15)] int? parPage, [FromQuery] string texte, [FromQuery] string tri, [FromQuery] DateTime? dateDebut, [FromQuery] DateTime? dateFin) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des formations."); |
||||||
|
|
||||||
|
IEnumerable<FormationDetailsDTO> formations; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
formations = await formationService.GetFormationsAsync(idAgence, idStatuts, asc, numPage, parPage, texte, tri, dateDebut, dateFin); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des formations récupérée."); |
||||||
|
|
||||||
|
return Ok(formations); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total de formations.</remarks> |
||||||
|
/// <param name="idAgence">id de l'agence à laquelle sont rattachées les données à récupérer</param> |
||||||
|
/// <param name="idStatuts">liste des ids des statuts des formations à récupérer</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="dateDebut">Date à partir de laquelle les données son récupérées</param> |
||||||
|
/// <param name="dateFin">Date jusqu'à laquelle les données sont récupérées</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/formations/count")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetFormationsCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetFormationsCount([FromQuery] long? idAgence, [FromQuery] List<int?> idStatuts, [FromQuery] string texte, [FromQuery] DateTime? dateDebut, [FromQuery] DateTime? dateFin) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération du nombre total de formations."); |
||||||
|
|
||||||
|
long count; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
count = await formationService.GetFormationsCountAsync(idAgence, idStatuts, texte, dateDebut, dateFin); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Nombre total de formations récupéré."); |
||||||
|
|
||||||
|
return Ok(count); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des modes de formation.</remarks> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/modesformation")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetModesFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<ModeFormationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetModesFormation() |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des modes de formation."); |
||||||
|
|
||||||
|
IEnumerable<ModeFormationDTO> modeFormations; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
modeFormations = await formationService.GetModesFormationAsync(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des modes de formation récupérée."); |
||||||
|
|
||||||
|
return Ok(modeFormations); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des origines de formation.</remarks> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/originesformation")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetOriginesFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<OrigineFormationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetOriginesFormation() |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des origines de formation."); |
||||||
|
|
||||||
|
IEnumerable<OrigineFormationDTO> origineFormations; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
origineFormations = await formationService.GetOriginesFormationAsync(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des origines de formation récupérée."); |
||||||
|
|
||||||
|
return Ok(origineFormations); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des statuts de formation.</remarks> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/statutsformation")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetStatutsFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<StatutFormationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetStatutsFormation() |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des statuts de formation."); |
||||||
|
|
||||||
|
IEnumerable<StatutFormationDTO> statutFormations; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
statutFormations = await formationService.GetStatutsFormationAsync(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des statuts de formation récupérée."); |
||||||
|
|
||||||
|
return Ok(statutFormations); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des types de formation.</remarks> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/typesformation")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetTypesFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<TypeFormationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetTypesFormation() |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des types de formation."); |
||||||
|
|
||||||
|
IEnumerable<TypeFormationDTO> typeFormations; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
typeFormations = await formationService.GetTypesFormationAsync(); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des types de formation récupérée."); |
||||||
|
|
||||||
|
return Ok(typeFormations); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Mettre à jour une formation.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idFormation">Id d'une formation</param> |
||||||
|
/// <response code="200">formation mise à jour</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/formations/{idFormation}")] |
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "RH")] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateFormation")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> UpdateFormation([FromBody] FormationDTO body, [FromRoute][Required] long idFormation) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Mise à jour de la formation d'id {idFormation}.", idFormation); |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
body = await formationService.UpdateFormationAsync(idFormation, body); |
||||||
|
} |
||||||
|
catch (FormationIncompatibleIdException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (FormationInvalidException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (FormationNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = string.Format("La formation {0} n'a pas pu être mise à jour car elle est prise par une autre ressource.", idFormation) |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de la mise à jour de la formation." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Update effectué avec succès"); |
||||||
|
|
||||||
|
return Ok(body); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,566 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using IO.Swagger.ClientCollaborateur; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
using System.Threading.Tasks; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class NotesApiController : ControllerBase |
||||||
|
{ |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Service des note |
||||||
|
/// </summary> |
||||||
|
private readonly INoteService noteService; |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Logger du contrôleur |
||||||
|
/// </summary> |
||||||
|
private readonly ILogger<NotesApiController> logger; |
||||||
|
|
||||||
|
public NotesApiController(INoteService _noteService, ILogger<NotesApiController> _logger) |
||||||
|
{ |
||||||
|
noteService = _noteService; |
||||||
|
logger = _logger; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Créer une nouvelle note.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <response code="201">Note créée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPost] |
||||||
|
[Route("/api/notes/")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("AddNote")] |
||||||
|
[SwaggerResponse(statusCode: 201, type: typeof(DetailsNoteDTO), description: "Note créée avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> AddNote([FromBody]DetailsNoteDTO body) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
body = await noteService.AjouterNoteAsync(body); |
||||||
|
} |
||||||
|
catch(ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des données collaborateurs", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch(NoteInvalideException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch(ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch(CollaborateurNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch(CollaborateurPartiException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value,erreur); |
||||||
|
} |
||||||
|
catch(DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
return Created("",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, default(DetailsNoteDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Supprimer une note.</remarks> |
||||||
|
/// <param name="idNote">Id d'une note</param> |
||||||
|
/// <response code="204">Note supprimée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpDelete] |
||||||
|
[Route("/api/notes/{idNote}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("DeleteNote")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> DeleteNote([FromRoute][Required]long? idNote) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
await noteService.SupprimerNoteAsync(idNote); |
||||||
|
} |
||||||
|
catch(NoteNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch(DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la suppression" |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur inconnue est survenue" |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
return NoContent(); |
||||||
|
//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 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer une note par son id.</remarks> |
||||||
|
/// <param name="idNote">Id d'une note</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/notes/{idNote}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetNoteById")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(DetailsNoteDTO), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetNoteById([FromRoute][Required]long? idNote) |
||||||
|
{ |
||||||
|
DetailsNoteDTO note; |
||||||
|
try |
||||||
|
{ |
||||||
|
note = await noteService.GetNoteByIdAsync(idNote); |
||||||
|
} |
||||||
|
catch(ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (CollaborateurNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (NoteNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur inconnue est survenue", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
return Ok(note); |
||||||
|
//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 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer les notes d’un auteur.</remarks> |
||||||
|
/// <param name="idAuteur">Id de l'auteur</param> |
||||||
|
/// <param name="asc">Indique si les données sont récupérées dans l'ordre croissant ou non</param> |
||||||
|
/// <param name="numPage">Numéro de la page du tableau à afficher</param> |
||||||
|
/// <param name="parPage">Nombre d’élément maximum à afficher dans le tableau</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <param name="tri">Colonne du tableau sur lequel le tri devra être effectué</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/notes/auteur/{idAuteur}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetNotesAuteur")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<AffichageNoteDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetNotesAuteur([FromRoute][Required]Guid? idAuteur, [FromQuery]bool? asc, [FromQuery]int? numPage, [FromQuery][Range(5, 100)]int? parPage, [FromQuery]string texte, [FromQuery]string tri) |
||||||
|
{ |
||||||
|
IEnumerable<AffichageNoteDTO> affichageNotes; |
||||||
|
try |
||||||
|
{ |
||||||
|
affichageNotes = await noteService.GetNotesByAuteurAsync(idAuteur, asc, numPage, parPage, texte, tri); |
||||||
|
//affichageNotes = noteService.GetNotesByAuteur(idAuteur, asc, numPage, parPage, texte, tri); |
||||||
|
} |
||||||
|
catch(ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch(ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des informations collaborateurs", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
//Message = "Une erreur inconnue est survenue", |
||||||
|
Message = e.StackTrace, |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
return Ok(affichageNotes); |
||||||
|
//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>)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer le nombre total de notes d’un auteur.</remarks> |
||||||
|
/// <param name="idAuteur">Id de l'auteur</param> |
||||||
|
/// <param name="texte">Texte permettant de filtrer les données</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/notes/auteur/{idAuteur}/count")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetNotesAuteurCount")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetNotesAuteurCount([FromRoute][Required]Guid? idAuteur, [FromQuery]string texte) |
||||||
|
{ |
||||||
|
int notes; |
||||||
|
try |
||||||
|
{ |
||||||
|
notes = await noteService.GetNotesByAuteurCountAsync(idAuteur, texte); |
||||||
|
} |
||||||
|
catch(ApiException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue lors de la récupération des informations collaborateurs", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
catch(ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch(Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur inconnue es survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreurDTO); |
||||||
|
} |
||||||
|
return Ok(notes); |
||||||
|
//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(long?)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Modifier une note.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idNote">Id d'une note</param> |
||||||
|
/// <response code="200">Note modifiée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/notes/{idNote}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateNote")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(DetailsNoteDTO), description: "Note modifiée avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> UpdateNote([FromBody]DetailsNoteDTO body, [FromRoute][Required]long? idNote) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
body = await noteService.UpdateNoteAsync(idNote, body); |
||||||
|
} |
||||||
|
catch(NoteIdImcompatibleException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
}catch(NoteInvalideException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
return Ok(body); |
||||||
|
//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 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,276 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using Microsoft.AspNetCore.Hosting; |
||||||
|
using Microsoft.Extensions.Hosting; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using Microsoft.AspNetCore.Http; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class ParticipationsFormationsApiController : ControllerBase |
||||||
|
{ |
||||||
|
private readonly IParticipationFormationService participationFormationService; |
||||||
|
private readonly ILogger<ParticipationsFormationsApiController> logger; |
||||||
|
private readonly IWebHostEnvironment env; |
||||||
|
|
||||||
|
public ParticipationsFormationsApiController(IParticipationFormationService _participationFormationService, ILogger<ParticipationsFormationsApiController> _logger, IWebHostEnvironment _env) |
||||||
|
{ |
||||||
|
participationFormationService = _participationFormationService; |
||||||
|
logger = _logger; |
||||||
|
env = _env; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Evaluer une formation.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idParticipationFormation">Id d'une participation formation</param> |
||||||
|
/// <response code="200">Evaluation envoyée avec succès</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/participationsformation/{idParticipationFormation}/evaluation")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("EvaluerFormation")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(EvaluationDTO), description: "Evaluation envoyée avec succès")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> EvaluerFormation([FromBody]EvaluationDTO body, [FromRoute][Required]long idParticipationFormation) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Mise à jour de la participation à la formation d'id {idParticipationFormation}.", idParticipationFormation); |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
body = await participationFormationService.EvaluerFormationAsync(idParticipationFormation, body); |
||||||
|
} |
||||||
|
catch (ParticipationFormationIncompatibleIdException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (ParticipationFormationInvalidException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status415UnsupportedMediaType, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur.Message); |
||||||
|
} |
||||||
|
catch (ParticipationFormationNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = string.Format("La participation à la formation {0} n'a pas pu être mise à jour car elle est prise par une autre ressource.", idParticipationFormation) |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur est survenue sur le serveur lors de la mise à jour de la participation à la formation." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Update effectué avec succès"); |
||||||
|
|
||||||
|
return Ok(body); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer une évaluation faite par un collaborateur.</remarks> |
||||||
|
/// <param name="idParticipationFormation">Id d'une participation formation</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/participationsformation/{idParticipationFormation}/evaluation")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetEvaluationCollaborateur")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(EvaluationDTO), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetEvaluationCollaborateur([FromRoute][Required]long idParticipationFormation) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la participation à la formation {idParticipationFormation}.", idParticipationFormation); |
||||||
|
|
||||||
|
EvaluationDTO evaluationDTO; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
evaluationDTO = await participationFormationService.GetEvaluationCollaborateurAsync(idParticipationFormation); |
||||||
|
} |
||||||
|
catch (ParticipationFormationNotFoundException e) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreurDTO = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status404NotFound, |
||||||
|
Message = e.Message |
||||||
|
}; |
||||||
|
|
||||||
|
return NotFound(erreurDTO); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Participation à la formation {idParticipationFormation} récupérée.", idParticipationFormation); |
||||||
|
|
||||||
|
return Ok(evaluationDTO); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Récupérer la liste des participations de formation d’un collaborateur.</remarks> |
||||||
|
/// <param name="idCollaborateur">Id du collaborateur</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpGet] |
||||||
|
[Route("/api/participationsformation/{idCollaborateur}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("GetParticipationByCollaborateur")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(List<ParticipationFormationDTO>), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> GetParticipationsByCollaborateur([FromRoute][Required]Guid idCollaborateur) |
||||||
|
{ |
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Récupération de la liste des particicaptions aux formations d'un collaborateur."); |
||||||
|
|
||||||
|
IEnumerable<ParticipationFormationDTO> participationFormationDTOs; |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
participationFormationDTOs = await participationFormationService.GetParticipationsByCollaborateurAsync(idCollaborateur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError(e.Message); |
||||||
|
|
||||||
|
ErreurDTO erreur = new ErreurDTO() |
||||||
|
{ |
||||||
|
Code = StatusCodes.Status500InternalServerError, |
||||||
|
Message = "Une erreur inconnue est survenue sur le serveur." |
||||||
|
}; |
||||||
|
|
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
|
||||||
|
if (env.IsDevelopment()) |
||||||
|
logger.LogInformation("Liste des particicaptions aux formations d'un collaborateur récupérée."); |
||||||
|
|
||||||
|
return Ok(participationFormationDTOs); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,323 @@ |
|||||||
|
/* |
||||||
|
* API du serveur de l'application de digitalisation des EP |
||||||
|
* |
||||||
|
* 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.6 |
||||||
|
* |
||||||
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Microsoft.AspNetCore.Mvc; |
||||||
|
using Swashbuckle.AspNetCore.Annotations; |
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||||
|
using Newtonsoft.Json; |
||||||
|
using System.ComponentModel.DataAnnotations; |
||||||
|
using IO.Swagger.Attributes; |
||||||
|
using IO.Swagger.Security; |
||||||
|
using Microsoft.AspNetCore.Authorization; |
||||||
|
using IO.Swagger.DTO; |
||||||
|
using EPAServeur.IServices; |
||||||
|
using Microsoft.Extensions.Logging; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using EPAServeur.Exceptions; |
||||||
|
using IO.Swagger.ClientCollaborateur; |
||||||
|
using Microsoft.EntityFrameworkCore; |
||||||
|
|
||||||
|
namespace IO.Swagger.Controllers |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
[ApiController] |
||||||
|
public class ReferentsEPApiController : ControllerBase |
||||||
|
{ |
||||||
|
|
||||||
|
private readonly IReferentEPService referentEPService; |
||||||
|
private readonly ILogger<ReferentsEPApiController> logger; |
||||||
|
|
||||||
|
|
||||||
|
public ReferentsEPApiController(IReferentEPService _referentEPService, ILogger<ReferentsEPApiController> _logger) |
||||||
|
{ |
||||||
|
referentEPService = _referentEPService; |
||||||
|
logger = _logger; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Mettre à jour les collaborateurs d'un référent.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idReferent">Id d'un référent</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/referentsep/referent/{idReferent}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateCollaborateursReferent")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(ReferentEPDTO), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> UpdateCollaborateursReferent([FromBody]ReferentEPDTO body, [FromRoute][Required]Guid? idReferent) |
||||||
|
{ |
||||||
|
|
||||||
|
try |
||||||
|
{ |
||||||
|
body = await referentEPService.UpdateCollaborateursReferentAsync(body, idReferent); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO(); |
||||||
|
if (e.ErrorCode == 415) |
||||||
|
{ |
||||||
|
erreur.Code = 415; |
||||||
|
erreur.Message = e.Message; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
erreur.Code = 500; |
||||||
|
erreur.Message = "Un erreur est survenue lors de la communication avec le serveur distant"; |
||||||
|
} |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (ReferentIncompatibleException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (ListeIdsCollaborateursVideException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (CollaborateurPartiException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 4, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (CollaborateurNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Les données n'ont pas pu être mise à jour car elles ont été modifiés avant votre mise à jour", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError("Une erreur est survenue avec la base de données" + e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError("Une erreur inconnue est survenue :" + e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur incconue est survenue", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
return Ok(body); |
||||||
|
//catch() { } |
||||||
|
//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(ReferentEPDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// |
||||||
|
/// </summary> |
||||||
|
/// <remarks>Mettre à jour le référent d'un collaborateur.</remarks> |
||||||
|
/// <param name="body"></param> |
||||||
|
/// <param name="idCollaborateur">Id du collaborateur</param> |
||||||
|
/// <response code="200">OK</response> |
||||||
|
/// <response code="401">L'utilisateur souhaitant accéder à la ressource n'est pas authentifié</response> |
||||||
|
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response> |
||||||
|
/// <response code="404">La ressource n'a pas été trouvée</response> |
||||||
|
/// <response code="415">L’opération ne peut pas être effectuée car certaines données sont manquantes</response> |
||||||
|
/// <response code="500">Une erreur est survenue sur le serveur</response> |
||||||
|
[HttpPut] |
||||||
|
[Route("/api/referentsep/collaborateur/{idCollaborateur}")] |
||||||
|
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] |
||||||
|
[ValidateModelState] |
||||||
|
[SwaggerOperation("UpdateReferentCollaborateur")] |
||||||
|
[SwaggerResponse(statusCode: 200, type: typeof(ReferentEPDTO), description: "OK")] |
||||||
|
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L'utilisateur souhaitant accéder à la ressource n'est pas authentifié")] |
||||||
|
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants")] |
||||||
|
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n'a pas été trouvée")] |
||||||
|
[SwaggerResponse(statusCode: 415, type: typeof(ErreurDTO), description: "L’opération ne peut pas être effectuée car certaines données sont manquantes")] |
||||||
|
[SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")] |
||||||
|
public virtual async Task<IActionResult> UpdateReferentCollaborateur([FromBody]ReferentEPDTO body, [FromRoute][Required]Guid? idCollaborateur) |
||||||
|
{ |
||||||
|
try |
||||||
|
{ |
||||||
|
body = await referentEPService.UpdateReferentCollaborateurAsync(body, idCollaborateur); |
||||||
|
} |
||||||
|
|
||||||
|
catch (CollaborateurIncompatibleException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (ApiException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = e.Message, |
||||||
|
//Message = "Un erreur est survenue lors de la communication avec le serveur distant", |
||||||
|
}; |
||||||
|
return StatusCode(500, erreur); |
||||||
|
} |
||||||
|
catch(ListeIdsCollaborateursVideException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 415, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (ReferentNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (CollaborateurPartiException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 4, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (CollaborateurNotFoundException e) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 404, |
||||||
|
Message = e.Message, |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateConcurrencyException) |
||||||
|
{ |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Les données n'ont pas pu être mise à jour car elles ont été modifiés avant votre mise à jour", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (DbUpdateException e) |
||||||
|
{ |
||||||
|
logger.LogError("Une erreur est survenue avec la base de données" + e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur est survenue sur le serveur", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
catch (Exception e) |
||||||
|
{ |
||||||
|
logger.LogError("Une erreur inconnue est survenue :" + e.Message); |
||||||
|
ErreurDTO erreur = new ErreurDTO |
||||||
|
{ |
||||||
|
Code = 500, |
||||||
|
Message = "Une erreur incconue est survenue", |
||||||
|
}; |
||||||
|
return StatusCode(erreur.Code.Value, erreur); |
||||||
|
} |
||||||
|
return Ok(body); |
||||||
|
|
||||||
|
//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(ReferentEPDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(401, default(ErreurDTO)); |
||||||
|
|
||||||
|
//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)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(415, default(ErreurDTO)); |
||||||
|
|
||||||
|
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... |
||||||
|
// return StatusCode(500, default(ErreurDTO)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue