Modification des noms de variables dans le service formation et l'api formation

develop
jboinembalome 4 years ago
parent 79e8a86071
commit 52977a4520
  1. 18
      Controllers/FormationsApi.cs
  2. 6
      IServices/IFormationService.cs
  3. 36
      Services/FormationService.cs

@ -106,7 +106,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<FormationDTO> formations = formationService.GetFormationAnnulees(asc, numPage, parPAge, idAgence, texte, tri);
if (formations.Count() == 0)
if (formations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -175,7 +175,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<FormationDTO> formations = formationService.GetFormationRealisee(asc, numPage, parPAge, idAgence, texte, tri);
if (formations.Count() == 0)
if (formations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -213,7 +213,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<FormationDTO> formations = formationService.GetFormations(asc, numPage, parPAge, idAgence, texte, tri);
if (formations.Count() == 0)
if (formations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -243,7 +243,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<ModeFormationDTO> modeFormations = formationService.GetModesFormation();
if (modeFormations.Count() == 0)
if (modeFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -273,7 +273,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<OrigineFormationDTO> origineFormations = formationService.GetOriginesFormation();
if (origineFormations.Count() == 0)
if (origineFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -311,7 +311,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<FormationDTO> formations = formationService.GetProchainesFormation(asc, numPage, parPAge, idAgence, texte, tri);
if (formations.Count() == 0)
if (formations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -341,7 +341,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<StatutFormationDTO> statutFormations = formationService.GetStatutsFormation();
if (statutFormations.Count() == 0)
if (statutFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -371,7 +371,7 @@ namespace IO.Swagger.Controllers
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
IEnumerable<TypeFormationDTO> typeFormations = formationService.GetTypesFormation();
if (typeFormations.Count() == 0)
if (typeFormations == null)
{
ErreurDTO erreur = new ErreurDTO()
{
@ -401,7 +401,7 @@ namespace IO.Swagger.Controllers
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
public virtual IActionResult UpdateFormation([FromBody] FormationDTO body, [FromRoute][Required] long? idFormation)
{
FormationDTO formation = formationService.UpdateFormation(body);
FormationDTO formation = formationService.UpdateFormation(idFormation, body);
if (formation == null)
{
formation = formationService.AddFormation(body);

@ -10,7 +10,7 @@ namespace EPAServeur.IServices
{
public interface IFormationService
{
FormationDTO GetFormationById(long? id);
FormationDTO GetFormationById(long? idFormation);
IEnumerable<FormationDTO> GetFormations(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri);
IEnumerable<FormationDTO> GetFormationAnnulees(bool? asc, int? numPage, int? parPAge, int? idAgence, string texte, string tri);
@ -22,7 +22,7 @@ namespace EPAServeur.IServices
IEnumerable<TypeFormationDTO> GetTypesFormation();
FormationDTO AddFormation(FormationDTO formationDTO);
FormationDTO UpdateFormation(FormationDTO formationDTO);
bool DeleteFormationById(long? id);
FormationDTO UpdateFormation(long? idFormation, FormationDTO formationDTO);
bool DeleteFormationById(long? idFormation);
}
}

@ -35,15 +35,15 @@ namespace EPAServeur.Services
/// <summary>
/// Récupérer une formation par son id
/// </summary>
/// <param name="id"></param>
/// <param name="idFormation"></param>
/// <returns></returns>
public FormationDTO GetFormationById(long? id)
public FormationDTO GetFormationById(long? idFormation)
{
Formation formation = epContext.Formation.Include(formation => formation.Statut)
.Include(formation => formation.ModeFormation)
.Include(formation => formation.Origine)
.Include(formation => formation.TypeFormation)
.FirstOrDefault(formation => formation.Id == id);
.FirstOrDefault(formation => formation.Id == idFormation);
if (formation == null)
return null;
@ -106,7 +106,7 @@ namespace EPAServeur.Services
if (formations == null)
return new List<FormationDTO>();
return null;
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
@ -150,7 +150,7 @@ namespace EPAServeur.Services
.Include(formation => formation.TypeFormation);
if (formations == null)
return new List<FormationDTO>();
return null;
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
@ -214,7 +214,7 @@ namespace EPAServeur.Services
if (formations == null)
return new List<FormationDTO>();
return null;
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
@ -268,7 +268,7 @@ namespace EPAServeur.Services
}
if (formations == null)
return new List<FormationDTO>();
return null;
formationDTOs = formations.Where(formation => formation.Intitule.ToLower().Contains(texte)).Select(formation => GetFormationDTO(formation));
@ -292,6 +292,9 @@ namespace EPAServeur.Services
throw;
}
if (modeFormations == null)
return null;
modeFormationDTOs = modeFormations.Select(modeFormation => GetModeFormationDTO(modeFormation));
return modeFormationDTOs;
@ -315,6 +318,9 @@ namespace EPAServeur.Services
throw;
}
if (origineFormations == null)
return null;
origineFormationDTOs = origineFormations.Select(origineFormation => GetOrigineFormationDTO(origineFormation));
return origineFormationDTOs;
@ -339,6 +345,9 @@ namespace EPAServeur.Services
throw;
}
if (statutFormations == null)
return null;
statutFormationDTOs = statutFormations.Select(statutFormation => GetStatutFormationDTO(statutFormation));
return statutFormationDTOs;
@ -362,6 +371,9 @@ namespace EPAServeur.Services
throw;
}
if (typeFormations == null)
return null;
typeFormationDTOs = typeFormations.Select(typeFormation => GetTypeFormationDTO(typeFormation));
return typeFormationDTOs;
@ -404,9 +416,9 @@ namespace EPAServeur.Services
/// </summary>
/// <param name="formationDTO"></param>
/// <returns></returns>
public FormationDTO UpdateFormation(FormationDTO formationDTO)
public FormationDTO UpdateFormation(long? idFormation, FormationDTO formationDTO)
{
Formation formation = epContext.Formation.FirstOrDefault(formation => formation.Id == formationDTO.Id);
Formation formation = epContext.Formation.Find(idFormation);
if (formation == null)
{
@ -429,11 +441,11 @@ namespace EPAServeur.Services
/// <summary>
/// Supprimer une formation
/// </summary>
/// <param name="id"></param>
/// <param name="idFormation"></param>
/// <returns></returns>
public bool DeleteFormationById(long? id)
public bool DeleteFormationById(long? idFormation)
{
Formation formation = epContext.Formation.FirstOrDefault(formation => formation.Id == id);
Formation formation = epContext.Formation.Find(idFormation);
if (formation == null)
return false;

Loading…
Cancel
Save