Merge branch 'formation' into develop

develop
jboinembalome 4 years ago
commit d75ee2b391
  1. 526
      EPAServeur.Tests/Controllers/FormationApiTests.cs
  2. 5
      EPAServeur.Tests/EPAServeur.Tests.csproj
  3. 7
      EPAServeur.Tests/Properties/launchSettings.json
  4. 922
      EPAServeur.Tests/Services/FormationServiceTests.cs
  5. 589
      EPAServeur/Context/DataSeeder.cs
  6. 1
      EPAServeur/Context/EpContext.cs
  7. 572
      EPAServeur/Controllers/FormationsApi.cs
  8. 16
      EPAServeur/DTO/FormationDetailsDTO.cs
  9. 8
      EPAServeur/Exceptions/EngagementIncompatibleIdException.cs
  10. 8
      EPAServeur/Exceptions/EngagementInvalidException.cs
  11. 2
      EPAServeur/Exceptions/EngagementNotFoundException.cs
  12. 2
      EPAServeur/Exceptions/FormationIncompatibleIdException.cs
  13. 8
      EPAServeur/Exceptions/FormationInvalidException.cs
  14. 2
      EPAServeur/Exceptions/FormationNotFoundException.cs
  15. 2
      EPAServeur/Exceptions/ModeFormationNotFoundException.cs
  16. 2
      EPAServeur/Exceptions/OrigineFormationNotFoundException.cs
  17. 2
      EPAServeur/Exceptions/StatutFormationNotFoundException.cs
  18. 2
      EPAServeur/Exceptions/TypeFormationNotFoundException.cs
  19. 24
      EPAServeur/IServices/IFormationService.cs
  20. 5
      EPAServeur/Models/Formation/Formation.cs
  21. 990
      EPAServeur/Services/FormationService.cs

@ -13,6 +13,12 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using EPAServeur.IServices;
using Moq;
using IO.Swagger.ApiCollaborateur;
namespace EPAServeur.Tests.Controllers namespace EPAServeur.Tests.Controllers
{ {
@ -21,9 +27,9 @@ namespace EPAServeur.Tests.Controllers
{ {
#region Variables #region Variables
private FormationService formationService; private IFormationService formationService;
private readonly ILogger<FormationsApiController> logger; private Mock<IWebHostEnvironment> mockEnvironment;
private EpContext epContext;
#endregion #endregion
#region Setup #region Setup
@ -31,12 +37,17 @@ namespace EPAServeur.Tests.Controllers
[SetUp] [SetUp]
public void 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 // Utilisation d'une base de données en mémoire
var optionBuider = new DbContextOptionsBuilder<EpContext>() var optionBuider = new DbContextOptionsBuilder<EpContext>()
.UseInMemoryDatabase("server_ep_test") .UseInMemoryDatabase("server_ep_test")
.Options; .Options;
EpContext epContext = new EpContext(optionBuider); services.AddDbContext<EpContext>(b => b.UseInMemoryDatabase("server_ep_test"));
epContext = new EpContext(optionBuider);
epContext.Database.EnsureDeleted(); epContext.Database.EnsureDeleted();
epContext.Database.EnsureCreated(); epContext.Database.EnsureCreated();
@ -52,8 +63,21 @@ namespace EPAServeur.Tests.Controllers
entity.State = EntityState.Detached; entity.State = EntityState.Detached;
} }
// Instanciation du service qui sera utilisé dans le controleur services.AddScoped<ICollaborateurApi, CollaborateurApi>();
formationService = new FormationService(epContext); services.AddScoped<ICollaborateurService, CollaborateurService>();
services.AddScoped<IFormationService, FormationService>();
// Récupère le service qui sera utilsé pour tester le contrôleur
var serviceProvider = services.BuildServiceProvider();
formationService = serviceProvider.GetService<IFormationService>();
// Simule l'interface IWebHostEnvironment avec Moq
mockEnvironment = new Mock<IWebHostEnvironment>();
mockEnvironment
.Setup(m => m.EnvironmentName)
.Returns("Development");
} }
#endregion #endregion
@ -61,127 +85,521 @@ namespace EPAServeur.Tests.Controllers
#region Tests GetFormationById #region Tests GetFormationById
[Test] [Test]
public void GetFormationById_PasseEnParamUnIdPresentDansLaBDD_RetourneUnObjetOkResult() public void GetById_PasseEnParamUnIdInconnu_RetourneUnObjetNotFoundResult()
{ {
//// Arrange // Arrange
//FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>()); FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
// // Act // Act
// var okResult = formationsApiController.GetFormationById(1); var notFoundResult = formationsApiController.GetFormationById(99999);
//// Assert // Assert
//Assert.IsInstanceOf<OkObjectResult>(okResult.Result); Assert.IsInstanceOf<NotFoundObjectResult>(notFoundResult.Result);
} }
[Test]
public void GetFormationById_PasseEnParamUnIdConnu_RetourneUnObjetOkResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
#endregion // Act
var okResult = formationsApiController.GetFormationById(1);
#region Tests GetFormations // Assert
Assert.IsInstanceOf<OkObjectResult>(okResult.Result);
}
// Arrange
// Act [Test]
public void GetFormationById_PasseEnParamUnIdConnu_RetourneLaBonneFormation()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
long idFormation = 1;
// Assert // Act
var okResult = formationsApiController.GetFormationById(idFormation).Result as OkObjectResult;
// Assert
Assert.IsInstanceOf<FormationDTO>(okResult.Value);
Assert.AreEqual(idFormation, (okResult.Value as FormationDTO).Id);
}
#endregion #endregion
#region Tests GetFormationAnnulees #region Tests GetFormations
// Arrange
// Act [Test]
public void GetFormations_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
List<int?> idStatuts = new List<int?> { 1, 2, 3 };
// Assert // Act
var okResult = formationsApiController.GetFormations(1, idStatuts, true, 1, 5, "formation", null, null, null);
#endregion // Assert
Assert.IsInstanceOf<OkObjectResult>(okResult.Result);
}
#region Tests GetFormationRealisee [Test]
public void GetFormations_PasseDesParamsPresentsDansLaBDD_RetourneLesCinqPremieresFormations()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
List<int?> idStatuts = new List<int?> { 1, 2, 3 };
int nbFormation = 5;
int idFirstFormation = 5;
int idLastFormation = 1;
// Act
var okResult = formationsApiController.GetFormations(1, idStatuts, true, 1, 5, "formation", null, null, null).Result as OkObjectResult;
// Assert
Assert.IsInstanceOf<IEnumerable<FormationDetailsDTO>>(okResult.Value);
Assert.AreEqual(nbFormation, (okResult.Value as IEnumerable<FormationDetailsDTO>).Count());
Assert.AreEqual(idFirstFormation, (okResult.Value as IEnumerable<FormationDetailsDTO>).First().Id);
Assert.AreEqual(idLastFormation, (okResult.Value as IEnumerable<FormationDetailsDTO>).Last().Id);
}
// Arrange #endregion
// Act #region Tests GetFormationsCount
// Assert [Test]
public void GetFormationsCount_PasseDesParamsPresentsDansLaBDD_RetourneUnObjetOkResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
List<int?> idStatuts = new List<int?> { 1, 2, 3 };
#endregion // Act
var okResult = formationsApiController.GetFormationsCount(1, idStatuts, 1, 5, "formation", null, null);
#region Tests GetProchainesFormation // Assert
Assert.IsInstanceOf<OkObjectResult>(okResult.Result);
}
// Arrange [Test]
public void GetFormationsCount_PasseDesParamsPresentsDansLaBDD_RetourneLeBonNombreDeFormation()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
List<int?> idStatuts = new List<int?> { 1, 2, 3 };
int nbFormation = 5;
// Act // Act
var okResult = formationsApiController.GetFormationsCount(1, idStatuts, 1, 5, "formation", null, null).Result as OkObjectResult;
// Assert // Assert
Assert.IsInstanceOf<long>(okResult.Value);
Assert.AreEqual(nbFormation, (long)okResult.Value);
}
#endregion #endregion
#region Tests GetModesFormation #region Tests GetModesFormation
// Arrange
// Act [Test]
public void GetModesFormation_RetourneUnObjetOkResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
// Act
var okResult = formationsApiController.GetModesFormation();
// Assert // Assert
Assert.IsInstanceOf<OkObjectResult>(okResult.Result);
}
[Test]
public void GetModesFormation_RetourneTousLesModes()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
int nbModeFormation = 4;
// Act
var okResult = formationsApiController.GetModesFormation().Result as OkObjectResult;
// Assert
Assert.IsInstanceOf<IEnumerable<ModeFormationDTO>>(okResult.Value);
Assert.AreEqual(nbModeFormation, (okResult.Value as IEnumerable<ModeFormationDTO>).Count());
}
#endregion #endregion
#region Tests GetOriginesFormation #region Tests GetOriginesFormation
// Arrange [Test]
public void GetOriginesFormation_RetourneUnObjetOkResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
// Act // Act
var okResult = formationsApiController.GetOriginesFormation();
// Assert // Assert
Assert.IsInstanceOf<OkObjectResult>(okResult.Result);
}
[Test]
public void GetOriginesFormation_RetourneToutesLesOrigines()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
int nbOrigineFormation = 4;
// Act
var okResult = formationsApiController.GetOriginesFormation().Result as OkObjectResult;
// Assert
Assert.IsInstanceOf<IEnumerable<OrigineFormationDTO>>(okResult.Value);
Assert.AreEqual(nbOrigineFormation, (okResult.Value as IEnumerable<OrigineFormationDTO>).Count());
}
#endregion #endregion
#region Tests GetStatutsFormation #region Tests GetStatutsFormation
// Arrange [Test]
public void GetStatusFormation_RetourneUnObjetOkResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
// Act
var okResult = formationsApiController.GetStatutsFormation();
// Act // Assert
Assert.IsInstanceOf<OkObjectResult>(okResult.Result);
}
// Assert [Test]
public void GetStatutsFormation_RetourneTousLesStatuts()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
int nbStatutFormation = 4;
// Act
var okResult = formationsApiController.GetStatutsFormation().Result as OkObjectResult;
// Assert
Assert.IsInstanceOf<IEnumerable<StatutFormationDTO>>(okResult.Value);
Assert.AreEqual(nbStatutFormation, (okResult.Value as IEnumerable<StatutFormationDTO>).Count());
}
#endregion #endregion
#region Tests GetTypesFormation #region Tests GetTypesFormation
// Arrange [Test]
public void GetTypesFormation_RetourneUnObjetOkResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
// Act // Act
var okResult = formationsApiController.GetTypesFormation();
// Assert
Assert.IsInstanceOf<OkObjectResult>(okResult.Result);
}
// Assert [Test]
public void GetTypesFormation_RetourneTousLesTypes()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
int nbTypeFormation = 4;
// Act
var okResult = formationsApiController.GetTypesFormation().Result as OkObjectResult;
// Assert
Assert.IsInstanceOf<IEnumerable<TypeFormationDTO>>(okResult.Value);
Assert.AreEqual(nbTypeFormation, (okResult.Value as IEnumerable<TypeFormationDTO>).Count());
}
#endregion #endregion
#region Tests AddFormation #region Tests AddFormation
// Arrange [Test]
public void AddFormation_AjouteUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
ModeFormationDTO modeExterne = new ModeFormationDTO { Id = 0, Libelle = "Externe" };
StatutFormationDTO statutPlanifie = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" };
TypeFormationDTO typeELearning = new TypeFormationDTO { Id = 3, Libelle = "E-learning" };
OrigineFormationDTO origineFormationCollaborateur = new OrigineFormationDTO { Id = 1, Libelle = "Demande collaborateur" };
FormationDTO formation = new FormationDTO
{
Intitule = "Test Formation",
IdAgence = 1,
DateDebut = new DateTime(2020, 10, 31),
DateFin = new DateTime(2020, 11, 02),
Heure = 2,
Jour = 1,
Mode = modeExterne,
Type = typeELearning,
Organisme = "Apside",
Origine = origineFormationCollaborateur,
Statut = statutPlanifie,
EstCertifiee = false
};
// Act
var objectResult = formationsApiController.AddFormation(formation);
// Assert
Assert.IsInstanceOf<ObjectResult>(objectResult.Result);
}
[Test]
public void AddFormation_AjouteUneFormationValide_RetourneUnObjetCreatedResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
ModeFormationDTO modeExterne = new ModeFormationDTO { Id = 1, Libelle = "Externe" };
StatutFormationDTO statutPlanifie = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" };
TypeFormationDTO typeELearning = new TypeFormationDTO { Id = 3, Libelle = "E-learning" };
OrigineFormationDTO origineFormationCollaborateur = new OrigineFormationDTO { Id = 1, Libelle = "Demande collaborateur" };
FormationDTO formation = new FormationDTO
{
Intitule = "Test Formation",
IdAgence = 1,
DateDebut = new DateTime(2020, 10, 31),
DateFin = new DateTime(2020, 11, 02),
Heure = 2,
Jour = 1,
Mode = modeExterne,
Type = typeELearning,
Organisme = "Apside",
Origine = origineFormationCollaborateur,
Statut = statutPlanifie,
EstCertifiee = false
};
// Act
var createdResult = formationsApiController.AddFormation(formation);
// Assert
Assert.IsInstanceOf<CreatedResult>(createdResult.Result);
}
// Act [Test]
public void AddFormation_AjouteUneFormationValide_RetourneLaFormationCreee()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
// Assert ModeFormationDTO modeExterne = new ModeFormationDTO { Id = 1, Libelle = "Externe" };
StatutFormationDTO statutPlanifie = new StatutFormationDTO { Id = 1, Libelle = "Planifiée" };
TypeFormationDTO typeELearning = new TypeFormationDTO { Id = 3, Libelle = "E-learning" };
OrigineFormationDTO origineFormationCollaborateur = new OrigineFormationDTO { Id = 1, Libelle = "Demande collaborateur" };
FormationDTO formation = new FormationDTO
{
Intitule = "Test Formation",
IdAgence = 1,
DateDebut = new DateTime(2020, 10, 31),
DateFin = new DateTime(2020, 11, 02),
Heure = 2,
Jour = 1,
Mode = modeExterne,
Type = typeELearning,
Organisme = "Apside",
Origine = origineFormationCollaborateur,
Statut = statutPlanifie,
EstCertifiee = false
};
// Act
var createdResult = formationsApiController.AddFormation(formation).Result as CreatedResult;
// Assert
Assert.IsInstanceOf<FormationDTO>(createdResult.Value);
Assert.AreEqual("Test Formation", (createdResult.Value as FormationDTO).Intitule);
}
#endregion #endregion
#region Tests UpdateFormation #region Tests UpdateFormation
// Arrange [Test]
public async Task UpdateFormation_ModifieUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchFormationInvalidException()
{
// Arrange
long idFormation = 1;
string nouvelleIntitule = "Formation modifiée";
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation);
formation.Intitule = nouvelleIntitule;
formation.Mode.Id = 0;
formation.Statut.Id = 0;
// Act // Act
var objectResult = formationsApiController.UpdateFormation(formation, idFormation);
// Assert // Assert
Assert.IsInstanceOf<ObjectResult>(objectResult.Result);
}
[Test]
public async Task UpdateFormation_ModifieUneFormationAvecDesObjetsEnfantsInvalides_RetourneUnObjetObjectResultDansCatchFormationIncompatibleIdException()
{
// Arrange
long idFormation = 1;
string nouvelleIntitule = "Formation modifiée";
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation);
idFormation = 2;
formation.Intitule = nouvelleIntitule;
// Act
var objectResult = formationsApiController.UpdateFormation(formation, idFormation);
// Assert
Assert.IsInstanceOf<ObjectResult>(objectResult.Result);
}
[Test]
public async Task UpdateFormation_ModifieUneFormatioInexistante_RetourneUnObjetObjectResultDansCatchFormationNotFoundExceptionn()
{
// Arrange
long idFormationExistant = 1;
long idFormationInexistant = 999;
string nouvelleIntitule = "Formation modifiée";
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormationExistant);
formation.Id = idFormationInexistant;
formation.Intitule = nouvelleIntitule;
// Act
var objectResult = formationsApiController.UpdateFormation(formation, idFormationInexistant);
// Assert
Assert.IsInstanceOf<ObjectResult>(objectResult.Result);
}
[Test]
public async Task UpdateFormation_ModifieUneFormationValide_RetourneUnObjetOkObjectResult()
{
// Arrange
long idFormation = 1;
string nouvelleIntitule = "Formation modifiée";
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object); ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == 2)
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault();
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == 2)
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault();
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == 1)
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault();
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == 1)
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault();
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation);
formation.Intitule = nouvelleIntitule;
formation.Mode = modeExterne;
formation.Type = typeELearning;
formation.Origine = origineFormationCollaborateur;
formation.Statut = statutPlanifie;
// Act
var okObjectResult = formationsApiController.UpdateFormation(formation, idFormation);
// Assert
Assert.IsInstanceOf<OkObjectResult>(okObjectResult.Result);
}
[Test]
public async Task UpdateFormation_ModifieUneFormationValide_RetourneLaFormationModifiee()
{
// Arrange
long idFormation = 1;
string nouvelleIntitule = "Formation modifiée";
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
ModeFormationDTO modeExterne = epContext.ModeFormation.Where(mode => mode.IdModeFormation == 2)
.Select(mode => new ModeFormationDTO { Id = mode.IdModeFormation, Libelle = mode.Libelle }).FirstOrDefault();
StatutFormationDTO statutPlanifie = epContext.StatutFormation.Where(mode => mode.IdStatutFormation == 2)
.Select(mode => new StatutFormationDTO { Id = mode.IdStatutFormation, Libelle = mode.Libelle }).FirstOrDefault();
TypeFormationDTO typeELearning = epContext.TypeFormation.Where(mode => mode.IdTypeFormation == 1)
.Select(mode => new TypeFormationDTO { Id = mode.IdTypeFormation, Libelle = mode.Libelle }).FirstOrDefault();
OrigineFormationDTO origineFormationCollaborateur = epContext.OrigineFormation.Where(mode => mode.IdOrigineFormation == 1)
.Select(mode => new OrigineFormationDTO { Id = mode.IdOrigineFormation, Libelle = mode.Libelle }).FirstOrDefault();
FormationDTO formation = await formationService.GetFormationByIdAsync(idFormation);
formation.Intitule = nouvelleIntitule;
formation.Mode = modeExterne;
formation.Type = typeELearning;
formation.Origine = origineFormationCollaborateur;
formation.Statut = statutPlanifie;
// Act
var okObjectResult = formationsApiController.UpdateFormation(formation, idFormation).Result as OkObjectResult;
// Assert
Assert.IsInstanceOf<FormationDTO>(okObjectResult.Value);
Assert.AreEqual(nouvelleIntitule, (okObjectResult.Value as FormationDTO).Intitule);
}
#endregion #endregion
#region Tests DeleteFormationById #region Tests DeleteFormationById
// Arrange [Test]
public void DeleteFormation_PasseEnParamUnIdFormationInexistant_RetourneUnObjetNotFoundObjectResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
int idFormation = 999;
// Act
var notFoundObjectResult = formationsApiController.DeleteFormation(idFormation);
// Assert
Assert.IsInstanceOf<NotFoundObjectResult>(notFoundObjectResult.Result);
}
[Test]
public void DeleteFormation_PasseEnParamUnIdFormationExistant_RetourneUnObjetNoContentResult()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
int idFormation = 1;
// Act // Act
var noContentResult = formationsApiController.DeleteFormation(idFormation);
// Assert
Assert.IsInstanceOf<NoContentResult>(noContentResult.Result);
}
[Test]
public async Task DeleteFormation_PasseEnParamUnIdFormationExistant_SupprimeBienUneFormation()
{
// Arrange
FormationsApiController formationsApiController = new FormationsApiController(formationService, new NullLogger<FormationsApiController>(), mockEnvironment.Object);
int idFormation = 1;
long nbFormationAvantSuppression = await formationService.GetFormationsCountAsync(null, null, null, null, null, null, null);
// Act
var noContentResult = formationsApiController.DeleteFormation(idFormation).Result as NoContentResult;
// Assert
long nbFormationApresSuppression = await formationService.GetFormationsCountAsync(null, null, null, null, null, null, null);
Assert.AreEqual(nbFormationAvantSuppression -1, nbFormationApresSuppression);
}
// Assert
#endregion #endregion
} }

@ -11,6 +11,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Moq" Version="4.15.2" />
<PackageReference Include="nunit" Version="3.12.0" /> <PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" /> <PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
@ -20,4 +21,8 @@
<ProjectReference Include="..\EPAServeur\EPAServeur.csproj" /> <ProjectReference Include="..\EPAServeur\EPAServeur.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="TestResults\" />
</ItemGroup>
</Project> </Project>

@ -0,0 +1,7 @@
{
"profiles": {
"EPAServeur.Tests": {
"commandName": "Project"
}
}
}

File diff suppressed because it is too large Load Diff

@ -64,18 +64,18 @@ namespace EPAServeur.Context
TypeEntretien typeSite, typeClient, typeVisio, typeTelephone; TypeEntretien typeSite, typeClient, typeVisio, typeTelephone;
typeSite = new TypeEntretien { Libelle = "Sur site" }; typeSite = new TypeEntretien { Libelle = "Sur site" };
epContext.TypeEntretien.Add(typeSite); epContext.TypeEntretien.Add(typeSite);
typeClient = new TypeEntretien { Libelle = "Chez le client" }; typeClient = new TypeEntretien { Libelle = "Chez le client" };
epContext.TypeEntretien.Add(typeClient); epContext.TypeEntretien.Add(typeClient);
typeVisio = new TypeEntretien { Libelle = "Visioconférence" }; typeVisio = new TypeEntretien { Libelle = "Visioconférence" };
epContext.TypeEntretien.Add(typeVisio); epContext.TypeEntretien.Add(typeVisio);
typeTelephone = new TypeEntretien { Libelle = "Téléphonique" }; typeTelephone = new TypeEntretien { Libelle = "Téléphonique" };
epContext.TypeEntretien.Add(typeTelephone); epContext.TypeEntretien.Add(typeTelephone);
epContext.SaveChanges(); epContext.SaveChanges();
} }
/// <summary> /// <summary>
@ -358,7 +358,7 @@ namespace EPAServeur.Context
statutPlanifie = new StatutFormation { IdStatutFormation = 1, Libelle = "Planifiée" }; statutPlanifie = new StatutFormation { IdStatutFormation = 1, Libelle = "Planifiée" };
epContext.StatutFormation.Add(statutPlanifie); epContext.StatutFormation.Add(statutPlanifie);
statutReplanifie = new StatutFormation { IdStatutFormation = 2, Libelle = "Replanifié" }; statutReplanifie = new StatutFormation { IdStatutFormation = 2, Libelle = "Replanifiée" };
epContext.StatutFormation.Add(statutReplanifie); epContext.StatutFormation.Add(statutReplanifie);
statutRealise = new StatutFormation { IdStatutFormation = 3, Libelle = "Réalisée" }; statutRealise = new StatutFormation { IdStatutFormation = 3, Libelle = "Réalisée" };
@ -443,10 +443,11 @@ namespace EPAServeur.Context
f1 = new Formation f1 = new Formation
{ {
Intitule = "Formation1", IdFormation = 1,
Intitule = "Formation Mainframe Complète",
DateDebut = new DateTime(2020, 9, 16, 10, 0, 0), DateDebut = new DateTime(2020, 1, 25, 10, 0, 0),
DateFin = new DateTime(2020, 9, 16), DateFin = new DateTime(2020, 1, 27),
IdAgence = 1, IdAgence = 1,
Heure = 2, Heure = 2,
Jour = 1, Jour = 1,
@ -461,10 +462,11 @@ namespace EPAServeur.Context
f2 = new Formation f2 = new Formation
{ {
Intitule = "Formation2", IdFormation = 2,
Intitule = "Formation professionnelle React + Redux",
DateDebut = new DateTime(2020, 10, 5, 14, 0, 0), DateDebut = new DateTime(2020, 2, 25, 14, 0, 0),
DateFin = new DateTime(2020, 10, 9), DateFin = new DateTime(2020, 2, 27),
IdAgence = 1, IdAgence = 1,
Heure = 10, Heure = 10,
Jour = 5, Jour = 5,
@ -479,10 +481,11 @@ namespace EPAServeur.Context
f3 = new Formation f3 = new Formation
{ {
Intitule = "Formation3", IdFormation = 3,
Intitule = "Apprendre C# et le développement de logiciels avec WPF",
DateDebut = new DateTime(2020, 9, 21, 14, 0, 0), DateDebut = new DateTime(2020, 5, 25, 14, 0, 0),
DateFin = new DateTime(2020, 9, 21), DateFin = new DateTime(2020, 5, 27),
IdAgence = 1, IdAgence = 1,
Heure = 4, Heure = 4,
Jour = 2, Jour = 2,
@ -497,10 +500,11 @@ namespace EPAServeur.Context
f4 = new Formation f4 = new Formation
{ {
Intitule = "Formation4", IdFormation = 4,
Intitule = "Formation Visual Basic.Net - Initiation + Approfondissement",
DateDebut = new DateTime(2020, 05, 11, 14, 0, 0), DateDebut = new DateTime(2020, 7, 25, 14, 0, 0),
DateFin = new DateTime(2020, 05, 11), DateFin = new DateTime(2020, 7, 27),
IdAgence = 1, IdAgence = 1,
Heure = 3, Heure = 3,
Jour = 1, Jour = 1,
@ -515,10 +519,11 @@ namespace EPAServeur.Context
f5 = new Formation f5 = new Formation
{ {
Intitule = "Formation5", IdFormation = 5,
Intitule = "Formation Conception, langage SQL : Les fondamentaux",
DateDebut = new DateTime(2020, 08, 1, 13, 0, 0), DateDebut = new DateTime(2020, 8, 25, 14, 0, 0),
DateFin = new DateTime(2020, 08, 3), DateFin = new DateTime(2020, 8, 27),
IdAgence = 1, IdAgence = 1,
Heure = 6, Heure = 6,
Jour = 2, Jour = 2,
@ -533,10 +538,11 @@ namespace EPAServeur.Context
f6 = new Formation f6 = new Formation
{ {
Intitule = "Formation6", IdFormation = 6,
Intitule = "Formation Laravel 5.x, Développement WEB en PHP",
DateDebut = new DateTime(2020, 9, 30, 9, 0, 0), DateDebut = new DateTime(2020, 9, 25, 14, 0, 0),
DateFin = new DateTime(2020, 10, 1), DateFin = new DateTime(2020, 9, 27),
IdAgence = 1, IdAgence = 1,
Heure = 4, Heure = 4,
Jour = 2, Jour = 2,
@ -551,10 +557,11 @@ namespace EPAServeur.Context
f7 = new Formation f7 = new Formation
{ {
Intitule = "Formation7", IdFormation = 7,
Intitule = "Formation d’initiation aux Méthodes Agiles – Scrum",
DateDebut = new DateTime(2020, 10, 5, 10, 0, 0), DateDebut = new DateTime(2020, 11, 25, 14, 0, 0),
DateFin = new DateTime(2020, 10, 8), DateFin = new DateTime(2020, 11, 27),
IdAgence = 1, IdAgence = 1,
Heure = 6, Heure = 6,
Jour = 5, Jour = 5,
@ -569,9 +576,10 @@ namespace EPAServeur.Context
f8 = new Formation f8 = new Formation
{ {
Intitule = "Formation2", IdFormation = 8,
DateDebut = new DateTime(2020, 11, 18, 10, 0, 0), Intitule = "Formation Xamarin, Développer des applications mobiles en C# pour iOS et Android",
DateFin = new DateTime(2020, 11, 20), DateDebut = new DateTime(2020, 12, 25, 14, 0, 0),
DateFin = new DateTime(2020, 12, 27),
IdAgence = 1, IdAgence = 1,
Heure = 6, Heure = 6,
Jour = 3, Jour = 3,
@ -586,7 +594,8 @@ namespace EPAServeur.Context
f9 = new Formation f9 = new Formation
{ {
Intitule = "Formation9", IdFormation = 9,
Intitule = "Formation Développer des Web Services en Java",
DateDebut = new DateTime(2020, 11, 15, 9, 0, 0), DateDebut = new DateTime(2020, 11, 15, 9, 0, 0),
DateFin = new DateTime(2020, 11, 15), DateFin = new DateTime(2020, 11, 15),
IdAgence = 1, IdAgence = 1,
@ -603,7 +612,8 @@ namespace EPAServeur.Context
f10 = new Formation f10 = new Formation
{ {
Intitule = "Formation10", IdFormation = 10,
Intitule = "Architecture Microservices – Les fondamentaux",
DateDebut = new DateTime(2020, 8, 3, 14, 0, 0), DateDebut = new DateTime(2020, 8, 3, 14, 0, 0),
DateFin = new DateTime(2020, 8, 3), DateFin = new DateTime(2020, 8, 3),
IdAgence = 1, IdAgence = 1,
@ -612,7 +622,7 @@ namespace EPAServeur.Context
ModeFormation = modePresentiel, ModeFormation = modePresentiel,
TypeFormation = typeInterne, TypeFormation = typeInterne,
Organisme = "Organisme4", Organisme = "Organisme4",
Origine = origineFormationClient, Origine = origineFormationReglementaire,
Statut = statutAnnule, Statut = statutAnnule,
EstCertifiee = false EstCertifiee = false
}; };
@ -620,7 +630,8 @@ namespace EPAServeur.Context
f11 = new Formation f11 = new Formation
{ {
Intitule = "Formation11", IdFormation = 11,
Intitule = "Formation Clean Architecture .Net Core",
DateDebut = new DateTime(2020, 04, 6, 9, 0, 0), DateDebut = new DateTime(2020, 04, 6, 9, 0, 0),
DateFin = new DateTime(2020, 04, 11), DateFin = new DateTime(2020, 04, 11),
IdAgence = 1, IdAgence = 1,
@ -629,28 +640,514 @@ namespace EPAServeur.Context
ModeFormation = modePresentiel, ModeFormation = modePresentiel,
TypeFormation = typeInterne, TypeFormation = typeInterne,
Organisme = "Organisme1", Organisme = "Organisme1",
Origine = origineFormationClient, Origine = origineFormationReglementaire,
Statut = statutAnnule, Statut = statutAnnule,
EstCertifiee = false EstCertifiee = false
}; };
epContext.Formation.Add(f11); epContext.Formation.Add(f11);
/* /*
formations.Add(f1);
formations.Add(f2);
formations.Add(f3);
formations.Add(f4);
formations.Add(f5);
formations.Add(f6);
formations.Add(f7);
formations.Add(f8);
formations.Add(f9);
formations.Add(f10);
formations.Add(f11);
int[] npParticipants = { }; int[] npParticipants = { };
*/ */
// EP
Ep ep12, ep13, ep14, ep15;
Ep ep16, ep17, ep18, ep19;
Ep ep20;
ep12 = new Ep
{
IdEP = 12,
IdCollaborateur = Guid.Parse("842650db-a548-4472-a3af-4c5fff3c1ab8"),
IdReferent = Guid.Parse("aa36f34c-9041-42f5-9db3-6536fe7f1696"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPA,
NumeroEp = 1,
DateCreation = new DateTime(2020, 1, 21, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 1, 22, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 1, 23)
};
epContext.Ep.Add(ep12);
ep13 = new Ep
{
IdEP = 13,
IdCollaborateur = Guid.Parse("301ba7f3-095e-4912-8998-a7c942dc5f23"),
IdReferent = Guid.Parse("ea027734-ff0f-4308-8879-133a09fb3c46"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPS,
NumeroEp = 3,
DateCreation = new DateTime(2020, 2, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 2, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 2, 23)
};
epContext.Ep.Add(ep13);
ep14 = new Ep
{
IdEP = 14,
IdCollaborateur = Guid.Parse("a0f40e2a-cc03-4032-a627-5389e1281c64"),
IdReferent = Guid.Parse("56e3d82d-4be4-4449-a1f7-b4004b6bd186"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPS,
NumeroEp = 1,
DateCreation = new DateTime(2020, 3, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 3, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 3, 23)
};
epContext.Ep.Add(ep14);
ep15 = new Ep
{
IdEP = 15,
IdCollaborateur = Guid.Parse("4f3fcd23-a1e4-4c9e-afa2-d06ca9216491"),
IdReferent = Guid.Parse("25d2b0ce-5c95-4ccc-98bb-63b06c4ee4ad"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPS,
NumeroEp = 1,
DateCreation = new DateTime(2020, 4, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 4, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 4, 23)
};
ep16 = new Ep
{
IdEP = 16,
IdCollaborateur = Guid.Parse("0968ccd3-1ef5-4041-83f3-1c76afb02bbf"),
IdReferent = Guid.Parse("01ee85ff-d7f3-494b-b1de-26ced8fbfa0d"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPA,
NumeroEp = 1,
DateCreation = new DateTime(2020, 5, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 5, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 5, 23)
};
epContext.Ep.Add(ep16);
ep17 = new Ep
{
IdEP = 17,
IdCollaborateur = Guid.Parse("e7820f92-eab1-42f5-ae96-5c16e71ff1e6"),
IdReferent = Guid.Parse("d4fc247b-015a-44d6-8f3e-a52f0902d2bf"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPS,
NumeroEp = 1,
DateCreation = new DateTime(2020, 6, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 6, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 6, 23)
};
epContext.Ep.Add(ep17);
ep18 = new Ep
{
IdEP = 18,
IdCollaborateur = Guid.Parse("1429be5b-9125-482c-80c4-c1d34afbd8d2"),
IdReferent = Guid.Parse("3f276ab8-727a-4e26-ad5d-4d296158688e"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPS,
NumeroEp = 1,
DateCreation = new DateTime(2020, 7, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 7, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 7, 23)
};
epContext.Ep.Add(ep18);
ep19 = new Ep
{
IdEP = 19,
IdCollaborateur = Guid.Parse("13fbe621-1bc9-4f04-afde-b54ca076e239"),
IdReferent = Guid.Parse("f1d14915-89f7-4c1a-a8e1-4148ed7d81d7"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPASIXANS,
NumeroEp = 1,
DateCreation = new DateTime(2020, 8, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 8, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 8, 23)
};
epContext.Ep.Add(ep19);
ep20 = new Ep
{
IdEP = 20,
IdCollaborateur = Guid.Parse("b5254c6c-7caa-435f-a4bb-e0cf92559832"),
IdReferent = Guid.Parse("dfea9a3c-7896-444d-9aa0-61ae536091c1"),
IdBu = 2,
Fonction = "Dev",
TypeEP = TypeEp.EPS,
NumeroEp = 1,
DateCreation = new DateTime(2020, 9, 22, 9, 0, 0),
DatePrevisionnelle = new DateTime(2020, 9, 25, 9, 0, 0),
Obligatoire = false,
Statut = StatutEp.SignatureReferent,
CV = "CV.pdf",
DateSaisie = new DateTime(2020, 9, 23)
};
epContext.Ep.Add(ep20);
// Demande de formation
DemandeFormation d1, d2, d3, d4;//EnAttente
DemandeFormation d5, d6, d7, d8; // Validee
DemandeFormation d9, d10, d11, d12;//Rejetee
d1 = new DemandeFormation
{
IdDemandeFormation = 1,
Libelle = "Formation Cobol",
Description = "Demande de formation Cobol avec Mainframe",
DemandeRH = false,
DateDemande = new DateTime(2020, 1, 22, 9, 0, 0),
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep12
};
epContext.DemandeFormation.Add(d1);
d2 = new DemandeFormation
{
IdDemandeFormation = 2,
Libelle = "Formation React",
Description = "Demande de formation React avec Redux",
DemandeRH = false,
DateDemande = new DateTime(2020, 2, 22, 9, 0, 0),
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep13
};
epContext.DemandeFormation.Add(d2);
d3 = new DemandeFormation
{
IdDemandeFormation = 3,
Libelle = "Formation C#",
Description = "Demande de formation C# avec WPF",
DemandeRH = false,
DateDemande = new DateTime(2020, 3, 22, 9, 0, 0),
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep14
};
epContext.DemandeFormation.Add(d3);
d4 = new DemandeFormation
{
IdDemandeFormation = 4,
Libelle = "Formation C#",
Description = "Demande de formation C# avec WPF",
DemandeRH = false,
DateDemande = new DateTime(2020, 4, 22, 9, 0, 0),
Etat = EtatDemande.EnAttente,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep13
};
epContext.DemandeFormation.Add(d4);
d5 = new DemandeFormation
{
IdDemandeFormation = 5,
Libelle = "Formation C#",
Description = "Demande de formation C# avec WPF",
DemandeRH = false,
DateDemande = new DateTime(2020, 5, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep12
};
epContext.DemandeFormation.Add(d5);
d6 = new DemandeFormation
{
IdDemandeFormation = 6,
Libelle = "Formation Vb.Net",
Description = "Demande de formation Vb.Net avec WinForms",
DemandeRH = false,
DateDemande = new DateTime(2020, 6, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep15
};
epContext.DemandeFormation.Add(d6);
d7 = new DemandeFormation
{
IdDemandeFormation = 7,
Libelle = "Formation Vb.Net",
Description = "Demande de formation Vb.Net avec WinForms",
DemandeRH = false,
DateDemande = new DateTime(2020, 7, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep16
};
epContext.DemandeFormation.Add(d7);
d8 = new DemandeFormation
{
IdDemandeFormation = 8,
Libelle = "Formation SQL",
Description = "Demande de formation SQL avec SQL Server",
DemandeRH = false,
DateDemande = new DateTime(2020, 8, 22, 9, 0, 0),
Etat = EtatDemande.Validee,
CommentaireRefus = null,
DateDerniereReponse = null,
Ep = ep16
};
epContext.DemandeFormation.Add(d8);
d9 = new DemandeFormation
{
IdDemandeFormation = 9,
Libelle = "Formation PHP",
Description = "Demande de formation PHP avec Laravel",
DemandeRH = false,
DateDemande = new DateTime(2020, 9, 22, 9, 0, 0),
Etat = EtatDemande.Rejetee,
CommentaireRefus = "Aucune formation PHP pour le moment",
DateDerniereReponse = new DateTime(2020, 9, 27, 9, 0, 0),
Ep = ep17
};
epContext.DemandeFormation.Add(d9);
d10 = new DemandeFormation
{
IdDemandeFormation = 10,
Libelle = "Formation Vue.JS",
Description = "Demande de formation Vue.JS",
DemandeRH = false,
DateDemande = new DateTime(2020, 10, 22, 9, 0, 0),
Etat = EtatDemande.Rejetee,
CommentaireRefus = null,
DateDerniereReponse = new DateTime(2020, 10, 27, 9, 0, 0),
Ep = ep18
};
epContext.DemandeFormation.Add(d10);
d11 = new DemandeFormation
{
IdDemandeFormation = 11,
Libelle = "Formation SCRUM",
Description = "Demande de formation sur la méthode agile SCRUM",
DemandeRH = false,
DateDemande = new DateTime(2020, 11, 22, 9, 0, 0),
Etat = EtatDemande.Rejetee,
CommentaireRefus = null,
DateDerniereReponse = new DateTime(2020, 11, 27, 9, 0, 0),
Ep = ep19
};
epContext.DemandeFormation.Add(d11);
d12 = new DemandeFormation
{
IdDemandeFormation = 12,
Libelle = "Formation C#",
Description = "Demande de formation C# avec Xamarin",
DemandeRH = false,
DateDemande = new DateTime(2020, 12, 22, 9, 0, 0),
Etat = EtatDemande.Rejetee,
CommentaireRefus = null,
DateDerniereReponse = new DateTime(2020, 12, 27, 9, 0, 0),
Ep = ep20
};
epContext.DemandeFormation.Add(d12);
// Participation formation
ParticipationFormation p1, p2, p3, p4;
ParticipationFormation p5, p6, p7, p8;
ParticipationFormation p9, p10, p11, p12;
p1 = new ParticipationFormation
{
IdParticipationFormation = 1,
DateCreation = new DateTime(2020, 1, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d1.IdDemandeFormation,
DemandeFormation = d1,
Formation = f1
};
epContext.ParticipationFormation.Add(p1);
p2 = new ParticipationFormation
{
IdParticipationFormation = 2,
DateCreation = new DateTime(2020, 2, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d2.IdDemandeFormation,
DemandeFormation = d2,
Formation = f2
};
epContext.ParticipationFormation.Add(p2);
p3 = new ParticipationFormation
{
IdParticipationFormation = 3,
DateCreation = new DateTime(2020, 3, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d3.IdDemandeFormation,
DemandeFormation = d3,
Formation = f3
};
epContext.ParticipationFormation.Add(p3);
p4 = new ParticipationFormation
{
IdParticipationFormation = 4,
DateCreation = new DateTime(2020, 4, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d4.IdDemandeFormation,
DemandeFormation = d4,
Formation = f3
};
epContext.ParticipationFormation.Add(p4);
p5 = new ParticipationFormation
{
IdParticipationFormation = 5,
DateCreation = new DateTime(2020, 5, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d5.IdDemandeFormation,
DemandeFormation = d5,
Formation = f3
};
epContext.ParticipationFormation.Add(p5);
p6 = new ParticipationFormation
{
IdParticipationFormation = 6,
DateCreation = new DateTime(2020, 6, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d6.IdDemandeFormation,
DemandeFormation = d6,
Formation = f4
};
epContext.ParticipationFormation.Add(p6);
p7 = new ParticipationFormation
{
IdParticipationFormation = 7,
DateCreation = new DateTime(2020, 7, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d7.IdDemandeFormation,
DemandeFormation = d7,
Formation = f4
};
epContext.ParticipationFormation.Add(p7);
p8 = new ParticipationFormation
{
IdParticipationFormation = 8,
DateCreation = new DateTime(2020, 8, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d8.IdDemandeFormation,
DemandeFormation = d8,
Formation = f5
};
epContext.ParticipationFormation.Add(p8);
p9 = new ParticipationFormation
{
IdParticipationFormation = 9,
DateCreation = new DateTime(2020, 9, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d9.IdDemandeFormation,
DemandeFormation = d9,
Formation = f6
};
epContext.ParticipationFormation.Add(p9);
p10 = new ParticipationFormation
{
IdParticipationFormation = 10,
DateCreation = new DateTime(2020, 10, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d10.IdDemandeFormation,
DemandeFormation = d10,
Formation = f7
};
epContext.ParticipationFormation.Add(p10);
p11 = new ParticipationFormation
{
IdParticipationFormation = 11,
DateCreation = new DateTime(2020, 11, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d11.IdDemandeFormation,
DemandeFormation = d11,
Formation = f8
};
epContext.ParticipationFormation.Add(p11);
p12 = new ParticipationFormation
{
IdParticipationFormation = 12,
DateCreation = new DateTime(2020, 12, 25, 9, 0, 0),
EstEvaluee = false,
IdDemandeFormation = d12.IdDemandeFormation,
DemandeFormation = d12,
Formation = f9
};
epContext.ParticipationFormation.Add(p12);
epContext.SaveChanges(); epContext.SaveChanges();
} }

@ -159,6 +159,7 @@ namespace EPAServeur.Context
{ {
entity.HasKey(e => e.IdFormation); entity.HasKey(e => e.IdFormation);
entity.Property(e => e.IdFormation).ValueGeneratedOnAdd(); entity.Property(e => e.IdFormation).ValueGeneratedOnAdd();
entity.HasMany<ParticipationFormation>(e => e.ParticipationsFormation).WithOne(e => e.Formation);
}); });
modelBuilder.Entity<ModeFormation>(entity => modelBuilder.Entity<ModeFormation>(entity =>

@ -18,6 +18,15 @@ using IO.Swagger.Attributes;
using IO.Swagger.Security; using IO.Swagger.Security;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using IO.Swagger.DTO; using IO.Swagger.DTO;
using System.ComponentModel;
using EPAServeur.IServices;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using EPAServeur.Exceptions;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Http;
namespace IO.Swagger.Controllers namespace IO.Swagger.Controllers
{ {
@ -27,6 +36,17 @@ namespace IO.Swagger.Controllers
[ApiController] [ApiController]
public class FormationsApiController : ControllerBase public class FormationsApiController : ControllerBase
{ {
private readonly IFormationService formationService;
private readonly ILogger<FormationsApiController> logger;
private readonly IWebHostEnvironment env;
public FormationsApiController(IFormationService _formationService, ILogger<FormationsApiController> _logger, IWebHostEnvironment _env)
{
formationService = _formationService;
logger = _logger;
env = _env;
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -47,29 +67,57 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult AddFormation([FromBody]FormationDTO body) public virtual async Task<IActionResult> AddFormation([FromBody] FormationDTO body)
{ {
//TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(201, default(FormationDTO)); logger.LogInformation("Ajout d'une nouvelle formation.");
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... try
// return StatusCode(401, default(ErreurDTO)); {
body = await formationService.AddFormationAsync(body);
//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)); catch (FormationInvalidException e)
{
//TODO: Uncomment the next line to return response 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(415, default(ErreurDTO)); logger.LogInformation(e.Message);
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(500, default(ErreurDTO)); {
string exampleJson = null; Code = StatusCodes.Status500InternalServerError,
exampleJson = "{\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}"; Message = e.Message,
};
var example = exampleJson != null
? JsonConvert.DeserializeObject<FormationDTO>(exampleJson) return StatusCode(erreur.Code.Value, erreur.Message);
: default(FormationDTO); //TODO: Change the data returned }
return new ObjectResult(example); catch (DbUpdateException e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur est survenue sur le serveur lors de l'ajout de la formation.",
};
return StatusCode(erreur.Code.Value, erreur);
}
catch (Exception e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur.",
};
return StatusCode(erreur.Code.Value, erreur);
}
if (env.IsDevelopment())
logger.LogInformation("Nouvelle formation ajoutée.");
return Created("", body);
} }
/// <summary> /// <summary>
@ -91,24 +139,69 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult DeleteFormation([FromRoute][Required]long? idFormation) public virtual async Task<IActionResult> DeleteFormation([FromRoute][Required] long idFormation)
{ {
//TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... try
// return StatusCode(204); {
if (env.IsDevelopment())
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... logger.LogInformation("Suppresion de la formation {idFormation}.", idFormation);
// return StatusCode(401, default(ErreurDTO));
FormationDTO formation = await formationService.DeleteFormationByIdAsync(idFormation);
//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)); catch (FormationNotFoundException e)
{
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(404, default(ErreurDTO)); logger.LogInformation(e.Message);
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(500, default(ErreurDTO)); {
Code = StatusCodes.Status404NotFound,
throw new NotImplementedException(); Message = e.Message
};
return NotFound(erreur);
}
catch (DbUpdateConcurrencyException e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = string.Format("La formation {0} n'a pas pu être supprimée car elle est prise par une autre ressource.", idFormation)
};
return StatusCode(erreur.Code.Value, erreur);
}
catch (DbUpdateException e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur est survenue sur le serveur lors de la suppression de la formation."
};
return StatusCode(erreur.Code.Value, erreur);
}
catch (Exception e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
return StatusCode(erreur.Code.Value, erreur);
}
if (env.IsDevelopment())
logger.LogInformation("Formation {idFormation} supprimée avec succès.", idFormation);
return NoContent();
} }
/// <summary> /// <summary>
@ -123,7 +216,7 @@ namespace IO.Swagger.Controllers
/// <response code="500">Une erreur est survenue sur le serveur</response> /// <response code="500">Une erreur est survenue sur le serveur</response>
[HttpGet] [HttpGet]
[Route("/api/formations/{idFormation}")] [Route("/api/formations/{idFormation}")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] //[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState] [ValidateModelState]
[SwaggerOperation("GetFormationById")] [SwaggerOperation("GetFormationById")]
[SwaggerResponse(statusCode: 200, type: typeof(FormationDTO), description: "OK")] [SwaggerResponse(statusCode: 200, type: typeof(FormationDTO), description: "OK")]
@ -131,29 +224,47 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult GetFormationById([FromRoute][Required]long? idFormation) public virtual async Task<IActionResult> GetFormationById([FromRoute][Required] long idFormation)
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(200, default(FormationDTO)); logger.LogInformation("Récupération de la formation {idFormation}.", idFormation);
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... FormationDTO formationDTO;
// return StatusCode(401, default(ErreurDTO));
try
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... {
// return StatusCode(403, default(ErreurDTO)); formationDTO = await formationService.GetFormationByIdAsync(idFormation);
}
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... catch (FormationNotFoundException e)
// return StatusCode(404, default(ErreurDTO)); {
if (env.IsDevelopment())
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... logger.LogInformation(e.Message);
// return StatusCode(500, default(ErreurDTO));
string exampleJson = null; ErreurDTO erreurDTO = new ErreurDTO()
exampleJson = "{\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}"; {
Code = StatusCodes.Status404NotFound,
var example = exampleJson != null Message = e.Message
? JsonConvert.DeserializeObject<FormationDTO>(exampleJson) };
: default(FormationDTO); //TODO: Change the data returned
return new ObjectResult(example); return NotFound(erreurDTO);
}
catch (Exception e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
return StatusCode(erreur.Code.Value, erreur);
}
if (env.IsDevelopment())
logger.LogInformation("Formation {idFormation} récupérée.", idFormation);
return Ok(formationDTO);
} }
/// <summary> /// <summary>
@ -182,26 +293,34 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult GetFormations([FromQuery]long? idAgence, [FromQuery]List<int?> idStatuts, [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> 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)
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(200, default(List<FormationDetailsDTO>)); logger.LogInformation("Récupération de la liste des formations.");
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable<FormationDetailsDTO> formations;
// 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(..), ... try
// return StatusCode(403, default(ErreurDTO)); {
formations = await formationService.GetFormationsAsync(idAgence, idStatuts, asc, numPage, parPAge, texte, tri, dateDebut, dateFin);
}
catch (Exception e)
{
logger.LogError(e.Message);
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(500, default(ErreurDTO)); {
string exampleJson = null; Code = StatusCodes.Status500InternalServerError,
exampleJson = "[ {\n \"nbParticipations\" : 6,\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"organisme\" : \"organisme\",\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n },\n \"estCertifiee\" : true,\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n }\n}, {\n \"nbParticipations\" : 6,\n \"dateDebut\" : \"2000-01-23T04:56:07.000+00:00\",\n \"organisme\" : \"organisme\",\n \"id\" : 0,\n \"dateFin\" : \"2000-01-23T04:56:07.000+00:00\",\n \"origine\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n },\n \"estCertifiee\" : true,\n \"intitule\" : \"intitule\",\n \"statut\" : {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n }\n} ]"; Message = "Une erreur inconnue est survenue sur le serveur."
};
var example = exampleJson != null return StatusCode(erreur.Code.Value, erreur);
? JsonConvert.DeserializeObject<List<FormationDetailsDTO>>(exampleJson) }
: default(List<FormationDetailsDTO>); //TODO: Change the data returned
return new ObjectResult(example); if (env.IsDevelopment())
logger.LogInformation("Liste des formations récupérée.");
return Ok(formations);
} }
/// <summary> /// <summary>
@ -230,26 +349,35 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult GetFormationsCount([FromQuery]long? idAgence, [FromQuery]List<int?> idStatuts, [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> GetFormationsCount([FromQuery] long? idAgence, [FromQuery] List<int?> idStatuts, [FromQuery] int? numPage, [FromQuery][Range(5, 100)][DefaultValue(15)] int? parPAge, [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(..), ... if (env.IsDevelopment())
// return StatusCode(200, default(long?)); logger.LogInformation("Récupération du nombre total de formations.");
long count;
try
{
count = await formationService.GetFormationsCountAsync(idAgence, idStatuts, numPage, parPAge, texte, dateDebut, dateFin);
}
catch (Exception e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... return StatusCode(erreur.Code.Value, erreur);
// 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(..), ... if (env.IsDevelopment())
// return StatusCode(403, default(ErreurDTO)); logger.LogInformation("Nombre total de formations récupéré.");
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... return Ok(count);
// return StatusCode(500, default(ErreurDTO));
string exampleJson = null;
exampleJson = "0";
var example = exampleJson != null
? JsonConvert.DeserializeObject<long?>(exampleJson)
: default(long?); //TODO: Change the data returned
return new ObjectResult(example);
} }
/// <summary> /// <summary>
@ -269,26 +397,34 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult GetModesFormation() public virtual async Task<IActionResult> GetModesFormation()
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(200, default(List<ModeFormationDTO>)); logger.LogInformation("Récupération de la liste des modes de formation.");
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... IEnumerable<ModeFormationDTO> modeFormations;
// 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(..), ... try
// return StatusCode(403, default(ErreurDTO)); {
modeFormations = await formationService.GetModesFormationAsync();
}
catch (Exception e)
{
logger.LogError(e.Message);
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(500, default(ErreurDTO)); {
string exampleJson = null; Code = StatusCodes.Status500InternalServerError,
exampleJson = "[ {\n \"libelle\" : \"libelle\",\n \"id\" : 1\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 1\n} ]"; Message = "Une erreur inconnue est survenue sur le serveur."
};
var example = exampleJson != null return StatusCode(erreur.Code.Value, erreur);
? JsonConvert.DeserializeObject<List<ModeFormationDTO>>(exampleJson) }
: default(List<ModeFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example); if (env.IsDevelopment())
logger.LogInformation("Liste des modes de formation récupérée.");
return Ok(modeFormations);
} }
/// <summary> /// <summary>
@ -308,26 +444,34 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult GetOriginesFormation() public virtual async Task<IActionResult> GetOriginesFormation()
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(200, default(List<OrigineFormationDTO>)); logger.LogInformation("Récupération de la liste des origines de formation.");
IEnumerable<OrigineFormationDTO> origineFormations;
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... try
// return StatusCode(401, default(ErreurDTO)); {
origineFormations = await formationService.GetOriginesFormationAsync();
}
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(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(403, default(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(erreur.Code.Value, erreur);
// return StatusCode(500, default(ErreurDTO)); }
string exampleJson = null;
exampleJson = "[ {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 2\n} ]";
var example = exampleJson != null if (env.IsDevelopment())
? JsonConvert.DeserializeObject<List<OrigineFormationDTO>>(exampleJson) logger.LogInformation("Liste des origines de formation récupérée.");
: default(List<OrigineFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example); return Ok(origineFormations);
} }
/// <summary> /// <summary>
@ -347,26 +491,34 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult GetStatutsFormation() public virtual async Task<IActionResult> GetStatutsFormation()
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(200, default(List<StatutFormationDTO>)); logger.LogInformation("Récupération de la liste des statuts de formation.");
IEnumerable<StatutFormationDTO> statutFormations;
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... try
// return StatusCode(401, default(ErreurDTO)); {
statutFormations = await formationService.GetStatutsFormationAsync();
}
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(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(403, default(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(erreur.Code.Value, erreur);
// return StatusCode(500, default(ErreurDTO)); }
string exampleJson = null;
exampleJson = "[ {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 4\n} ]";
var example = exampleJson != null if (env.IsDevelopment())
? JsonConvert.DeserializeObject<List<StatutFormationDTO>>(exampleJson) logger.LogInformation("Liste des statuts de formation récupérée.");
: default(List<StatutFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example); return Ok(statutFormations);
} }
/// <summary> /// <summary>
@ -386,26 +538,34 @@ 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: 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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult GetTypesFormation() public virtual async Task<IActionResult> GetTypesFormation()
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(200, default(List<TypeFormationDTO>)); logger.LogInformation("Récupération de la liste des types de formation.");
IEnumerable<TypeFormationDTO> typeFormations;
try
{
typeFormations = await formationService.GetTypesFormationAsync();
}
catch (Exception e)
{
logger.LogError(e.Message);
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(401, default(ErreurDTO)); {
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... return StatusCode(erreur.Code.Value, erreur);
// return StatusCode(403, default(ErreurDTO)); }
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(500, default(ErreurDTO)); logger.LogInformation("Liste des types de formation récupérée.");
string exampleJson = null;
exampleJson = "[ {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n}, {\n \"libelle\" : \"libelle\",\n \"id\" : 6\n} ]";
var example = exampleJson != null return Ok(typeFormations);
? JsonConvert.DeserializeObject<List<TypeFormationDTO>>(exampleJson)
: default(List<TypeFormationDTO>); //TODO: Change the data returned
return new ObjectResult(example);
} }
/// <summary> /// <summary>
@ -430,27 +590,95 @@ namespace IO.Swagger.Controllers
[SwaggerResponse(statusCode: 404, type: typeof(ErreurDTO), description: "La ressource n&#x27;a pas été trouvée")] [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: 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")] [SwaggerResponse(statusCode: 500, type: typeof(ErreurDTO), description: "Une erreur est survenue sur le serveur")]
public virtual IActionResult UpdateFormation([FromBody]FormationDTO body, [FromRoute][Required]long? idFormation) public virtual async Task<IActionResult> UpdateFormation([FromBody] FormationDTO body, [FromRoute][Required] long idFormation)
{ {
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(200); logger.LogInformation("Mise à jour de la formation d'id {idFormation}.", idFormation);
//TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... try
// return StatusCode(401, default(ErreurDTO)); {
body = await formationService.UpdateFormationAsync(idFormation, body);
//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)); catch (FormationIncompatibleIdException e)
{
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... if (env.IsDevelopment())
// return StatusCode(404, default(ErreurDTO)); logger.LogInformation(e.Message);
//TODO: Uncomment the next line to return response 415 or use other options such as return this.NotFound(), return this.BadRequest(..), ... ErreurDTO erreur = new ErreurDTO()
// return StatusCode(415, default(ErreurDTO)); {
Code = StatusCodes.Status415UnsupportedMediaType,
//TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... Message = e.Message,
// return StatusCode(500, default(ErreurDTO)); };
throw new NotImplementedException(); return StatusCode(erreur.Code.Value, erreur.Message);
}
catch (FormationInvalidException e)
{
if (env.IsDevelopment())
logger.LogInformation(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status415UnsupportedMediaType,
Message = e.Message,
};
return StatusCode(erreur.Code.Value, erreur.Message);
}
catch (FormationNotFoundException e)
{
if (env.IsDevelopment())
logger.LogInformation(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status404NotFound,
Message = e.Message
};
return NotFound(erreur);
}
catch (DbUpdateConcurrencyException e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = string.Format("La formation {0} n'a pas pu être supprimée car elle est prise par une autre ressource.", idFormation)
};
return StatusCode(erreur.Code.Value, erreur);
}
catch (DbUpdateException e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur est survenue sur le serveur lors de la suppression de la formation."
};
return StatusCode(erreur.Code.Value, erreur);
}
catch (Exception e)
{
logger.LogError(e.Message);
ErreurDTO erreur = new ErreurDTO()
{
Code = StatusCodes.Status500InternalServerError,
Message = "Une erreur inconnue est survenue sur le serveur."
};
return StatusCode(erreur.Code.Value, erreur);
}
if (env.IsDevelopment())
logger.LogInformation("Update effectué avec succès");
return Ok(body);
} }
} }
} }

@ -92,8 +92,8 @@ namespace IO.Swagger.DTO
/// </summary> /// </summary>
/// <value>Indique si la formation est certifiée ou non</value> /// <value>Indique si la formation est certifiée ou non</value>
[Required] [Required]
[DataMember(Name="estCertifie")] [DataMember(Name="estCertifiee")]
public bool? EstCertifie { get; set; } public bool? EstCertifiee { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
@ -111,7 +111,7 @@ namespace IO.Swagger.DTO
sb.Append(" Organisme: ").Append(Organisme).Append("\n"); sb.Append(" Organisme: ").Append(Organisme).Append("\n");
sb.Append(" NbParticipations: ").Append(NbParticipations).Append("\n"); sb.Append(" NbParticipations: ").Append(NbParticipations).Append("\n");
sb.Append(" Origine: ").Append(Origine).Append("\n"); sb.Append(" Origine: ").Append(Origine).Append("\n");
sb.Append(" EstCertifie: ").Append(EstCertifie).Append("\n"); sb.Append(" EstCertifie: ").Append(EstCertifiee).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -189,9 +189,9 @@ namespace IO.Swagger.DTO
Origine.Equals(other.Origine) Origine.Equals(other.Origine)
) && ) &&
( (
EstCertifie == other.EstCertifie || EstCertifiee == other.EstCertifiee ||
EstCertifie != null && EstCertifiee != null &&
EstCertifie.Equals(other.EstCertifie) EstCertifiee.Equals(other.EstCertifiee)
); );
} }
@ -221,8 +221,8 @@ namespace IO.Swagger.DTO
hashCode = hashCode * 59 + NbParticipations.GetHashCode(); hashCode = hashCode * 59 + NbParticipations.GetHashCode();
if (Origine != null) if (Origine != null)
hashCode = hashCode * 59 + Origine.GetHashCode(); hashCode = hashCode * 59 + Origine.GetHashCode();
if (EstCertifie != null) if (EstCertifiee != null)
hashCode = hashCode * 59 + EstCertifie.GetHashCode(); hashCode = hashCode * 59 + EstCertifiee.GetHashCode();
return hashCode; return hashCode;
} }
} }

@ -5,10 +5,10 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsque l'id de l'engagement avec les données à mettre à jour et l'id de l'engagement à mettre sont différents /// Exception qui est levée lorsque l'id de l'engagement avec les données à mettre à jour et l'id de l'engagement à mettre sont différents
/// </summary> /// </summary>
public class EngagementIncompatibleIdException : Exception public class EngagementIncompatibleIdException : Exception
{ {
/// <summary> /// <summary>
/// Initialise une nouvelle instance de la classe <see cref="EngagementIncompatibleIdException"/> class. /// Initialise une nouvelle instance de la classe <see cref="EngagementIncompatibleIdException"/> class.

@ -5,10 +5,10 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'un engagement est invalide /// Exception qui est levée lorsqu'un engagement est invalide
/// </summary> /// </summary>
public class EngagementInvalidException : Exception public class EngagementInvalidException : Exception
{ {
/// <summary> /// <summary>
/// Initialise une nouvelle instance de la classe <see cref="EngagementInvalidException"/> class. /// Initialise une nouvelle instance de la classe <see cref="EngagementInvalidException"/> class.

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'un engagement n'a pas été trouvé /// Exception qui est levée lorsqu'un engagement n'a pas été trouvé
/// </summary> /// </summary>
public class EngagementNotFoundException : Exception public class EngagementNotFoundException : Exception
{ {

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsque l'id de la formation avec les données à mettre à jour et l'id de la formation dans la base de données sont différents /// Exception qui est levée lorsque l'id de la formation avec les données à mettre à jour et l'id de la formation dans la base de données sont différents
/// </summary> /// </summary>
public class FormationIncompatibleIdException : Exception public class FormationIncompatibleIdException : Exception
{ {

@ -5,10 +5,10 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'une formation est invalide /// Exception qui est levée lorsqu'une formation est invalide
/// </summary> /// </summary>
public class FormationInvalidException : Exception public class FormationInvalidException : Exception
{ {
/// <summary> /// <summary>
/// Initialise une nouvelle instance de la classe <see cref="FormationInvalidException"/> class. /// Initialise une nouvelle instance de la classe <see cref="FormationInvalidException"/> class.

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'une formation n'a pas été trouvée /// Exception qui est levée lorsqu'une formation n'a pas été trouvée
/// </summary> /// </summary>
public class FormationNotFoundException : Exception public class FormationNotFoundException : Exception
{ {

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'un mode de formation n'a pas été trouvé /// Exception qui est levée lorsqu'un mode de formation n'a pas été trouvé
/// </summary> /// </summary>
public class ModeFormationNotFoundException : Exception public class ModeFormationNotFoundException : Exception
{ {

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'une origine de formation n'a pas été trouvée /// Exception qui est levée lorsqu'une origine de formation n'a pas été trouvée
/// </summary> /// </summary>
public class OrigineFormationNotFoundException : Exception public class OrigineFormationNotFoundException : Exception
{ {

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'un statut de formation n'a pas été trouvé /// Exception qui est levée lorsqu'un statut de formation n'a pas été trouvé
/// </summary> /// </summary>
public class StatutFormationNotFoundException : Exception public class StatutFormationNotFoundException : Exception
{ {

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace EPAServeur.Exceptions namespace EPAServeur.Exceptions
{ {
/// <summary> /// <summary>
/// Exception à jeter lorsqu'un type de formation n'a pas été trouvé /// Exception qui est levée lorsqu'un type de formation n'a pas été trouvé
/// </summary> /// </summary>
public class TypeFormationNotFoundException : Exception public class TypeFormationNotFoundException : Exception
{ {

@ -10,31 +10,17 @@ namespace EPAServeur.IServices
{ {
public interface IFormationService public interface IFormationService
{ {
FormationDTO GetFormationById(long? idFormation); Task<FormationDTO> GetFormationByIdAsync(long idFormation);
Task<FormationDTO> GetFormationByIdAsync(long? idFormation); Task<IEnumerable<FormationDetailsDTO>> GetFormationsAsync(long? idAgence, List<int?> idStatuts, bool? asc, int? numPage, int? parPage, string texte, string tri, DateTime? dateDebut, DateTime? dateFin);
IEnumerable<FormationDTO> GetFormations(bool? asc, int? numPage, int? parPAge, long? idAgence, int? statutFormation, string texte, string tri); Task<long> GetFormationsCountAsync(long? idAgence, List<int?> idStatuts, int? numPage, int? parPage, string texte, DateTime? dateDebut, DateTime? dateFin);
Task<IEnumerable<FormationDTO>> GetFormationsAsync(bool? asc, int? numPage, int? parPAge, long? idAgence, int? statutFormation, string texte, string tri);
IEnumerable<FormationDTO> GetFormationAnnulees(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
Task<IEnumerable<FormationDTO>> GetFormationAnnuleesAsync(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
IEnumerable<FormationDTO> GetFormationRealisees(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
Task<IEnumerable<FormationDTO>> GetFormationRealiseesAsync(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
IEnumerable<FormationDTO> GetProchainesFormation(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
Task<IEnumerable<FormationDTO>> GetProchainesFormationAsync(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
IEnumerable<ModeFormationDTO> GetModesFormation();
Task<IEnumerable<ModeFormationDTO>> GetModesFormationAsync(); Task<IEnumerable<ModeFormationDTO>> GetModesFormationAsync();
IEnumerable<OrigineFormationDTO> GetOriginesFormation();
Task<IEnumerable<OrigineFormationDTO>> GetOriginesFormationAsync(); Task<IEnumerable<OrigineFormationDTO>> GetOriginesFormationAsync();
IEnumerable<StatutFormationDTO> GetStatutsFormation();
Task<IEnumerable<StatutFormationDTO>> GetStatutsFormationAsync(); Task<IEnumerable<StatutFormationDTO>> GetStatutsFormationAsync();
IEnumerable<TypeFormationDTO> GetTypesFormation();
Task<IEnumerable<TypeFormationDTO>> GetTypesFormationAsync(); Task<IEnumerable<TypeFormationDTO>> GetTypesFormationAsync();
FormationDTO AddFormation(FormationDTO formationDTO);
Task<FormationDTO> AddFormationAsync(FormationDTO formationDTO); Task<FormationDTO> AddFormationAsync(FormationDTO formationDTO);
FormationDTO UpdateFormation(long? idFormation, FormationDTO formationDTO); Task<FormationDTO> UpdateFormationAsync(long idFormation, FormationDTO formationDTO);
Task<FormationDTO> UpdateFormationAsync(long? idFormation, FormationDTO formationDTO); Task<FormationDTO> DeleteFormationByIdAsync(long idFormation);
FormationDTO DeleteFormationById(long? idFormation);
Task<FormationDTO> DeleteFormationByIdAsync(long? idFormation);
} }
} }

@ -80,5 +80,10 @@ namespace EPAServeur.Models.Formation
/// Type de formation qui est lié à la formation /// Type de formation qui est lié à la formation
/// </summary> /// </summary>
public TypeFormation TypeFormation { get; set; } public TypeFormation TypeFormation { get; set; }
/// <summary>
/// Liste des participations qui sont liées à la formation
/// </summary>
public List<ParticipationFormation> ParticipationsFormation { get; set; }
} }
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save