Compare commits

..

29 Commits

Author SHA1 Message Date
Yanaël GRETTE 644d473ce7 Implémentation de la récupération des demandes de formation avec un EP 4 years ago
Yanaël GRETTE b1d3ebdaeb Ajout d'un endpoint pour la récupération des typesentretiens 4 years ago
Yanaël GRETTE fb8fff4a92 Ajout de la récupération d'un EP dans le controleur ep 4 years ago
Yanaël GRETTE d15c4a3a3b Corrections de bugs pour la gestion des clés étrangères 4 years ago
Yanaël GRETTE 2a8d199020 Mise à jour des tests EP en cours 4 years ago
jboinembalome 559cec8611 Résolution des conflits 4 years ago
Yanaël GRETTE fedbd4b901 Merge branch 'ep-details' into develop 4 years ago
jboinembalome 3fd54f315d Petite correction du jeu de données pour les demandes de formation 4 years ago
jboinembalome b0bc3d9d5f Mise à jour des tests unitaires en fonction du paramètres statutsEp 4 years ago
jboinembalome 301c6e456a Ajout du paramètre statutsEp dans GetDemandesFormations et GetDemandesFormationCount 4 years ago
jboinembalome b48c53aa28 Ajout des tests unitaires pour l'api DemandeFormationApi 4 years ago
jboinembalome dbd3888e27 Intégration du service DemandeFormationService dans DemandeFormationApi 4 years ago
jboinembalome bc43b2f2ff Mise à jour des tests unitaires en fonction du filtre sur les statuts de l'EP 4 years ago
jboinembalome 15e9a57e0b Ajout d'une méthode pour récupérer les demandes de formations rattachées à un Ep en cours ou créé 4 years ago
jboinembalome 308e6b6001 Ajout des tests unitaires pour le service DemandeFormationService 4 years ago
jboinembalome 3bfc264c12 Ajout du service DemandeFormationService 4 years ago
jboinembalome 72eb5ce675 DemandeFormationDTO: Remplacement de la propriété FormationDTO par FormationDetailsDTO 4 years ago
jboinembalome d7f93b4913 EpContext: Ajout d'une propriété masqué IdDemandeFormation pour la clé étrangère entre ParticipationFormation et DemandeFormation + Configuration de la relation entre DemandeFormation et OrigineDemande 4 years ago
jboinembalome 0f8e905098 OrigineDemande: Suppression de la propriété DemandeFormations 4 years ago
jboinembalome 80003b0c66 DemandeFormation: Remplacement de la propriété OrigineFormation par OrigineDemande 4 years ago
jboinembalome ce44d25807 Mise à jour du jeu de données pour la partie demande de formation 4 years ago
jboinembalome 0b63a775ff Ajout des méthodes de transformation DTO pour la partie demande de formation 4 years ago
jboinembalome b6dfd23cee Ajout d'une méthode pour récupérer des collaborateurs en fonction d'une demande de formation 4 years ago
Yanaël GRETTE fdda245aad Implémentation de la possibilité de ne récupérer que les EP obligatoires 4 years ago
Yanaël GRETTE f8ba6c6237 Modification sur les counts, résolution d'un bug sur la mise à jour d'une note et suppression des commentaires des autorisations des certains endpoints 4 years ago
jboinembalome ed83ee261c Merge branch 'develop' into demande_formation 4 years ago
jboinembalome 021be18a03 Suppression du tri et de la pagination pour l'action GetDemandesFormationCount 4 years ago
jboinembalome 04171808f5 Création du service DemandeFormationService (non terminée) 4 years ago
jboinembalome 6633d5db52 Ajout des exceptions pour la partie demande de formation 4 years ago
  1. 637
      EPAServeur.Tests/Controllers/DemandeFormationApiTests.cs
  2. 32
      EPAServeur.Tests/Controllers/EpInformationApiTests.cs
  3. 1610
      EPAServeur.Tests/Services/DemandeFormationServiceTests.cs
  4. 32
      EPAServeur.Tests/Services/EpDetailsServiceTests.cs
  5. 30
      EPAServeur.Tests/Services/EpInformationTests.cs
  6. 73
      EPAServeur/Context/DataSeeder.cs
  7. 10
      EPAServeur/Context/EpContext.cs
  8. 38
      EPAServeur/Controllers/CollaborateursApi.cs
  9. 2
      EPAServeur/Controllers/DemandesDelegationApi.cs
  10. 429
      EPAServeur/Controllers/DemandesFormationApi.cs
  11. 6
      EPAServeur/Controllers/EngagementsApi.cs
  12. 152
      EPAServeur/Controllers/EpApi.cs
  13. 6
      EPAServeur/Controllers/FormationsApi.cs
  14. 28
      EPAServeur/Controllers/NotesApi.cs
  15. 6
      EPAServeur/Controllers/ParticipationsFormationsApi.cs
  16. 2
      EPAServeur/Controllers/ReferentsEPApi.cs
  17. 2
      EPAServeur/DTO/DemandeFormationDTO.cs
  18. 40
      EPAServeur/Exceptions/DemandeFormationIncompatibleIdException.cs
  19. 40
      EPAServeur/Exceptions/DemandeFormationInvalidException.cs
  20. 40
      EPAServeur/Exceptions/DemandeFormationNotFoundException.cs
  21. 3
      EPAServeur/IServices/ICollaborateurService.cs
  22. 21
      EPAServeur/IServices/IDemandeFormationService.cs
  23. 12
      EPAServeur/IServices/IEpDetailsService.cs
  24. 10
      EPAServeur/IServices/IEpInformationService.cs
  25. 2
      EPAServeur/IServices/INoteService.cs
  26. 14
      EPAServeur/IServices/ITransformDTO.cs
  27. 2
      EPAServeur/Models/EP/DemandeEPI.cs
  28. 2
      EPAServeur/Models/EP/RdvEntretien.cs
  29. 4
      EPAServeur/Models/Formation/DemandeFormation.cs
  30. 5
      EPAServeur/Models/Formation/OrigineDemande.cs
  31. 2
      EPAServeur/Properties/launchSettings.json
  32. 15
      EPAServeur/Services/CollaborateurService.cs
  33. 602
      EPAServeur/Services/DemandeFormationService.cs
  34. 14
      EPAServeur/Services/EpDetailsService.cs
  35. 16
      EPAServeur/Services/EpInformationService.cs
  36. 1
      EPAServeur/Services/NoteService.cs
  37. 178
      EPAServeur/Services/TransformDTO.cs
  38. 3
      EPAServeur/Startup.cs

@ -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
}
}

@ -60,8 +60,8 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEpEnCours()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
Task<IActionResult> task = epApiController.GetEPEnCours(new List<long?>() { 1, 2 }, true, 1, 15, "", "", null, null);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPEnCours(new List<long?>() { 1, 2 }, true, 1, 15, "", true, "", null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
Assert.IsInstanceOf<IEnumerable<EpInformationDTO>>(result.Value);
@ -70,8 +70,8 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEpEnCoursCount()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
Task<IActionResult> task = epApiController.GetEPEnCoursCount(new List<long?>() { 1, 2 }, true, 1, 15, "", "", null, null);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPEnCoursCount(new List<long?>() { 1, 2 }, "", true, null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
Assert.IsInstanceOf<int>(result.Value);
@ -80,7 +80,7 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEpEnSignes()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPSignes(new List<long?>() { 1, 2 }, true, 1, 15, "", "", null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
@ -91,8 +91,8 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEpEnSignesCount()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
Task<IActionResult> task = epApiController.GetEPSignesCount(new List<long?>() { 1, 2 }, true, 1, 15, "", "", null, null);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPSignesCount(new List<long?>() { 1, 2 }, "", null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
Assert.IsInstanceOf<int>(result.Value);
@ -101,7 +101,7 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEPSignesCollaborateur()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPSignesCollaborateur(new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"));
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
@ -111,7 +111,7 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetProchainEPCollaborateur()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetProchainEPCollaborateur(new Guid("a0f40e2a-cc03-4032-a627-5389e1281c64"));
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
@ -121,7 +121,7 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEPSignesReferent()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPSignesReferent(new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"), true, 1, 15, "", "", null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
@ -131,8 +131,8 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEPSignesReferentCount()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
Task<IActionResult> task = epApiController.GetEPSignesReferentCount(new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"), true, 1, 15, "", "", null, null);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPSignesReferentCount(new Guid("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"), "", null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
Assert.IsInstanceOf<int>(result.Value);
@ -141,8 +141,8 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEPEnCoursReferent()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
Task<IActionResult> task = epApiController.GetEPEnCoursReferent(new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"), true, 1, 15, "", "", true, null, null);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPEnCoursReferent(new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"), true, 1, 15, "", "", null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
Assert.IsInstanceOf<IEnumerable<EpInformationDTO>>(result.Value);
@ -151,8 +151,8 @@ namespace EPAServeur.Tests.Controllers
[Test]
public async Task GetEPEnCoursReferentCount()
{
EpApiController epApiController = new EpApiController(epInformationService, logger);
Task<IActionResult> task = epApiController.GetEPEnCoursReferentCount(new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"), true, 1, 15, "", "", true, null, null);
EpApiController epApiController = new EpApiController(epInformationService, logger, null);
Task<IActionResult> task = epApiController.GetEPEnCoursReferentCount(new Guid("eb8b0f33-f529-4985-861e-1207f3312bb5"), "", null, null);
OkObjectResult result = task.Result as OkObjectResult;
Assert.AreEqual(200, result.StatusCode);
Assert.IsInstanceOf<int>(result.Value);

File diff suppressed because it is too large Load Diff

@ -15,6 +15,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Tests.Services
{
[TestFixture]
public class EpDetailsServiceTests
{
#region variables
@ -269,18 +270,27 @@ namespace EPAServeur.Tests.Services
#endregion
#region Récupérer EP avec demandes de formation
[TestCase(1,0)]
[TestCase(2,0)]
[TestCase(3,1)]
[TestCase(12,3)]
[TestCase(16,0)]
public async Task GetEp_GetpDemandesFormation(long idEp, int count)
{
IEpDetailsService epDetailsService = new EpDetailsService(context, transformDTO, collaborateurService);
EpDTO epDTO = await epDetailsService.GetEp(idEp);
Assert.IsNotNull(epDTO);
if(count == 0)
{
Assert.IsNull(epDTO.DemandesFormation);
}
else
{
Assert.IsNotNull(epDTO.DemandesFormation);
Assert.AreEqual(epDTO.DemandesFormation.Count, count);
}
}
#endregion
#region
#endregion
#region
#endregion
}
}

@ -63,8 +63,8 @@ namespace EPAServeur.Tests.Services
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPEnCoursCount(new List<long?> { idBUs }, true, 1, 15, "", "", null, null);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?>{ idBUs }, true, 1, 15, "", false,"", null, null);
int count = await epInformationService.GetEPEnCoursCount(new List<long?> { idBUs }, "", false, null, null);
Assert.AreEqual(count, nbElements);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach(EpInformationDTO ep in epInformationDTOs)
@ -79,8 +79,8 @@ namespace EPAServeur.Tests.Services
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1,2 }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPEnCoursCount(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, null);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1,2 }, true, 1, 15, "", false, "", null, null);
int count = await epInformationService.GetEPEnCoursCount(new List<long?> { 1, 2 }, "", false, null, null);
Assert.AreEqual(count, 6);
Assert.AreEqual(count, epInformationDTOs.Count());
long? bu;
@ -104,7 +104,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEpEnCours_TriColonneASC(string tri)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", tri, null, null);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", false, tri, null, null);
EpInformationDTO ep1, ep2;
int compare = 0;
for(int i = 0; i < epInformationDTOs.Count()-1; ++i)
@ -157,7 +157,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEpEnCours_TriColonneDESC(string tri)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, false, 1, 15, "", tri, null, null);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, false, 1, 15, "", false, tri, null, null);
EpInformationDTO ep1, ep2;
int compare = 0;
for (int i = 0; i < epInformationDTOs.Count() - 1; ++i)
@ -206,7 +206,7 @@ namespace EPAServeur.Tests.Services
DateTime date = new DateTime(a, m, j);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date, null);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", false, "", date, null);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach(EpInformationDTO ep in epInformationDTOs)
{
@ -222,7 +222,7 @@ namespace EPAServeur.Tests.Services
{
DateTime date = new DateTime(a, m, j); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, date);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", false, "", null, date);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
@ -242,7 +242,7 @@ namespace EPAServeur.Tests.Services
DateTime date2 = new DateTime(a2, m2, j2);
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", "", date1, date2);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, "", false, "", date1, date2);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
@ -263,7 +263,7 @@ namespace EPAServeur.Tests.Services
public async Task GetEpEnCours_texte(string texte, int count)
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, texte, "", null, null);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCours(new List<long?> { 1, 2 }, true, 1, 15, texte, false, "", null, null);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach (EpInformationDTO ep in epInformationDTOs)
{
@ -285,7 +285,7 @@ namespace EPAServeur.Tests.Services
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?>{ idBUs }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPSignesCount(new List<long?> { idBUs }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPSignesCount(new List<long?> { idBUs }, "", null, null);
Assert.AreEqual(count, nbElements);
Assert.AreEqual(count, epInformationDTOs.Count());
foreach(EpInformationDTO ep in epInformationDTOs)
@ -301,7 +301,7 @@ namespace EPAServeur.Tests.Services
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1,2 }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, null);
int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, "", null, null);
Assert.AreEqual(count, 8);
Assert.AreEqual(count, epInformationDTOs.Count());
long? bu;
@ -449,7 +449,7 @@ namespace EPAServeur.Tests.Services
DateTime date = new DateTime(a, m, j); IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignes(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, date);
int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, true, 1, 15, "", "", null, date);
int count = await epInformationService.GetEPSignesCount(new List<long?> { 1, 2 }, "", null, date);
Assert.AreEqual(epInformationDTOs.Count(), count);
foreach (EpInformationDTO ep in epInformationDTOs)
{
@ -513,7 +513,7 @@ namespace EPAServeur.Tests.Services
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPEnCoursReferent(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPEnCoursReferentCount(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPEnCoursReferentCount(idReferent, "", null, null);
Assert.AreEqual(epCount, count);
foreach(EpInformationDTO ep in epInformationDTOs)
{
@ -536,7 +536,7 @@ namespace EPAServeur.Tests.Services
{
IEpInformationService epInformationService = new EpInformationService(context, collaborateurService, transformDTO);
IEnumerable<EpInformationDTO> epInformationDTOs = await epInformationService.GetEPSignesReferent(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPSignesReferentCount(idReferent, true, 1, 15, "", "", null, null);
int epCount = await epInformationService.GetEPSignesReferentCount(idReferent, "", null, null);
Assert.AreEqual(epCount, count);
foreach (EpInformationDTO ep in epInformationDTOs)
{

@ -106,6 +106,8 @@ namespace EPAServeur.Context
DemandeEPI demandeEPI1, demandeEPI2, demandeEPI3;
DemandeFormation demandeF1, demandeF2, demandeF3, demandeF4;
//Ep en cours
Ep epEnCours1, epEnCours2, epEnCours3, epEnCours4, epEnCours5, epEnCours6, epEnCours7, epEnCours8, epEnCours9;
@ -253,8 +255,16 @@ namespace EPAServeur.Context
epEnCours3.Objectifs = new List<Objectif>() { objectif1, objectif2, objectif3 };
epEnCours3.ObjectifsPrecedents = new List<ObjectifPrecedent>() { objectifPrecedent1, objectifPrecedent2, objectifPrecedent3 };
demandeF1 = new DemandeFormation()
{
DateDemande = new DateTime(),
Description = "Description",
DemandeRH = false,
Libelle = "Libellé",
Etat = EtatDemande.EnAttente,
Ep = epEnCours3,
};
epEnCours3.DemandesFormation = new List<DemandeFormation>() { demandeF1 };
epContext.Ep.Add(epEnCours3);
@ -568,6 +578,37 @@ namespace EPAServeur.Context
};
epSigne3.RdvEntretien = rdv3;
demandeF2 = new DemandeFormation()
{
DateDemande = new DateTime(),
Description = "Description 2",
DemandeRH = false,
Libelle = "Libellé 2",
Etat = EtatDemande.EnAttente,
Ep = epSigne3,
};
demandeF3 = new DemandeFormation()
{
DateDemande = new DateTime(),
Description = "Description 3",
DemandeRH = false,
Libelle = "Libellé 3",
Etat = EtatDemande.EnAttente,
Ep = epSigne3,
};
demandeF4 = new DemandeFormation()
{
DateDemande = new DateTime(),
Description = "Description 4",
DemandeRH = true,
Libelle = "Libellé 4",
Etat = EtatDemande.EnAttente,
Ep = epSigne3,
};
epSigne3.DemandesFormation = new List<DemandeFormation>() { demandeF2, demandeF3, demandeF4 };
epContext.Ep.Add(epSigne3);
@ -1411,6 +1452,7 @@ namespace EPAServeur.Context
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
OrigineDemande = origineDemandeFormationApside,
Ep = ep12
};
@ -1426,6 +1468,7 @@ namespace EPAServeur.Context
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
OrigineDemande = origineDemandeFormationApside,
Ep = ep13
};
@ -1441,6 +1484,7 @@ namespace EPAServeur.Context
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
OrigineDemande = origineDemandeFormationClient,
Ep = ep14
};
@ -1456,6 +1500,7 @@ namespace EPAServeur.Context
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
OrigineDemande = origineDemandeFormationClient,
Ep = ep13
};
@ -1470,7 +1515,8 @@ namespace EPAServeur.Context
DateDemande = new DateTime(2020, 5, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
DateDerniereReponse = new DateTime(2020, 5, 23, 9, 0, 0),
OrigineDemande = origineDemandeFormationEP,
Ep = ep12
};
@ -1481,11 +1527,12 @@ namespace EPAServeur.Context
IdDemandeFormation = 6,
Libelle = "Formation Vb.Net",
Description = "Demande de formation Vb.Net avec WinForms",
DemandeRH = false,
DemandeRH = true,
DateDemande = new DateTime(2020, 6, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
DateDerniereReponse = new DateTime(2020, 6, 23, 9, 0, 0),
OrigineDemande = origineDemandeFormationEP,
Ep = ep15
};
@ -1500,7 +1547,8 @@ namespace EPAServeur.Context
DateDemande = new DateTime(2020, 7, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
DateDerniereReponse = new DateTime(2020, 7, 23, 9, 0, 0),
OrigineDemande = origineDemandeFormationReglement,
Ep = ep16
};
@ -1515,7 +1563,8 @@ namespace EPAServeur.Context
DateDemande = new DateTime(2020, 8, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
DateDerniereReponse = new DateTime(2020, 8, 23, 9, 0, 0),
OrigineDemande = origineDemandeFormationReglement,
Ep = ep16
};
@ -1531,6 +1580,7 @@ namespace EPAServeur.Context
Etat = EtatDemande.Rejetee,
CommentaireRefus = "Aucune formation PHP pour le moment",
DateDerniereReponse = new DateTime(2020, 9, 27, 9, 0, 0),
OrigineDemande = origineDemandeFormationCollaborateur,
Ep = ep17
};
@ -1544,8 +1594,9 @@ namespace EPAServeur.Context
DemandeRH = false,
DateDemande = new DateTime(2020, 10, 22, 9, 0, 0),
Etat = EtatDemande.Rejetee,
CommentaireRefus = null,
CommentaireRefus = "Aucune formation Vus.JS",
DateDerniereReponse = new DateTime(2020, 10, 27, 9, 0, 0),
OrigineDemande = origineDemandeFormationCollaborateur,
Ep = ep18
};
@ -1559,8 +1610,9 @@ namespace EPAServeur.Context
DemandeRH = false,
DateDemande = new DateTime(2020, 11, 22, 9, 0, 0),
Etat = EtatDemande.Rejetee,
CommentaireRefus = null,
CommentaireRefus = "Aucune formation SCRUM pour le moment",
DateDerniereReponse = new DateTime(2020, 11, 27, 9, 0, 0),
OrigineDemande = origineDemandeFormationCollaborateur,
Ep = ep19
};
@ -1574,8 +1626,9 @@ namespace EPAServeur.Context
DemandeRH = false,
DateDemande = new DateTime(2020, 12, 22, 9, 0, 0),
Etat = EtatDemande.Rejetee,
CommentaireRefus = null,
CommentaireRefus = "Aucune formation avec du Xamarin pour le moment",
DateDerniereReponse = new DateTime(2020, 12, 27, 9, 0, 0),
OrigineDemande = origineDemandeFormationCollaborateur,
Ep = ep20
};

@ -85,12 +85,11 @@ namespace EPAServeur.Context
entity.HasMany<Objectif>(e => e.Objectifs).WithOne(o => o.Ep);
entity.HasMany<ObjectifPrecedent>(e => e.ObjectifsPrecedents).WithOne(o => o.Ep);
entity.HasMany<ParticipationEP>(e => e.Participants).WithOne(p => p.Ep);
entity.HasOne<RdvEntretien>(e => e.RdvEntretien).WithOne(r => r.EpChoixRDV).HasForeignKey<RdvEntretien>(r => r.IdEPChoixRDV);
entity.HasOne<RdvEntretien>(e => e.RdvEntretien).WithOne(r => r.EpChoixRDV).HasForeignKey<RdvEntretien>( r => r.IdEPChoixRDV);
entity.HasMany<RdvEntretien>(e => e.PropositionsRDV).WithOne(r => r.EpProposition);
entity.HasOne<DemandeEPI>(e => e.DemandeEPI).WithOne(a => a.Ep).HasForeignKey<DemandeEPI>(a => a.IdEP);
});
modelBuilder.Entity<Objectif>(entity =>
{
entity.HasKey(e => e.IdObjectif);
@ -152,12 +151,14 @@ namespace EPAServeur.Context
});
//Formation
modelBuilder.Entity<DemandeFormation>(entity =>
{
entity.HasKey(e => e.IdDemandeFormation);
entity.Property(e => e.IdDemandeFormation).ValueGeneratedOnAdd();
entity.HasOne<ParticipationFormation>(e => e.ParticipationFormation).WithOne(e => e.DemandeFormation).HasForeignKey<ParticipationFormation>(d => d.IdParticipationFormation);
entity.HasOne<ParticipationFormation>(e => e.ParticipationFormation).WithOne(e => e.DemandeFormation).HasForeignKey<ParticipationFormation>("IdDemandeFormation");
entity.HasOne<OrigineDemande>(o => o.OrigineDemande).WithMany().IsRequired();
});
modelBuilder.Entity<Formation>(entity =>
@ -192,6 +193,7 @@ namespace EPAServeur.Context
{
entity.HasKey(e => e.IdParticipationFormation);
entity.Property(e => e.IdParticipationFormation).ValueGeneratedOnAdd();
entity.Property<long>("IdDemandeFormation");
entity.HasMany<Saisie>(e => e.Evaluation).WithOne(e => e.ParticipationFormation);
});

@ -59,7 +59,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/collaborateurs/{idCollaborateur}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetCollaborateurById")]
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), description: "OK")]
@ -154,7 +154,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/collaborateurs/{mail}/mail")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetCollaborateurByMail")]
[SwaggerResponse(statusCode: 200, type: typeof(CollaborateurDTO), description: "OK")]
@ -245,7 +245,7 @@ namespace IO.Swagger.Controllers
/// <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&#x27;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="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>
@ -256,20 +256,20 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/collaborateurs")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetCollaborateurs")]
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), description: "OK")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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)
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);
collaborateurs = await collaborateurService.GetCollaborateursAsync(roles, idBUs, asc, numPage, parPage, texte, tri, dateDebut, dateFin);
}
catch (ApiException e)
{
@ -312,7 +312,7 @@ namespace IO.Swagger.Controllers
/// <param name="idReferent">Id d&#x27;un référent</param>
/// <param name="asc">Indique si les données sont récupérées dans l&#x27;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="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>
@ -322,7 +322,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/collaborateurs/referent/{idReferent}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetCollaborateursByReferent")]
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), description: "OK")]
@ -330,12 +330,12 @@ namespace IO.Swagger.Controllers
[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&#x27;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)
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);
collaborateurs = await collaborateurService.GetCollaborateursByReferentAsync(idReferent, asc, numPage, parPage, texte, tri);
}
catch (ApiException e)
{
@ -390,25 +390,21 @@ namespace IO.Swagger.Controllers
/// </summary>
/// <remarks>Récupérer le nombre total de collaborateurs d’un référent.</remarks>
/// <param name="idReferent">Id d&#x27;un référent</param>
/// <param name="asc">Indique si les données sont récupérées dans l&#x27;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&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetCollaborateursByReferentCount")]
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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]bool? asc, [FromQuery]int? numPage, [FromQuery][Range(5, 100)]int? parPAge, [FromQuery]string texte, [FromQuery]string tri)
public virtual async Task<IActionResult> GetCollaborateursByReferentCount([FromRoute][Required]Guid? idReferent, [FromQuery]string texte)
{
int collaborateurs;
try
@ -465,11 +461,7 @@ namespace IO.Swagger.Controllers
/// <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="asc">Indique si les données sont récupérées dans l&#x27;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&#x27;à laquelle les données sont récupérées</param>
/// <response code="200">OK</response>
@ -478,14 +470,14 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/collaborateurs/count")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetCollaborateursCount")]
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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]bool? asc, [FromQuery]int? numPage, [FromQuery][Range(5, 100)]int? parPAge, [FromQuery]string texte, [FromQuery]string tri, [FromQuery]DateTime? dateDebut, [FromQuery]DateTime? dateFin)
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
@ -540,7 +532,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/collaborateurs/{idCollaborateur}/ep/referents")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetReferentsPrecedentEPCollaborateur")]
[SwaggerResponse(statusCode: 200, type: typeof(List<CollaborateurDTO>), description: "OK")]

@ -138,7 +138,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPut]
[Route("/api/demandesdelegation/{idDemandeDelegation}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("UpdateDemandeDelegation")]
[SwaggerResponse(statusCode: 200, type: typeof(DemandeDelegationDTO), description: "Demande de délégation mise à jour avec succès")]

@ -19,6 +19,14 @@ 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
{
@ -28,6 +36,17 @@ namespace IO.Swagger.Controllers
[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>
@ -40,7 +59,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPost]
[Route("/api/demandesformation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("AddDemandeFormation")]
[SwaggerResponse(statusCode: 201, type: typeof(DemandeFormationDTO), description: "Demande formation créée")]
@ -48,29 +67,58 @@ namespace IO.Swagger.Controllers
[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 AddDemandeFormation([FromBody]DemandeFormationDTO body)
public virtual async Task<IActionResult> AddDemandeFormation([FromBody] DemandeFormationDTO 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(DemandeFormationDTO));
//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 \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 2,\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 7\n },\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 9,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\"\n },\n \"formation\" : {\n \"heure\" : 1,\n \"participations\" : [ {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n }, {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n } ],\n \"organisme\" : \"organisme\",\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n },\n \"estCertifiee\" : true,\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"intitule\" : \"intitule\",\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 1\n },\n \"jour\" : 1,\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estRealisee\" : true,\n \"id\" : 3,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"idAgence\" : 7,\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n }\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etatDemande\" : \"EnAttente\"\n}";
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);
var example = exampleJson != null
? JsonConvert.DeserializeObject<DemandeFormationDTO>(exampleJson)
: default(DemandeFormationDTO); //TODO: Change the data returned
return new ObjectResult(example);
}
/// <summary>
@ -82,34 +130,94 @@ namespace IO.Swagger.Controllers
/// <response code="401">L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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&#x27;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)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("DeleteDemandeFormation")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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&#x27;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 DeleteDemandeFormation([FromRoute][Required]long? idDemandeFormation)
public virtual async Task<IActionResult> DeleteDemandeFormation([FromRoute][Required] long idDemandeFormation)
{
//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();
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>
@ -118,6 +226,7 @@ namespace IO.Swagger.Controllers
/// <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&#x27;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>
@ -131,33 +240,41 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/demandesformation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetDemandesFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<DemandeFormationDTO>), description: "OK")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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 IActionResult GetDemandesFormation([FromQuery]List<EtatDemande> etatsDemande, [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)
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)
{
//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>));
if (env.IsDevelopment())
logger.LogInformation("Récupération de la liste des demandes de formation.");
IEnumerable<DemandeFormationDTO> demandeFormations;
//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));
try
{
demandeFormations = await demandeFormationService.GetDemandesFormationAsync(etatsDemande, idBUs, statutsEp, asc, numPage, parPAge, texte, tri, dateDebut, dateFin);
}
catch (Exception e)
{
logger.LogError(e.Message);
//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));
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
//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 \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 2,\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 7\n },\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 9,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\"\n },\n \"formation\" : {\n \"heure\" : 1,\n \"participations\" : [ {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n }, {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n } ],\n \"organisme\" : \"organisme\",\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n },\n \"estCertifiee\" : true,\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"intitule\" : \"intitule\",\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 1\n },\n \"jour\" : 1,\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estRealisee\" : true,\n \"id\" : 3,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"idAgence\" : 7,\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n }\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etatDemande\" : \"EnAttente\"\n}, {\n \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 2,\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 7\n },\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 9,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\"\n },\n \"formation\" : {\n \"heure\" : 1,\n \"participations\" : [ {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n }, {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n } ],\n \"organisme\" : \"organisme\",\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n },\n \"estCertifiee\" : true,\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"intitule\" : \"intitule\",\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 1\n },\n \"jour\" : 1,\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estRealisee\" : true,\n \"id\" : 3,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"idAgence\" : 7,\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n }\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etatDemande\" : \"EnAttente\"\n} ]";
return StatusCode(erreur.Code.Value, erreur);
}
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<DemandeFormationDTO>>(exampleJson)
: default(List<DemandeFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example);
if (env.IsDevelopment())
logger.LogInformation("Liste des demandes de formation récupérée.");
return Ok(demandeFormations);
}
/// <summary>
@ -166,11 +283,8 @@ namespace IO.Swagger.Controllers
/// <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="asc">Indique si les données sont récupérées dans l&#x27;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="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="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&#x27;à laquelle les données sont récupérées</param>
/// <response code="200">OK</response>
@ -179,33 +293,41 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/demandesformation/count")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetDemandesFormationCount")]
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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 IActionResult GetDemandesFormationCount([FromQuery]List<EtatDemande> etatsDemande, [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)
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)
{
//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?));
if (env.IsDevelopment())
logger.LogInformation("Récupération du nombre total de demandes de formation.");
long count;
//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));
try
{
count = await demandeFormationService.GetDemandesFormationCountAsync(etatsDemande, idBUs, statutsEp, texte, dateDebut, dateFin);
}
catch (Exception e)
{
logger.LogError(e.Message);
//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));
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
//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";
return StatusCode(erreur.Code.Value, erreur);
}
var example = exampleJson != null
? JsonConvert.DeserializeObject<long?>(exampleJson)
: default(long?); //TODO: Change the data returned
return new ObjectResult(example);
if (env.IsDevelopment())
logger.LogInformation("Nombre total de demandes de formation récupéré.");
return Ok(count);
}
/// <summary>
@ -218,33 +340,41 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/originesdemandeformation")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetOriginesDemandeFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(List<OrigineDemandeFormationDTO>), description: "OK")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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 IActionResult GetOriginesDemandeFormation()
public virtual async Task<IActionResult> GetOriginesDemandeFormation()
{
//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>));
if (env.IsDevelopment())
logger.LogInformation("Récupération de la liste des origines de demande de formation.");
IEnumerable<OrigineDemandeFormationDTO> origineDemandes;
//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));
try
{
origineDemandes = await demandeFormationService.GetOriginesDemandeFormationAsync();
}
catch (Exception e)
{
logger.LogError(e.Message);
//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));
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
//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 \"libelle\" : \"libelle\",\n \"id\" : 7\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 7\n} ]";
return StatusCode(erreur.Code.Value, erreur);
}
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<OrigineDemandeFormationDTO>>(exampleJson)
: default(List<OrigineDemandeFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example);
if (env.IsDevelopment())
logger.LogInformation("Liste des origines de demande de formation récupérée.");
return Ok(origineDemandes);
}
/// <summary>
@ -261,7 +391,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPut]
[Route("/api/demandesformation/{idDemandeFormation}")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("UpdateDemandeFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(DemandeFormationDTO), description: "demande formation mise à jour")]
@ -270,32 +400,95 @@ namespace IO.Swagger.Controllers
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n&#x27;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 UpdateDemandeFormation([FromBody]DemandeFormationDTO body, [FromRoute][Required]long? idDemandeFormation)
public virtual async Task<IActionResult> UpdateDemandeFormation([FromBody] DemandeFormationDTO body, [FromRoute][Required] long 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, default(DemandeFormationDTO));
//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 \"commentaireRefus\" : \"commentaireRefus\",\n \"libelle\" : \"libelle\",\n \"description\" : \"description\",\n \"dateDerniereReponse\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 2,\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 7\n },\n \"ep\" : {\n \"obligatoire\" : true,\n \"dateDisponibilite\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 9,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\"\n },\n \"formation\" : {\n \"heure\" : 1,\n \"participations\" : [ {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n }, {\n \"estEvaluee\" : true,\n \"dateCreation\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"id\" : 7,\n \"intitule\" : \"intitule\"\n } ],\n \"organisme\" : \"organisme\",\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n },\n \"estCertifiee\" : true,\n \"type\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n },\n \"intitule\" : \"intitule\",\n \"mode\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 1\n },\n \"jour\" : 1,\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"estRealisee\" : true,\n \"id\" : 3,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"idAgence\" : 7,\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n }\n },\n \"demandeRH\" : false,\n \"dateDemande\" : \"2000-01-23T04:56:07.000+00:00\",\n \"etatDemande\" : \"EnAttente\"\n}";
var example = exampleJson != null
? JsonConvert.DeserializeObject<DemandeFormationDTO>(exampleJson)
: default(DemandeFormationDTO); //TODO: Change the data returned
return new ObjectResult(example);
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);
}
}
}

@ -57,7 +57,7 @@ namespace IO.Swagger.Controllers
/// <param name="etatsEngagement">Etats de l&#x27;engagement</param>
/// <param name="asc">Indique si les données sont récupérées dans l&#x27;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="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>
@ -73,7 +73,7 @@ namespace IO.Swagger.Controllers
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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)
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.");
@ -82,7 +82,7 @@ namespace IO.Swagger.Controllers
try
{
engagements = await engagementService.GetEngagementsAsync(idBUs, etatsEngagement, asc, numPage, parPAge, texte, tri);
engagements = await engagementService.GetEngagementsAsync(idBUs, etatsEngagement, asc, numPage, parPage, texte, tri);
}
catch (Exception e)
{

File diff suppressed because one or more lines are too long

@ -276,7 +276,7 @@ namespace IO.Swagger.Controllers
/// <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&#x27;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="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>
@ -294,7 +294,7 @@ namespace IO.Swagger.Controllers
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;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)
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.");
@ -303,7 +303,7 @@ namespace IO.Swagger.Controllers
try
{
formations = await formationService.GetFormationsAsync(idAgence, idStatuts, asc, numPage, parPAge, texte, tri, dateDebut, dateFin);
formations = await formationService.GetFormationsAsync(idAgence, idStatuts, asc, numPage, parPage, texte, tri, dateDebut, dateFin);
}
catch (Exception e)
{

@ -63,8 +63,8 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPost]
[Route("/api/notes/")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[ValidateModelState]
[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&#x27;utilisateur souhaitant accéder à la ressource n&#x27;est pas authentifié")]
@ -173,7 +173,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpDelete]
[Route("/api/notes/{idNote}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("DeleteNote")]
[SwaggerResponse(statusCode: 401, type: typeof(ErreurDTO), description: "L&#x27;utilisateur souhaitant accéder à la ressource n&#x27;est pas authentifié")]
@ -244,7 +244,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/notes/{idNote}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetNoteById")]
[SwaggerResponse(statusCode: 200, type: typeof(DetailsNoteDTO), description: "OK")]
@ -320,7 +320,7 @@ namespace IO.Swagger.Controllers
/// <param name="idAuteur">Id de l&#x27;auteur</param>
/// <param name="asc">Indique si les données sont récupérées dans l&#x27;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="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>
@ -330,7 +330,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/notes/auteur/{idAuteur}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetNotesAuteur")]
[SwaggerResponse(statusCode: 200, type: typeof(List<AffichageNoteDTO>), description: "OK")]
@ -338,13 +338,13 @@ namespace IO.Swagger.Controllers
[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&#x27;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)
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);
affichageNotes = await noteService.GetNotesByAuteurAsync(idAuteur, asc, numPage, parPage, texte, tri);
//affichageNotes = noteService.GetNotesByAuteur(idAuteur, asc, numPage, parPage, texte, tri);
}
catch(ReferentNotFoundException e)
{
@ -398,11 +398,7 @@ namespace IO.Swagger.Controllers
/// </summary>
/// <remarks>Récupérer le nombre total de notes d’un auteur.</remarks>
/// <param name="idAuteur">Id de l&#x27;auteur</param>
/// <param name="asc">Indique si les données sont récupérées dans l&#x27;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&#x27;utilisateur souhaitant accéder à la ressource n&#x27;est pas authentifié</response>
/// <response code="403">L’utilisateur souhaitant accéder à la ressource n’a pas les droits d’accès suffisants</response>
@ -410,7 +406,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/notes/auteur/{idAuteur}/count")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetNotesAuteurCount")]
[SwaggerResponse(statusCode: 200, type: typeof(long?), description: "OK")]
@ -418,7 +414,7 @@ namespace IO.Swagger.Controllers
[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&#x27;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]bool? asc, [FromQuery]int? numPage, [FromQuery][Range(5, 100)]int? parPAge, [FromQuery]string texte, [FromQuery]string tri)
public virtual async Task<IActionResult> GetNotesAuteurCount([FromRoute][Required]Guid? idAuteur, [FromQuery]string texte)
{
int notes;
try
@ -485,7 +481,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPut]
[Route("/api/notes/{idNote}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("UpdateNote")]
[SwaggerResponse(statusCode: 200, type: typeof(DetailsNoteDTO), description: "Note modifiée avec succès")]

@ -60,7 +60,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPut]
[Route("/api/participationsformation/{idParticipationFormation}/evaluation")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("EvaluerFormation")]
[SwaggerResponse(statusCode: 200, type: typeof(EvaluationDTO), description: "Evaluation envoyée avec succès")]
@ -172,7 +172,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/participationsformation/{idParticipationFormation}/evaluation")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetEvaluationCollaborateur")]
[SwaggerResponse(statusCode: 200, type: typeof(EvaluationDTO), description: "OK")]
@ -235,7 +235,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet]
[Route("/api/participationsformation/{idCollaborateur}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetParticipationByCollaborateur")]
[SwaggerResponse(statusCode: 200, type: typeof(List<ParticipationFormationDTO>), description: "OK")]

@ -199,7 +199,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpPut]
[Route("/api/referentsep/collaborateur/{idCollaborateur}")]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("UpdateReferentCollaborateur")]
[SwaggerResponse(statusCode: 200, type: typeof(ReferentEPDTO), description: "OK")]

@ -109,7 +109,7 @@ namespace IO.Swagger.DTO
/// Gets or Sets Formation
/// </summary>
[DataMember(Name="formation")]
public FormationDTO Formation { get; set; }
public FormationDetailsDTO Formation { get; set; }
/// <summary>
/// Returns the string presentation of the object

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.Exceptions
{
/// <summary>
/// Exception qui est levée lorsque l'id de la demande de formation avec les données à mettre à jour et l'id de la demande de formation dans la base de données sont différents
/// </summary>
public class DemandeFormationIncompatibleIdException : Exception
{
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationIncompatibleIdException"/> class.
/// </summary>
public DemandeFormationIncompatibleIdException()
{
}
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationIncompatibleIdException"/> class.
/// </summary>
/// <param name="message"></param>
public DemandeFormationIncompatibleIdException(string message) : base(message)
{
}
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationIncompatibleIdException"/> class.
/// </summary>
/// <param name="message"></param>
/// <param name="inner"></param>
public DemandeFormationIncompatibleIdException(string message, Exception inner) : base(message, inner)
{
}
}
}

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.Exceptions
{
/// <summary>
/// Exception qui est levée lorsqu'une demande de formation est invalide
/// </summary>
public class DemandeFormationInvalidException : Exception
{
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationInvalidException"/> class.
/// </summary>
public DemandeFormationInvalidException()
{
}
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationInvalidException"/> class.
/// </summary>
/// <param name="message"></param>
public DemandeFormationInvalidException(string message) : base(message)
{
}
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationInvalidException"/> class.
/// </summary>
/// <param name="message"></param>
/// <param name="inner"></param>
public DemandeFormationInvalidException(string message, Exception inner) : base(message, inner)
{
}
}
}

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.Exceptions
{
/// <summary>
/// Exception qui est levée lorsqu'une demande de formation n'a pas été trouvée
/// </summary>
public class DemandeFormationNotFoundException : Exception
{
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationNotFoundException"/> class.
/// </summary>
public DemandeFormationNotFoundException()
{
}
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationNotFoundException"/> class.
/// </summary>
/// <param name="message"></param>
public DemandeFormationNotFoundException(string message) : base(message)
{
}
/// <summary>
/// Initialise une nouvelle instance de la classe <see cref="DemandeFormationNotFoundException"/> class.
/// </summary>
/// <param name="message"></param>
/// <param name="inner"></param>
public DemandeFormationNotFoundException(string message, Exception inner) : base(message, inner)
{
}
}
}

@ -15,7 +15,7 @@ namespace EPAServeur.IServices
{
Task<CollaborateurDTO> GetCollaborateurByIdAsync(Guid? id);
Task<CollaborateurDTO> GetCollaborateurByMailAsync(string mail);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateursAsync(List<string> roles, List<long?> idBUs, bool? asc, int? numPage, int? parPAge, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateursAsync(List<string> roles, List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetCollaborateursCountAsync(List<string> roles, List<long?> idBUs, string texte, DateTime? dateDebut, DateTime? dateFin);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateursByReferentAsync(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri);
Task<int> GetCollaborateursCountByReferentAsync(Guid? idReferent, string texte);
@ -23,6 +23,7 @@ namespace EPAServeur.IServices
Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(List<Guid?> guids);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(List<ParticipationFormation> participationsFormation);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(IEnumerable<ParticipationFormation> participationsFormation);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(IEnumerable<DemandeFormation> demandeFormations);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(Engagement engagement);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(IEnumerable<Engagement> engagements);
Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(IEnumerable<Ep> eps);

@ -0,0 +1,21 @@
using EPAServeur.Context;
using IO.Swagger.DTO;
using IO.Swagger.Enum;
using IO.Swagger.ModelCollaborateur;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.IServices
{
public interface IDemandeFormationService
{
Task<IEnumerable<OrigineDemandeFormationDTO>> GetOriginesDemandeFormationAsync();
Task<IEnumerable<DemandeFormationDTO>> GetDemandesFormationAsync(List<EtatDemande> etatsDemande, List<long?> idBUs, List<StatutEp> statutsEp, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<long> GetDemandesFormationCountAsync(List<EtatDemande> etatsDemande, List<long?> idBUs, List<StatutEp> statutsEp, string texte, DateTime? dateDebut, DateTime? dateFin);
Task<DemandeFormationDTO> AddDemandeFormationAsync(DemandeFormationDTO demandeFormationDTO);
Task<DemandeFormationDTO> UpdateDemandeFormationAsync(long idDemandeFormation, DemandeFormationDTO demandeFormationDTO);
Task<bool> DeleteDemandeFormationAsync(long idDemandeFormation);
}
}

@ -9,13 +9,13 @@ namespace EPAServeur.IServices
public interface IEpDetailsService
{
void SupprimerDonneesEPCollaborateur(Guid? idCollaborateur);
Task<EpDTO> GetEp(long id);
Task<EpDTO> UpdateEP(long idEp, EpDTO ep);
void SupprimerEP(long idEp);
void RappelSignature(long idEp);
Task<EpDTO> UpdateSaisie(long idEp, EpDTO ep);
Task<EpDTO> GetEp(long? id);
Task<EpDTO> UpdateEP(long? idEp, EpDTO ep);
void SupprimerEP(long? idEp);
void RappelSignature(long? idEp);
Task<EpDTO> UpdateSaisie(long? idEp, EpDTO ep);
Task<EpDTO> SaisirEPCollaborateur(Guid? idCollaborateur);
Task<EpDTO> SaisirEPReferent(long idEp);
Task<EpDTO> SaisirEPReferent(long? idEp);
}
}

@ -8,24 +8,24 @@ namespace EPAServeur.IServices
{
public interface IEpInformationService
{
Task<IEnumerable<EpInformationDTO>> GetEPEnCours(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPEnCoursCount(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<IEnumerable<EpInformationDTO>> GetEPEnCours(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, bool? epObligatoire, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPEnCoursCount(List<long?> idBUs, string texte, bool? epObligatoire, DateTime? dateDebut, DateTime? dateFin);
Task<IEnumerable<EpInformationDTO>> GetEPEnCoursCollaborateurParticipant(Guid? idCollaborateur);
Task<IEnumerable<EpInformationDTO>> GetEPEnCoursReferent(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPEnCoursReferentCount(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPEnCoursReferentCount(Guid? idReferent, string texte, DateTime? dateDebut, DateTime? dateFin);
Task<IEnumerable<EpInformationDTO>> GetEPSignes(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPSignesCount(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPSignesCount(List<long?> idBUs, string texte, DateTime? dateDebut, DateTime? dateFin);
Task<IEnumerable<EpInformationDTO>> GetEPSignesCollaborateur(Guid? idCollaborateur);
Task<IEnumerable<EpInformationDTO>> GetEPSignesReferent(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPSignesReferentCount(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
Task<int> GetEPSignesReferentCount(Guid? idReferent, string texte, DateTime? dateDebut, DateTime? dateFin);
Task<EpInformationDTO> GetProchainEPCollaborateur(Guid? idCollaborateur);

@ -13,7 +13,7 @@ namespace EPAServeur.IServices
Task<DetailsNoteDTO> AjouterNoteAsync(DetailsNoteDTO note);
Task<bool> SupprimerNoteAsync(long? idNote);
Task<DetailsNoteDTO> GetNoteByIdAsync(long? idNote);
Task<IEnumerable<AffichageNoteDTO>> GetNotesByAuteurAsync(Guid? idAuteur, bool? asc, int? numPage, int? parPAge, string texte, string tri);
Task<IEnumerable<AffichageNoteDTO>> GetNotesByAuteurAsync(Guid? idAuteur, bool? asc, int? numPage, int? parPage, string texte, string tri);
Task<int> GetNotesByAuteurCountAsync(Guid? idAuteur, string texte);
Task<DetailsNoteDTO> UpdateNoteAsync(long? idNote, DetailsNoteDTO note);

@ -17,6 +17,7 @@ namespace EPAServeur.IServices
AgenceDTO GetAgenceDTO(Agence agence);
BusinessUnitDTO GetBusinessUnitDTO(BU businessUnit);
CollaborateurDTO GetCollaborateurDTO(ParticipationFormation participationFormation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
CollaborateurDTO GetCollaborateurDTO(DemandeFormation demandeFormation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
#endregion
#region Demande de délégation
@ -41,6 +42,7 @@ namespace EPAServeur.IServices
ModeFormationDTO GetModeFormationDTO(ModeFormation modeFormation);
TypeFormationDTO GetTypeFormationDTO(TypeFormation typeFormation);
Formation SetFormation(Formation formation, FormationDTO formationDTO);
Formation GetFormation(FormationDetailsDTO formationDetailsDTO);
OrigineFormation GetOrigineFormation(OrigineFormationDTO origineFormationDTO);
StatutFormation GetStatutFormation(StatutFormationDTO statutFormationDTO);
ModeFormation GetModeFormation(ModeFormationDTO modeFormationDTO);
@ -77,6 +79,8 @@ namespace EPAServeur.IServices
List<CommentaireAssistantDTO> GetCommentaireAssistant(List<CommentaireAssistant> commentaireAssistant, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeDelegationDTO GetDemandeDelegationDTO(DemandeDelegation demandeDelegation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeEPIDTO GetDemandeEPIDTO(DemandeEPI demande, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation);
List<DemandeFormationDTO> GetDemandeFormationDTOs(List<DemandeFormation> demandes);
AugmentationSalaireDTO GetAugmentationSalaireDTO(AugmentationSalaire augmentation);
RDVEntretienDTO GetRDVEntretienDTO(RdvEntretien rdvEntretien);
TypeEntretienDTO GetTypeEntretienDTO(TypeEntretien typeEntretien);
@ -85,10 +89,14 @@ namespace EPAServeur.IServices
DocumentDTO GetDocumentDTO(Document document);
List<ObjectifDTO> GetObjectifDTOs(List<Objectif> objectifs);
List<ObjectifPrecedentDTO> GetObjectifPrecedentDTO(List<ObjectifPrecedent> objectifsPrecedents);
#endregion
#region Demande Formation
// DemandeFormation
DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation, IEnumerable<CollaborateurDTO> collaborateurDTOs);
DemandeFormation SetDemandeFormationWithoutParticipationFormationAndEp(DemandeFormation demandeFormation, DemandeFormationDTO demandeFormationDTO);
OrigineDemandeFormationDTO GetOrigineDemandeFormationDTO(OrigineDemande origineDemande);
OrigineDemande GetOrigineDemandeFormation(OrigineDemandeFormationDTO origineDemandeDTO);
#endregion
}
}

@ -49,7 +49,7 @@ namespace EPAServeur.Models.EP
/// <summary>
/// Id de l'EP
/// </summary>
public long IdEP { get; set; }
public long? IdEP { get; set; }
/// <summary>
/// EP qui est lié à la demande d'EPI

@ -18,7 +18,7 @@ namespace EPAServeur.Models.EP
/// <summary>
/// Id EP concernant le choix du rendez-vous
/// </summary>
public long IdEPChoixRDV { get; set; }
public long? IdEPChoixRDV { get; set; }
/// <summary>
/// Date proposée/prévue pour l’entretien

@ -65,8 +65,8 @@ namespace EPAServeur.Models.Formation
public ParticipationFormation ParticipationFormation { get; set; }
/// <summary>
/// Origine de formation qui est liée à la demande de formation
/// Origine de demande qui est liée à la demande de formation
/// </summary>
public OrigineFormation OrigineFormation { get; set; }
public OrigineDemande OrigineDemande { get; set; }
}
}

@ -19,10 +19,5 @@ namespace EPAServeur.Models.Formation
/// Libellé de l’origine de la demande de formation
/// </summary>
public string Libelle { get; set; }
/// <summary>
/// Liste des demandes de formation qui sont liées à l'origine de formation
/// </summary>
public List<DemandeFormation> DemandeFormations { get; set; }
}
}

@ -11,7 +11,7 @@
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchBrowser": false,
"launchUrl": "api/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"

@ -320,6 +320,21 @@ namespace EPAServeur.Services
return await GetCollaborateurDTOsAsync(guids);
}
/// <summary>
/// Récupérer une liste de CollaborateurDTO contenant les collaborateurs et les référents.
/// </summary>
/// <param name="demandeFormations"></param>
/// <returns></returns>
public async Task<IEnumerable<CollaborateurDTO>> GetCollaborateurDTOsAsync(IEnumerable<DemandeFormation> demandeFormations)
{
if (demandeFormations == null || !demandeFormations.Any())
return null;
List<Guid?> guids = demandeFormations.SelectMany(participationFormation => new[] { (Guid?)participationFormation.Ep.IdCollaborateur, participationFormation.Ep.IdReferent }).ToList();
return await GetCollaborateurDTOsAsync(guids);
}
/// <summary>
/// Récupérer le collaborateur et le référent qui sont présent dans l'EP qui est lié à l'engagement.

@ -0,0 +1,602 @@
using EPAServeur.Context;
using EPAServeur.Exceptions;
using EPAServeur.IServices;
using EPAServeur.Models.EP;
using EPAServeur.Models.Formation;
using EPAServeur.Models.SaisieChamp;
using IO.Swagger.DTO;
using IO.Swagger.Enum;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.Services
{
public class DemandeFormationService : IDemandeFormationService
{
#region Variables
/// <summary>
/// Accès et gestion de la base de données
/// </summary>
private readonly EpContext epContext;
/// <summary>
/// Accès au service collaborateur
/// </summary>
private readonly ICollaborateurService collaborateurService;
/// <summary>
/// Accès au service permettant de transformer un modèle en dto
/// </summary>
private readonly ITransformDTO transformDTO;
/// <summary>
/// Nombre d'éléments min à afficher par page
/// </summary>
private readonly int minParPage = 5;
/// <summary>
/// Nom d'éléments max à affichar par page
/// </summary>
private readonly int maxParPage = 100;
/// <summary>
/// Nombre d'éléments à afficher par défaut par page
/// </summary>
private readonly int defaultParPage = 15;
/// <summary>
/// Numéro de page min à afficher par défaut
/// </summary>
private readonly int defaultNumPage = 1;
/// <summary>
/// Ordonnancement par défaut
/// </summary>
private readonly bool defaultAsc = true;
#endregion
#region Contructeurs
/// <summary>
/// Constructeur de la classe FormationService
/// </summary>
/// <param name="_epContext"></param>
public DemandeFormationService(EpContext _epContext, ICollaborateurService _collaborateurService, ITransformDTO _transformDTO)
{
epContext = _epContext;
collaborateurService = _collaborateurService;
transformDTO = _transformDTO;
}
#endregion
#region Méthodes Service
/// <summary>
/// Récupérer la liste des origines des demandes de formation.
/// </summary>
/// <returns></returns>
public async Task<IEnumerable<OrigineDemandeFormationDTO>> GetOriginesDemandeFormationAsync()
{
IEnumerable<OrigineDemande> origineDemandes;
IEnumerable<OrigineDemandeFormationDTO> origineDemandeDTOs;
origineDemandes = await epContext.OrigineDemandeFormation.ToListAsync();
origineDemandeDTOs = origineDemandes.Select(origineFormation => transformDTO.GetOrigineDemandeFormationDTO(origineFormation));
return origineDemandeDTOs;
}
/// <summary>
/// Récupérer la liste des demandes de formation.
/// </summary>
/// <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&#x27;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&#x27;à laquelle les données sont récupérées</param>
/// <returns></returns>
public async Task<IEnumerable<DemandeFormationDTO>> GetDemandesFormationAsync(List<EtatDemande> etatsDemande, List<long?> idBUs, List<StatutEp> statutsEp, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
{
IQueryable<DemandeFormation> query;
IEnumerable<DemandeFormation> demandeFormations;
IEnumerable<DemandeFormationDTO> demandeFormationDTOs;
IEnumerable<CollaborateurDTO> collaborateurDTOs;
query = epContext.DemandeFormation
.Include(demandeFormation => demandeFormation.Ep)
.Include(demandeFormation => demandeFormation.OrigineDemande)
.Include(demandeFormation => demandeFormation.ParticipationFormation)
.ThenInclude(participationFormation => participationFormation.Formation);
query = StatutEpFilter(query, statutsEp);
query = EtatsDemandeFilter(query, etatsDemande);
query = IdBUsFilter(query, idBUs);
query = DateFilter(query, dateDebut, dateFin);
query = SkipAndTake(query, parPage, numPage);
demandeFormations = await query.ToListAsync();
collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(demandeFormations);
demandeFormationDTOs = demandeFormations.Select(demandeFormation => transformDTO.GetDemandeFormationDTO(demandeFormation, collaborateurDTOs));
demandeFormationDTOs = CollaborateurFilter(demandeFormationDTOs, texte);
demandeFormationDTOs = OrderByColumn(demandeFormationDTOs, asc, tri);
return demandeFormationDTOs;
}
/// <summary>
/// Récupérer le nombre total de demandes de formation.
/// </summary>
/// <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&#x27;à laquelle les données sont récupérées</param>
/// <returns></returns>
public async Task<long> GetDemandesFormationCountAsync(List<EtatDemande> etatsDemande, List<long?> idBUs, List<StatutEp> statutsEp, string texte, DateTime? dateDebut, DateTime? dateFin)
{
IQueryable<DemandeFormation> query;
IEnumerable<DemandeFormation> demandeFormations;
IEnumerable<DemandeFormationDTO> demandeFormationDTOs;
IEnumerable<CollaborateurDTO> collaborateurDTOs;
long count;
query = epContext.DemandeFormation
.Include(demandeFormation => demandeFormation.Ep)
.Include(demandeFormation => demandeFormation.ParticipationFormation)
.ThenInclude(participationFormation => participationFormation.Formation);
query = StatutEpFilter(query, statutsEp);
query = EtatsDemandeFilter(query, etatsDemande);
query = IdBUsFilter(query, idBUs);
query = DateFilter(query, dateDebut, dateFin);
demandeFormations = await query.ToListAsync();
collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(demandeFormations);
demandeFormationDTOs = demandeFormations.Select(demandeFormation => transformDTO.GetDemandeFormationDTO(demandeFormation, collaborateurDTOs));
demandeFormationDTOs = CollaborateurFilter(demandeFormationDTOs, texte);
count = demandeFormationDTOs.Count();
return count;
}
/// <summary>
/// Créer une demande de formation pour un collaborateur.
/// </summary>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <returns></returns>
public async Task<DemandeFormationDTO> AddDemandeFormationAsync(DemandeFormationDTO demandeFormationDTO)
{
IsDemandeFormationValide(demandeFormationDTO);
if (demandeFormationDTO.EtatDemande != EtatDemande.EnAttente)
throw new DemandeFormationInvalidException("Impossible de créer une demande de formation qui n'est pas en attente.");
string collaborateur = string.Format("{0} {1}", demandeFormationDTO.Collaborateur.Nom, demandeFormationDTO.Collaborateur.Prenom);
DemandeFormation demandeFormation = transformDTO.SetDemandeFormationWithoutParticipationFormationAndEp(new DemandeFormation(), demandeFormationDTO);
IEnumerable<StatutEp> statutsEp = Enum.GetValues(typeof(StatutEp)).Cast<StatutEp>().Where(statut => statut == StatutEp.Cree || EstEpEnCours(statut));
Ep ep = await epContext.Ep.Include(ep => ep.DemandesFormation)
.Where(ep => ep.IdCollaborateur == demandeFormationDTO.Collaborateur.Id && statutsEp.Contains(ep.Statut))
.OrderBy(ep => ep.DateDisponibilite).FirstOrDefaultAsync();
if (ep == null)
throw new DemandeFormationInvalidException(string.Format("Il n'existe aucun EP en cours ou créé pour le collaborateur {0}.", collaborateur));
ep.DemandesFormation.Add(demandeFormation);
await epContext.SaveChangesAsync();
demandeFormationDTO.Id = demandeFormation.IdDemandeFormation;
return demandeFormationDTO;
}
/// <summary>
/// Répondre à une demande de formation.
/// </summary>
/// <param name="idDemandeFormation"></param>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationIncompatibleIdException"></exception>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <returns></returns>
public async Task<DemandeFormationDTO> UpdateDemandeFormationAsync(long idDemandeFormation, DemandeFormationDTO demandeFormationDTO)
{
IsDemandeFormationValide(demandeFormationDTO);
if (!demandeFormationDTO.Id.HasValue || demandeFormationDTO.Id.Value != idDemandeFormation)
throw new DemandeFormationIncompatibleIdException("La demande de formation ne correspond pas avec l'identifiant reçu.");
switch (demandeFormationDTO.EtatDemande)
{
case EtatDemande.EnAttente:
throw new DemandeFormationInvalidException("La demande ne peut pas être mise à jour si aucune réponse n'a été donnée.");
case EtatDemande.Validee:
demandeFormationDTO = await AccepterDemandeFormation(idDemandeFormation, demandeFormationDTO);
break;
case EtatDemande.Rejetee:
demandeFormationDTO = await RefuserDemandeFormation(idDemandeFormation, demandeFormationDTO);
break;
}
return demandeFormationDTO;
}
/// <summary>
/// Supprimer une demande de formation.
/// </summary>
/// <param name="idDemandeFormation"></param>
/// <returns></returns>
public async Task<bool> DeleteDemandeFormationAsync(long idDemandeFormation)
{
IEnumerable<StatutEp> statutsEp = Enum.GetValues(typeof(StatutEp)).Cast<StatutEp>().Where(statut => statut == StatutEp.Cree || EstEpEnCours(statut));
DemandeFormation demandeFormation = await epContext.DemandeFormation.Include(demandeFormation => demandeFormation.Ep)
.FirstOrDefaultAsync(demandeFormation => demandeFormation.IdDemandeFormation == idDemandeFormation);
if (demandeFormation == null)
throw new DemandeFormationNotFoundException("Aucune demande de formation n'a été trouvée.");
if (!statutsEp.Contains(demandeFormation.Ep.Statut))
throw new DemandeFormationInvalidException(string.Format("L'EP {1} qui est rattaché à la demande de formation {0} n'est ni créé ni en cours. Statut de l'EP {1}: {2}.", demandeFormation.IdDemandeFormation, demandeFormation.Ep.IdEP, demandeFormation.Ep.Statut));
epContext.Remove(demandeFormation);
await epContext.SaveChangesAsync();
return true;
}
#endregion
#region Méthodes Privée
/// <summary>
/// Accepter une demande de formation.
/// </summary>
/// <remarks>Créer une participation formation et associe cette dernière la demande de formation</remarks>
/// <param name="idDemandeFormation"></param>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationNotFoundException"></exception>
/// <returns></returns>
private async Task<DemandeFormationDTO> AccepterDemandeFormation(long idDemandeFormation, DemandeFormationDTO demandeFormationDTO)
{
// Vérifier que la demande de formation a bien une formation
if (demandeFormationDTO.Formation == null || !demandeFormationDTO.Formation.Id.HasValue)
throw new DemandeFormationInvalidException("Une formation est requise pour accepter une demande de formation.");
DemandeFormation demandeFormation = await epContext.DemandeFormation.Include(d => d.ParticipationFormation)
.Include(d => d.Ep)
.FirstOrDefaultAsync(d => d.IdDemandeFormation == idDemandeFormation);
if (demandeFormation == null)
throw new DemandeFormationNotFoundException("Aucune demande de formation n'a été trouvée.");
Guid idCollaborateur = demandeFormation.Ep.IdCollaborateur; // devra être utilisé pour notifier le collaborateur
DateTime dateNow = DateTime.Now;
Formation formation = transformDTO.GetFormation(demandeFormationDTO.Formation);
ParticipationFormation participationFormation = new ParticipationFormation { DateCreation = dateNow, Formation = formation };
demandeFormation.Etat = demandeFormationDTO.EtatDemande;
demandeFormation.DateDerniereReponse = dateNow;
demandeFormation.ParticipationFormation = participationFormation;
await epContext.SaveChangesAsync();
int nbParticipations = await epContext.ParticipationFormation.Include(p => p.DemandeFormation).Where(p => p.Formation.IdFormation == formation.IdFormation).CountAsync();
demandeFormationDTO.EtatDemande = demandeFormation.Etat;
demandeFormationDTO.DateDerniereReponse = demandeFormation.DateDerniereReponse;
demandeFormationDTO.Formation.NbParticipations = nbParticipations;
return demandeFormationDTO;
}
/// <summary>
/// Refuser une demande de formation.
/// </summary>
/// <remarks>Supprime la participation formation qui est liée à la demande de formation</remarks>
/// <param name="idDemandeFormation"></param>
/// <param name="demandeFormationDTO"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationNotFoundException"></exception>
/// <returns></returns>
private async Task<DemandeFormationDTO> RefuserDemandeFormation(long idDemandeFormation, DemandeFormationDTO demandeFormationDTO)
{
// Vérifier que la demande de formation a bien un commentaire expliquant la raison pour laquelle la demande a été refusée
if (string.IsNullOrWhiteSpace(demandeFormationDTO.CommentaireRefus))
throw new DemandeFormationInvalidException("Un commentaire expliquant la raison pour laquelle la demande a été refusée est requis.");
DemandeFormation demandeFormation = await epContext.DemandeFormation.Include(d => d.ParticipationFormation)
.Include(d => d.Ep)
.FirstOrDefaultAsync(d => d.IdDemandeFormation == idDemandeFormation);
if (demandeFormation == null)
throw new DemandeFormationNotFoundException("Aucune demande de formation n'a été trouvée.");
Guid idCollaborateur = demandeFormation.Ep.IdCollaborateur; // devra être utilisé pour notifier le collaborateur
demandeFormation.Etat = demandeFormationDTO.EtatDemande;
demandeFormation.CommentaireRefus = demandeFormationDTO.CommentaireRefus;
demandeFormation.DateDerniereReponse = DateTime.Now;
if (demandeFormation.ParticipationFormation != null)
epContext.Remove(demandeFormation.ParticipationFormation);
await epContext.SaveChangesAsync();
if (demandeFormationDTO.Formation != null && demandeFormationDTO.Formation.Id.HasValue)
{
int nbParticipations = await epContext.ParticipationFormation.Include(p => p.DemandeFormation).Where(p => p.Formation.IdFormation == demandeFormationDTO.Formation.Id.Value).CountAsync();
demandeFormationDTO.Formation.NbParticipations = nbParticipations;
}
demandeFormationDTO.EtatDemande = demandeFormation.Etat;
demandeFormationDTO.DateDerniereReponse = demandeFormation.DateDerniereReponse;
return demandeFormationDTO;
}
/// <summary>
/// Vérifier si un objet DemandeFormationDTO est valide pour une mise à jour.
/// </summary>
/// <remarks>
/// Un objet DemandeFormationDTO est valide si l'objet n'est pas null, si le libellé, la descritpion,
/// la date de demande de début et la valeur permettant de dire si la demande a été créé par une RH ou non ne sont pas null.
/// </remarks>
/// <param name="demande"></param>
/// <exception cref="EPAServeur.Exceptions.DemandeFormationInvalidException"></exception>
/// <returns>true si l'objet est valide, false sinon</returns>
private void IsDemandeFormationValide(DemandeFormationDTO demande)
{
// Vérifier que la demande de formation n'est pas null
if (demande == null)
throw new DemandeFormationInvalidException("Aucune évaluation n'a été reçue.");
// Vérifier que la demande de formation a bien un libellé
if (string.IsNullOrWhiteSpace(demande.Libelle))
throw new DemandeFormationInvalidException("Le libellé de la demande de formation doit contenir au moins 1 caractère.");
// Vérifier que la demande de formation a bien une description
if (string.IsNullOrWhiteSpace(demande.Description))
throw new DemandeFormationInvalidException("La description de la demande de formation doit contenir au moins 1 caractère.");
// Vérifier que la demande de formation a bien une valeur permettant de dire s'il s'agit d'une demande créée par une RH ou non
if (!demande.DemandeRH.HasValue)
throw new DemandeFormationInvalidException("Impossible de répondre à une demande de formation sans savoir si la demande a été créé par une RH ou non.");
// Vérifier que la demande de formation a bien une date de demande
if (!demande.DateDemande.HasValue)
throw new DemandeFormationInvalidException("Une date de demande de formation est requise.");
// Vérifier que la demande de formation a bien un collaborateur
if (demande.Collaborateur == null || !demande.Collaborateur.Id.HasValue)
throw new DemandeFormationInvalidException("Un collaborateur est requis pour une demande de formation.");
// Vérifier que la demande de formation a bien un collaborateur
if (demande.Origine == null || !demande.Origine.Id.HasValue)
throw new DemandeFormationInvalidException("Une origine de formation est requise pour une demande de formation.");
}
/// <summary>
/// Ajouter un ordonnancement croissant ou décroissant sur une colonne.
/// </summary>
/// <param name="query"></param>
/// <param name="asc"></param>
/// <param name="columnName"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByColumn(IEnumerable<DemandeFormationDTO> query, bool? asc, string columnName)
{
if (!asc.HasValue)
asc = defaultAsc;
if (string.IsNullOrWhiteSpace(columnName))
return OrderByDefault(query, (bool)asc);
if ((bool)asc)
return OrderByAscending(query, columnName);
else
return OrderByDescending(query, columnName);
}
/// <summary>
/// Ajouter un ordonnancement croissant sur une colonne.
/// </summary>
/// <param name="query"></param>
/// <param name="columnName"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByAscending(IEnumerable<DemandeFormationDTO> query, string columnName)
{
switch (columnName.ToLower())
{
case "businessunit":
return query.OrderBy(d => d.Collaborateur.BusinessUnit.Nom);
case "collaborateur":
return query.OrderBy(d => d.Collaborateur.Nom);
case "datedemande":
return query.OrderBy(d => d.DateDemande);
case "demanderh":
return query.OrderBy(d => d.DemandeRH);
case "etat":
return query.OrderBy(d => d.EtatDemande);
case "datereponse":
return query.OrderBy(d => d.DateDerniereReponse);
default:
return query.OrderBy(p => p.Collaborateur.Nom);
}
}
/// <summary>
/// Ajouter un ordonnancement décroissant sur une colonne.
/// </summary>
/// <param name="query"></param>
/// <param name="columnName"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByDescending(IEnumerable<DemandeFormationDTO> query, string columnName)
{
switch (columnName.ToLower())
{
case "businessunit":
return query.OrderByDescending(d => d.Collaborateur.BusinessUnit.Nom);
case "collaborateur":
return query.OrderByDescending(d => d.Collaborateur.Nom);
case "datedemande":
return query.OrderByDescending(d => d.DateDemande);
case "demanderh":
return query.OrderByDescending(d => d.DemandeRH);
case "etat":
return query.OrderByDescending(d => d.EtatDemande);
case "datereponse":
return query.OrderByDescending(d => d.DateDerniereReponse);
default:
return query.OrderByDescending(d => d.Collaborateur.Nom);
}
}
/// <summary>
/// Ajouter un ordonnancement par défaut.
/// </summary>
/// <param name="query"></param>
/// <param name="asc"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> OrderByDefault(IEnumerable<DemandeFormationDTO> query, bool asc)
{
if (asc)
return query.OrderBy(p => p.Collaborateur.Nom);
else
return query.OrderByDescending(p => p.Collaborateur.Nom);
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction du statut de l'EP.
/// </summary>
/// <param name="query"></param>
/// <param name="statutsEp"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> StatutEpFilter(IQueryable<DemandeFormation> query, List<StatutEp> statutsEp)
{
if (statutsEp != null && statutsEp.Count > 0)
return query.Where(demandeFormation => statutsEp.Contains(demandeFormation.Ep.Statut));
else
return query;
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction de plusieurs états de demande.
/// </summary>
/// <param name="query"></param>
/// <param name="etatsDemande"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> EtatsDemandeFilter(IQueryable<DemandeFormation> query, List<EtatDemande> etatsDemande)
{
if (etatsDemande != null && etatsDemande.Count > 0)
return query.Where(demandeFormation => etatsDemande.Contains(demandeFormation.Etat));
else
return query;
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction de l'id BU des collaborateurs.
/// </summary>
/// <param name="query"></param>
/// <param name="idBus"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> IdBUsFilter(IQueryable<DemandeFormation> query, List<long?> idBus)
{
if (idBus != null && idBus.Count > 0)
return query.Where(demandeFormation => idBus.Contains(demandeFormation.Ep.IdBu));
else
return query;
}
/// <summary>
/// Ajouter un filtre pour récupérer les formations en fonction d'un intervalle de date.
/// </summary>
/// <param name="query"></param>
/// <param name="dateDebut"></param>
/// <param name="dateFin"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> DateFilter(IQueryable<DemandeFormation> query, DateTime? dateDebut, DateTime? dateFin)
{
if (dateDebut.HasValue && dateFin.HasValue)
return query.Where(demandeFormation => demandeFormation.DateDemande >= dateDebut.Value && demandeFormation.DateDemande <= dateFin.Value.AddDays(1));
else if (!dateDebut.HasValue && dateFin.HasValue)
return query.Where(demandeFormation => demandeFormation.DateDemande <= dateFin.Value.AddDays(1));
else if (dateDebut.HasValue && !dateFin.HasValue)
return query.Where(demandeFormation => demandeFormation.DateDemande >= dateDebut.Value);
else
return query;
}
/// <summary>
/// Ajouter un filtre pour récupérer les demandes de formation en fonction du nom et du prénom du collaborateur.
/// </summary>
/// <param name="demandeFormationDTOs"></param>
/// <param name="intitule"></param>
/// <returns></returns>
private IEnumerable<DemandeFormationDTO> CollaborateurFilter(IEnumerable<DemandeFormationDTO> demandeFormationDTOs, string texte)
{
if (string.IsNullOrWhiteSpace(texte))
return demandeFormationDTOs;
return demandeFormationDTOs.Where(demandeFormation => (demandeFormation.Ep.Collaborateur.Nom + " " + demandeFormation.Ep.Collaborateur.Prenom).ToLower().Contains(texte.ToLower()) ||
(demandeFormation.Ep.Collaborateur.Prenom + " " + demandeFormation.Ep.Collaborateur.Nom).ToLower().Contains(texte.ToLower()));
}
/// <summary>
/// Ajouter une pagination.
/// </summary>
/// <param name="query"></param>
/// <param name="parPage"></param>
/// <param name="numPage"></param>
/// <returns></returns>
private IQueryable<DemandeFormation> SkipAndTake(IQueryable<DemandeFormation> query, int? parPage, int? numPage)
{
int skip, take;
if (!parPage.HasValue || parPage.Value < minParPage || parPage.Value > maxParPage)
parPage = defaultParPage;
if (!numPage.HasValue || numPage.Value <= 0)
numPage = defaultNumPage;
skip = (numPage.Value - 1) * parPage.Value;
take = parPage.Value;
return query.Skip(skip).Take(take);
}
private bool EstEpEnCours(StatutEp statut)
{
return statut != StatutEp.Annule && statut != StatutEp.Cree && statut != StatutEp.Rejete && statut != StatutEp.Signe;
}
#endregion
}
}

@ -24,7 +24,7 @@ namespace EPAServeur.Services
this.collaborateurService = collaborateurService;
}
public async Task<EpDTO> GetEp(long id)
public async Task<EpDTO> GetEp(long? id)
{
Ep ep = await context.Ep
.Include(ep => ep.Engagements)
@ -37,6 +37,7 @@ namespace EPAServeur.Services
.Include(ep => ep.Objectifs)
.Include(ep => ep.ObjectifsPrecedents)
.Include(ep => ep.DemandeEPI)
.Include(ep => ep.DemandesFormation)
.FirstOrDefaultAsync(ep => ep.IdEP.Equals(id));
if (ep == null)
throw new EpNotFoundException();
@ -57,6 +58,7 @@ namespace EPAServeur.Services
if (ep.DemandeEPI != null && ep.DemandeEPI.IdReferent != null)
guids.Add(ep.DemandeEPI.IdReferent);
IEnumerable<CollaborateurDTO> collaborateurDTOs = await collaborateurService.GetCollaborateurDTOsAsync(guids);
EpDTO epDTO = transformDTO.EpToEpDetails(ep, collaborateurDTOs);
@ -64,7 +66,7 @@ namespace EPAServeur.Services
return epDTO;
}
public void RappelSignature(long idEp)
public void RappelSignature(long? idEp)
{
throw new NotImplementedException();
}
@ -74,7 +76,7 @@ namespace EPAServeur.Services
throw new NotImplementedException();
}
public Task<EpDTO> SaisirEPReferent(long idEp)
public Task<EpDTO> SaisirEPReferent(long? idEp)
{
throw new NotImplementedException();
}
@ -84,17 +86,17 @@ namespace EPAServeur.Services
throw new NotImplementedException();
}
public void SupprimerEP(long idEp)
public void SupprimerEP(long? idEp)
{
throw new NotImplementedException();
}
public Task<EpDTO> UpdateEP(long idEp, EpDTO ep)
public Task<EpDTO> UpdateEP(long? idEp, EpDTO ep)
{
throw new NotImplementedException();
}
public Task<EpDTO> UpdateSaisie(long idEp, EpDTO ep)
public Task<EpDTO> UpdateSaisie(long? idEp, EpDTO ep)
{
throw new NotImplementedException();
}

@ -55,20 +55,22 @@ namespace EPAServeur.Services
#region Services async
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCours(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
public async Task<IEnumerable<EpInformationDTO>> GetEPEnCours(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, bool? epObligatoire, string tri, DateTime? dateDebut, DateTime? dateFin)
{
IEnumerable<Ep> eps = context.Ep.Where(ep => idBUs.Contains(ep.IdBu)).AsEnumerable().Where(ep => EstEpEnCours(ep.Statut));
if (epObligatoire.HasValue && epObligatoire.Value)
eps = eps.Where(ep => ep.Obligatoire);
return await GetEpInformationDTOs(eps, asc, numPage, parPage, texte, tri, dateDebut, dateFin);
}
public async Task<int> GetEPEnCoursCount(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
public async Task<int> GetEPEnCoursCount(List<long?> idBUs, string texte, bool? epObligatoire, DateTime? dateDebut, DateTime? dateFin)
{
IEnumerable<Ep> eps = context.Ep.Where(ep => idBUs.Contains(ep.IdBu)).AsEnumerable().Where(ep => EstEpEnCours(ep.Statut));
if (epObligatoire.HasValue && epObligatoire.Value)
eps = eps.Where(ep => ep.Obligatoire);
return await GetEpInformationDTOsCount(eps, texte, dateDebut, dateFin);
}
@ -84,7 +86,7 @@ namespace EPAServeur.Services
return await GetEpInformationDTOs(eps, asc, numPage, parPage, texte, tri, dateDebut, dateFin);
}
public async Task<int> GetEPEnCoursReferentCount(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
public async Task<int> GetEPEnCoursReferentCount(Guid? idReferent, string texte, DateTime? dateDebut, DateTime? dateFin)
{
IEnumerable<Ep> eps = context.Ep.Where(ep => ep.IdReferent.Equals(idReferent)).AsEnumerable().Where(ep => EstEpEnCours(ep.Statut));
@ -105,7 +107,7 @@ namespace EPAServeur.Services
return await GetEpInformationDTOs(eps, true, 1, maxParPage, "", "", null, null);
}
public async Task<int> GetEPSignesCount(List<long?> idBUs, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
public async Task<int> GetEPSignesCount(List<long?> idBUs, string texte, DateTime? dateDebut, DateTime? dateFin)
{
IEnumerable<Ep> eps = context.Ep.Where(ep => idBUs.Contains(ep.IdBu)).Where(ep => ep.Statut == StatutEp.Signe);
@ -118,7 +120,7 @@ namespace EPAServeur.Services
return await GetEpInformationDTOs(eps, asc, numPage, parPage, texte, tri, dateDebut, dateFin);
}
public async Task<int> GetEPSignesReferentCount(Guid? idReferent, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin)
public async Task<int> GetEPSignesReferentCount(Guid? idReferent, string texte, DateTime? dateDebut, DateTime? dateFin)
{
IEnumerable<Ep> eps = context.Ep.Where(ep => ep.IdReferent.Equals(idReferent)).Where(ep => ep.Statut.Equals(StatutEp.Signe));
return await GetEpInformationDTOsCount(eps, texte, dateDebut, dateFin);

@ -211,6 +211,7 @@ namespace EPAServeur.Services
noteToUpdate.Texte = note.Texte;
noteToUpdate.DateMiseAJour = DateTime.Now;
note.DateMiseAjour = noteToUpdate.DateMiseAJour;
await context.SaveChangesAsync();
return note;
}
#endregion

@ -1,18 +1,15 @@
using EPAServeur.Context;
using EPAServeur.Exceptions;
using EPAServeur.Exceptions;
using EPAServeur.IServices;
using EPAServeur.Models.EP;
using EPAServeur.Models.Formation;
using EPAServeur.Models.Notes;
using EPAServeur.Models.SaisieChamp;
using IO.Swagger.ApiCollaborateur;
using IO.Swagger.DTO;
using IO.Swagger.Enum;
using IO.Swagger.ModelCollaborateur;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.Services
{
@ -70,7 +67,9 @@ namespace EPAServeur.Services
ChoixTypeEntretien = GetTypeEntretienDTOs(ep.ChoixTypeEntretien),
Objectifs = GetObjectifDTOs(ep.Objectifs),
ObjectifsPrecedent = GetObjectifPrecedentDTO(ep.ObjectifsPrecedents),
DemandeEPI = GetDemandeEPIDTO(ep.DemandeEPI, collaborateurDTOs)
DemandeEPI = GetDemandeEPIDTO(ep.DemandeEPI, collaborateurDTOs),
DemandesFormation = GetDemandeFormationDTOs(ep.DemandesFormation)
};
}
@ -237,6 +236,22 @@ namespace EPAServeur.Services
return commentaireAssistantDTO.Any() ? commentaireAssistantDTO : null;
}
/// <summary>
/// Récupérer le collaborateur qui a fait une demande de formation.
/// </summary>
/// <param name="demandeFormation"></param>
/// <param name="collaborateurDTOs"></param>
/// <returns></returns>
public CollaborateurDTO GetCollaborateurDTO(DemandeFormation demandeFormation, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
if (demandeFormation == null)
return null;
if (collaborateurDTOs == null || !collaborateurDTOs.Any())
return null;
return collaborateurDTOs.FirstOrDefault(collaborateurDTO => collaborateurDTO.Id == demandeFormation.Ep.IdCollaborateur);
}
/// <summary>
/// Transformer un objet DemandeDelegation en objet DemandeDelegationDTO.
@ -306,9 +321,20 @@ namespace EPAServeur.Services
}
public DemandeFormationDTO GetDemandeFormationDTOEP(DemandeFormation demandeFormation)
public DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation)
{
throw new NotImplementedException();
if (demandeFormation == null)
return null;
return new DemandeFormationDTO()
{
CommentaireRefus = demandeFormation.CommentaireRefus,
DemandeRH = demandeFormation.DemandeRH,
Libelle = demandeFormation.Libelle,
EtatDemande = demandeFormation.Etat,
Description = demandeFormation.Description,
DateDemande = demandeFormation.DateDemande,
};
}
@ -653,6 +679,63 @@ namespace EPAServeur.Services
return participationFormationDTOs;
}
// <summary>
/// Récuperer un objet OrigineDemandeFormationDTO en fonction d'un objet OrigineDemande
/// </summary>
/// <param name="origineDemande"></param>
/// <returns></returns>
public OrigineDemandeFormationDTO GetOrigineDemandeFormationDTO(OrigineDemande origineDemande)
{
if (origineDemande == null)
return null;
OrigineDemandeFormationDTO origineDemandeFormationDTO = new OrigineDemandeFormationDTO()
{
Id = origineDemande.IdOrigineDemande,
Libelle = origineDemande.Libelle
};
return origineDemandeFormationDTO;
}
/// <summary>
/// Récuperer un objet DemandeFormationDTO en fonction d'un objet DemandeFormation et d'une liste de CollaborateurDTO
/// </summary>
/// <param name="demandeFormation"></param>
/// <returns></returns>
public DemandeFormationDTO GetDemandeFormationDTO(DemandeFormation demandeFormation, IEnumerable<CollaborateurDTO> collaborateurDTOs)
{
if (demandeFormation == null)
return null;
if (collaborateurDTOs == null || !collaborateurDTOs.Any())
return null;
Formation formation;
if (demandeFormation.ParticipationFormation != null)
formation = demandeFormation.ParticipationFormation.Formation;
else
formation = null;
DemandeFormationDTO demandeFormationDTO = new DemandeFormationDTO()
{
Id = demandeFormation.IdDemandeFormation,
Libelle = demandeFormation.Libelle,
Description = demandeFormation.Description,
DemandeRH = demandeFormation.DemandeRH,
DateDemande = demandeFormation.DateDemande,
EtatDemande = demandeFormation.Etat,
CommentaireRefus = demandeFormation.CommentaireRefus,
DateDerniereReponse = demandeFormation.DateDerniereReponse,
Origine = GetOrigineDemandeFormationDTO(demandeFormation.OrigineDemande),
Collaborateur = GetCollaborateurDTO(demandeFormation, collaborateurDTOs),
Ep = GetEpInformationDTO(demandeFormation.Ep, collaborateurDTOs),
Formation = GetFormationDetailsDTO(formation)
};
return demandeFormationDTO;
}
public RDVEntretienDTO GetRDVEntretienDTO(RdvEntretien rdvEntretien)
{
@ -849,6 +932,49 @@ namespace EPAServeur.Services
return details;
}
// <summary>
/// Récupérer un objet OrigineDemande en fonction d'un objet OrigineDemandeFormationDTO
/// </summary>
/// <param name="origineDemande"></param>
/// <returns></returns>
public OrigineDemande GetOrigineDemandeFormation(OrigineDemandeFormationDTO origineDemandeDTO)
{
if (origineDemandeDTO == null)
return null;
OrigineDemande origineDemandeFormation = new OrigineDemande()
{
IdOrigineDemande = origineDemandeDTO.Id.Value,
Libelle = origineDemandeDTO.Libelle
};
return origineDemandeFormation;
}
/// <summary>
/// Mettre à jour un objet DemandeFormation en fonction d'un objet DemandeFormationDTO.
/// </summary>
/// <remarks>Les propriétés ParticipationFormation et Ep ne sont pas mise à jour.</remarks>
/// <param name="formation"></param>
/// <param name="formationDTO"></param>
/// <returns></returns>
public DemandeFormation SetDemandeFormationWithoutParticipationFormationAndEp(DemandeFormation demandeFormation, DemandeFormationDTO demandeFormationDTO)
{
if (demandeFormation == null || demandeFormationDTO == null)
return null;
demandeFormation.Libelle = demandeFormationDTO.Libelle;
demandeFormation.Description = demandeFormationDTO.Description;
demandeFormation.DemandeRH = demandeFormationDTO.DemandeRH.Value;
demandeFormation.DateDemande = demandeFormationDTO.DateDemande.Value;
demandeFormation.Etat = demandeFormationDTO.EtatDemande;
demandeFormation.CommentaireRefus = demandeFormationDTO.CommentaireRefus;
demandeFormation.DateDerniereReponse = demandeFormationDTO.DateDerniereReponse;
demandeFormation.OrigineDemande = GetOrigineDemandeFormation(demandeFormationDTO.Origine);
return demandeFormation;
}
/// <summary>
/// Mettre à jour un objet Formation en fonction d'un objet FormationDTO.
/// </summary>
@ -860,6 +986,9 @@ namespace EPAServeur.Services
if (formation == null || formationDTO == null)
return null;
if (formationDTO.Id.HasValue)
formation.IdFormation = formationDTO.Id.Value;
formation.Intitule = formationDTO.Intitule;
formation.IdAgence = formationDTO.IdAgence.Value;
formation.DateDebut = formationDTO.DateDebut.Value;
@ -877,6 +1006,34 @@ namespace EPAServeur.Services
return formation;
}
/// <summary>
/// Récupérer un objet Formation en fonction d'un objet FormationDetailsDTO.
/// </summary>
/// <param name="formationDetailsDTO"></param>
/// <returns></returns>
public Formation GetFormation(FormationDetailsDTO formationDetailsDTO)
{
if (formationDetailsDTO == null)
return null;
Formation formation = new Formation
{
Intitule = formationDetailsDTO.Intitule,
DateDebut = formationDetailsDTO.DateDebut.Value,
DateFin = formationDetailsDTO.DateFin.Value,
Organisme = formationDetailsDTO.Organisme,
EstCertifiee = formationDetailsDTO.EstCertifiee.Value,
//EstRealisee = formationDTO.EstRealisee.Value,
Origine = GetOrigineFormation(formationDetailsDTO.Origine),
Statut = GetStatutFormation(formationDetailsDTO.Statut),
};
if (formationDetailsDTO.Id.HasValue)
formation.IdFormation = formationDetailsDTO.Id.Value;
return formation;
}
/// <summary>
/// Mettre à jour la réponse d'un objet Engagement en fonction d'un objet EngagementDTO.
/// </summary>
@ -929,5 +1086,12 @@ namespace EPAServeur.Services
Commentaire = o.Commentaire
}).ToList();
}
public List<DemandeFormationDTO> GetDemandeFormationDTOs(List<DemandeFormation> demandes)
{
if (demandes == null || !demandes.Any())
return null;
return demandes.Select(d => GetDemandeFormationDTO(d)).ToList();
}
}
}

@ -109,8 +109,8 @@ namespace EPAServeur
DataSeeder.AddChamps(context);
DataSeeder.AddNotes(context);
DataSeeder.AddDemandeDelegationEP(context);
DataSeeder.AddEp(context);
DataSeeder.AddEngagements(context);
DataSeeder.AddEp(context);
DataSeeder.AddRereferentEP(context);
}
//faire using, check si kekchoz exkist puis appeler les m<EFBFBD>thodes de cr<EFBFBD>ation si il n'y a rien
@ -127,6 +127,7 @@ namespace EPAServeur
services.AddScoped<IEpInformationService, EpInformationService>();
services.AddScoped<IEpDetailsService, EpDetailsService>();
services.AddScoped<IFormationService, FormationService>();
services.AddScoped<IDemandeFormationService, DemandeFormationService>();
services.AddScoped<IParticipationFormationService, ParticipationFormationService>();
services.AddScoped<INoteService, NoteService>();
services.AddScoped<IReferentEPService, ReferentEPService>();

Loading…
Cancel
Save