@ -1,4 +1,5 @@
using EPAServeur.Context ;
using EPAServeur.Context ;
using EPAServeur.Exceptions ;
using EPAServeur.IServices ;
using EPAServeur.IServices ;
using EPAServeur.Models.Formation ;
using EPAServeur.Models.Formation ;
using IO.Swagger.DTO ;
using IO.Swagger.DTO ;
@ -47,7 +48,7 @@ namespace EPAServeur.Services
. FirstOrDefault ( formation = > formation . Id = = idFormation ) ;
. FirstOrDefault ( formation = > formation . Id = = idFormation ) ;
if ( formation = = null )
if ( formation = = null )
return null ;
throw new FormationNotFoundException ( ) ;
return GetFormationDTO ( formation ) ;
return GetFormationDTO ( formation ) ;
}
}
@ -66,7 +67,7 @@ namespace EPAServeur.Services
. FirstOrDefaultAsync ( formation = > formation . Id = = idFormation ) ;
. FirstOrDefaultAsync ( formation = > formation . Id = = idFormation ) ;
if ( formation = = null )
if ( formation = = null )
return null ;
throw new FormationNotFoundException ( ) ;
return GetFormationDTO ( formation ) ;
return GetFormationDTO ( formation ) ;
}
}
@ -81,7 +82,7 @@ namespace EPAServeur.Services
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param>
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param>
/// <returns></returns>
/// <returns></returns>
public IEnumerable < FormationDTO > GetFormations ( bool? asc , int? numPage , int? parPAge , int? idAgence , string texte , string tri )
public IEnumerable < FormationDTO > GetFormations ( bool? asc , int? numPage , int? parPAge , int? idAgence , int? statutFormation , string texte , string tri )
{
{
IEnumerable < Formation > formations ;
IEnumerable < Formation > formations ;
IEnumerable < FormationDTO > formationDTOs ;
IEnumerable < FormationDTO > formationDTOs ;
@ -94,34 +95,38 @@ namespace EPAServeur.Services
int skip = ( numPage . Value - 1 ) * parPAge . Value ;
int skip = ( numPage . Value - 1 ) * parPAge . Value ;
int take = parPAge . Value ;
int take = parPAge . Value ;
if ( idAgence ! = null )
if ( statutFormation ! = null & & idAgence ! = null )
{
{
try
formations = epContext . Formation
{
. Include ( formation = > formation . Statut )
formations = epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . TypeFormation )
. Include ( formation = > formation . Origine )
. Where ( formation = > formation . Statut . Id = = statutFormation & & formation . IdAgence = = idAgence ) ;
. Include ( formation = > formation . TypeFormation ) ;
}
}
else if ( statutFormation ! = null & & idAgence = = null )
catch ( Exception ex )
{
{
formations = epContext . Formation
throw ;
. Include ( formation = > formation . Statut )
}
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation )
. Where ( formation = > formation . Statut . Id = = statutFormation ) ;
}
else if ( idAgence ! = null )
{
formations = epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) ;
}
}
else
else
{
{
try
formations = epContext . Formation . Include ( formation = > formation . Statut )
{
. Include ( formation = > formation . ModeFormation )
formations = epContext . Formation . Include ( formation = > formation . Statut )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . TypeFormation ) ;
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) ;
}
catch ( Exception ex )
{
throw ;
}
}
}
@ -143,7 +148,7 @@ namespace EPAServeur.Services
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param>
/// <param name="texte">Texte permettant d'identifier l'objet rechercher</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param>
/// <param name="tri">Colonne du tableau sur lequel le tri s'effectue</param>
/// <returns></returns>
/// <returns></returns>
public async Task < IEnumerable < FormationDTO > > GetFormationsAsync ( bool? asc , int? numPage , int? parPAge , int? idAgence , string texte , string tri )
public async Task < IEnumerable < FormationDTO > > GetFormationsAsync ( bool? asc , int? numPage , int? parPAge , int? idAgence , int? statutFormation , string texte , string tri )
{
{
IEnumerable < Formation > formations ;
IEnumerable < Formation > formations ;
IEnumerable < FormationDTO > formationDTOs ;
IEnumerable < FormationDTO > formationDTOs ;
@ -156,34 +161,42 @@ namespace EPAServeur.Services
int skip = ( numPage . Value - 1 ) * parPAge . Value ;
int skip = ( numPage . Value - 1 ) * parPAge . Value ;
int take = parPAge . Value ;
int take = parPAge . Value ;
if ( idAgence ! = null )
if ( statutFormation ! = null & & idAgence ! = null )
{
{
try
formations = await epContext . Formation
{
. Include ( formation = > formation . Statut )
formations = await epContext . Formation
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . TypeFormation )
. Include ( formation = > formation . Origine )
. Where ( formation = > formation . Statut . Id = = statutFormation & & formation . IdAgence = = idAgence ) . ToListAsync ( ) ;
. Include ( formation = > formation . TypeFormation ) . Where ( formation = > formation . IdAgence = = idAgence ) . ToListAsync ( ) ;
}
}
else if ( statutFormation ! = null & & idAgence = = null )
catch ( Exception ex )
{
{
formations = await epContext . Formation
throw ;
. Include ( formation = > formation . Statut )
}
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation )
. Where ( formation = > formation . Statut . Id = = statutFormation ) . ToListAsync ( ) ;
}
else if ( idAgence ! = null )
{
formations = await epContext . Formation
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) . Where ( formation = > formation . IdAgence = = idAgence ) . ToListAsync ( ) ;
}
}
else
else
{
{
try
{
formations = await epContext . Formation . Include ( formation = > formation . Statut )
formations = await epContext . Formation . Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
}
}
@ -308,34 +321,23 @@ namespace EPAServeur.Services
if ( idAgence ! = null )
if ( idAgence ! = null )
{
{
try
{
formations = epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & formation . Statut . Id = = 3 )
formations = epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & formation . Statut . Id = = 3 )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) ;
. Include ( formation = > formation . TypeFormation ) ;
}
catch ( Exception ex )
{
throw ;
}
}
}
else
else
{
{
try
{
formations = epContext . Formation . Where ( formation = > formation . Statut . Id = = 3 )
formations = epContext . Formation . Where ( formation = > formation . Statut . Id = = 3 )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) ;
. Include ( formation = > formation . TypeFormation ) ;
}
catch ( Exception ex )
{
throw ;
}
}
}
@ -372,34 +374,22 @@ namespace EPAServeur.Services
if ( idAgence ! = null )
if ( idAgence ! = null )
{
{
try
{
formations = await epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & formation . Statut . Id = = 3 )
formations = await epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & formation . Statut . Id = = 3 )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
}
}
else
else
{
{
try
{
formations = await epContext . Formation . Where ( formation = > formation . Statut . Id = = 3 )
formations = await epContext . Formation . Where ( formation = > formation . Statut . Id = = 3 )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
}
}
@ -435,19 +425,14 @@ namespace EPAServeur.Services
int take = parPAge . Value ;
int take = parPAge . Value ;
if ( idAgence ! = null )
if ( idAgence ! = null )
try
{
{
formations = epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & ( formation . Statut . Id = = 1 | | formation . Statut . Id = = 2 ) )
formations = epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & ( formation . Statut . Id = = 1 | | formation . Statut . Id = = 2 ) )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) ;
. Include ( formation = > formation . TypeFormation ) ;
}
catch ( Exception ex )
{
throw ;
}
}
else
else
{
{
formations = epContext . Formation . Where ( formation = > ( formation . Statut . Id = = 1 | | formation . Statut . Id = = 2 ) )
formations = epContext . Formation . Where ( formation = > ( formation . Statut . Id = = 1 | | formation . Statut . Id = = 2 ) )
@ -489,18 +474,14 @@ namespace EPAServeur.Services
int take = parPAge . Value ;
int take = parPAge . Value ;
if ( idAgence ! = null )
if ( idAgence ! = null )
try
{
{
formations = await epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & ( formation . Statut . Id = = 1 | | formation . Statut . Id = = 2 ) )
formations = await epContext . Formation . Where ( formation = > formation . IdAgence = = idAgence & & ( formation . Statut . Id = = 1 | | formation . Statut . Id = = 2 ) )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . Statut )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . ModeFormation )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . Origine )
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
. Include ( formation = > formation . TypeFormation ) . ToListAsync ( ) ;
}
}
catch ( Exception ex )
{
throw ;
}
else
else
{
{
@ -527,14 +508,8 @@ namespace EPAServeur.Services
{
{
IEnumerable < ModeFormation > modeFormations ;
IEnumerable < ModeFormation > modeFormations ;
IEnumerable < ModeFormationDTO > modeFormationDTOs ;
IEnumerable < ModeFormationDTO > modeFormationDTOs ;
try
{
modeFormations = epContext . ModeFormation ;
modeFormations = epContext . ModeFormation ;
}
catch ( Exception ex )
{
throw ;
}
if ( modeFormations = = null )
if ( modeFormations = = null )
return null ;
return null ;
@ -552,14 +527,7 @@ namespace EPAServeur.Services
{
{
IEnumerable < ModeFormation > modeFormations ;
IEnumerable < ModeFormation > modeFormations ;
IEnumerable < ModeFormationDTO > modeFormationDTOs ;
IEnumerable < ModeFormationDTO > modeFormationDTOs ;
try
modeFormations = await epContext . ModeFormation . ToListAsync ( ) ;
{
modeFormations = await epContext . ModeFormation . ToListAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
if ( modeFormations = = null )
if ( modeFormations = = null )
return null ;
return null ;
@ -578,14 +546,7 @@ namespace EPAServeur.Services
IEnumerable < OrigineFormation > origineFormations ;
IEnumerable < OrigineFormation > origineFormations ;
IEnumerable < OrigineFormationDTO > origineFormationDTOs ;
IEnumerable < OrigineFormationDTO > origineFormationDTOs ;
try
origineFormations = epContext . OrigineFormation ;
{
origineFormations = epContext . OrigineFormation ;
}
catch ( Exception ex )
{
throw ;
}
if ( origineFormations = = null )
if ( origineFormations = = null )
return null ;
return null ;
@ -604,14 +565,7 @@ namespace EPAServeur.Services
IEnumerable < OrigineFormation > origineFormations ;
IEnumerable < OrigineFormation > origineFormations ;
IEnumerable < OrigineFormationDTO > origineFormationDTOs ;
IEnumerable < OrigineFormationDTO > origineFormationDTOs ;
try
origineFormations = await epContext . OrigineFormation . ToListAsync ( ) ;
{
origineFormations = await epContext . OrigineFormation . ToListAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
if ( origineFormations = = null )
if ( origineFormations = = null )
return null ;
return null ;
@ -630,15 +584,7 @@ namespace EPAServeur.Services
IEnumerable < StatutFormation > statutFormations ;
IEnumerable < StatutFormation > statutFormations ;
IEnumerable < StatutFormationDTO > statutFormationDTOs ;
IEnumerable < StatutFormationDTO > statutFormationDTOs ;
try
statutFormations = epContext . StatutFormation ;
{
statutFormations = epContext . StatutFormation ;
}
catch ( Exception ex )
{
throw ;
}
if ( statutFormations = = null )
if ( statutFormations = = null )
return null ;
return null ;
@ -657,15 +603,7 @@ namespace EPAServeur.Services
IEnumerable < StatutFormation > statutFormations ;
IEnumerable < StatutFormation > statutFormations ;
IEnumerable < StatutFormationDTO > statutFormationDTOs ;
IEnumerable < StatutFormationDTO > statutFormationDTOs ;
try
statutFormations = await epContext . StatutFormation . ToListAsync ( ) ;
{
statutFormations = await epContext . StatutFormation . ToListAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
if ( statutFormations = = null )
if ( statutFormations = = null )
return null ;
return null ;
@ -684,14 +622,7 @@ namespace EPAServeur.Services
IEnumerable < TypeFormation > typeFormations ;
IEnumerable < TypeFormation > typeFormations ;
IEnumerable < TypeFormationDTO > typeFormationDTOs ;
IEnumerable < TypeFormationDTO > typeFormationDTOs ;
try
typeFormations = epContext . TypeFormation ;
{
typeFormations = epContext . TypeFormation ;
}
catch ( Exception ex )
{
throw ;
}
if ( typeFormations = = null )
if ( typeFormations = = null )
return null ;
return null ;
@ -710,14 +641,7 @@ namespace EPAServeur.Services
IEnumerable < TypeFormation > typeFormations ;
IEnumerable < TypeFormation > typeFormations ;
IEnumerable < TypeFormationDTO > typeFormationDTOs ;
IEnumerable < TypeFormationDTO > typeFormationDTOs ;
try
typeFormations = await epContext . TypeFormation . ToListAsync ( ) ;
{
typeFormations = await epContext . TypeFormation . ToListAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
if ( typeFormations = = null )
if ( typeFormations = = null )
return null ;
return null ;
@ -734,27 +658,21 @@ namespace EPAServeur.Services
/// <returns></returns>
/// <returns></returns>
public FormationDTO AddFormation ( FormationDTO formationDTO )
public FormationDTO AddFormation ( FormationDTO formationDTO )
{
{
if ( ! IsFormationValide ( formationDTO ) )
throw new FormationInvalidException ( ) ;
Formation formation = new Formation ( ) ;
Formation formation = new Formation ( ) ;
formation = SetFormation ( formation , formationDTO ) ;
formation = SetFormation ( formation , formationDTO ) ;
if ( formation . Statut ! = null )
if ( formation . Statut ! = null )
{
epContext . StatutFormation . Attach ( formation . Statut ) ;
epContext . StatutFormation . Attach ( formation . Statut ) ;
}
epContext . OrigineFormation . Attach ( formation . Origine ) ;
epContext . OrigineFormation . Attach ( formation . Origine ) ;
epContext . ModeFormation . Attach ( formation . ModeFormation ) ;
epContext . ModeFormation . Attach ( formation . ModeFormation ) ;
epContext . TypeFormation . Attach ( formation . TypeFormation ) ;
epContext . TypeFormation . Attach ( formation . TypeFormation ) ;
epContext . Add ( formation ) ;
epContext . Add ( formation ) ;
try
epContext . SaveChanges ( ) ;
{
epContext . SaveChanges ( ) ;
}
catch ( Exception ex )
{
throw ;
}
return GetFormationDTO ( formation ) ;
return GetFormationDTO ( formation ) ;
}
}
@ -766,27 +684,21 @@ namespace EPAServeur.Services
/// <returns></returns>
/// <returns></returns>
public async Task < FormationDTO > AddFormationAsync ( FormationDTO formationDTO )
public async Task < FormationDTO > AddFormationAsync ( FormationDTO formationDTO )
{
{
if ( ! IsFormationValide ( formationDTO ) )
throw new FormationInvalidException ( ) ;
Formation formation = new Formation ( ) ;
Formation formation = new Formation ( ) ;
formation = SetFormation ( formation , formationDTO ) ;
formation = SetFormation ( formation , formationDTO ) ;
if ( formation . Statut ! = null )
if ( formation . Statut ! = null )
{
epContext . StatutFormation . Attach ( formation . Statut ) ;
epContext . StatutFormation . Attach ( formation . Statut ) ;
}
epContext . OrigineFormation . Attach ( formation . Origine ) ;
epContext . OrigineFormation . Attach ( formation . Origine ) ;
epContext . ModeFormation . Attach ( formation . ModeFormation ) ;
epContext . ModeFormation . Attach ( formation . ModeFormation ) ;
epContext . TypeFormation . Attach ( formation . TypeFormation ) ;
epContext . TypeFormation . Attach ( formation . TypeFormation ) ;
epContext . Add ( formation ) ;
epContext . Add ( formation ) ;
try
await epContext . SaveChangesAsync ( ) ;
{
await epContext . SaveChangesAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
return GetFormationDTO ( formation ) ;
return GetFormationDTO ( formation ) ;
}
}
@ -799,27 +711,20 @@ namespace EPAServeur.Services
/// <returns></returns>
/// <returns></returns>
public FormationDTO UpdateFormation ( long? idFormation , FormationDTO formationDTO )
public FormationDTO UpdateFormation ( long? idFormation , FormationDTO formationDTO )
{
{
if ( formationDTO = = null & & ! formationDTO . Id . HasValue & & formationDTO . Id . Value ! = idFormation )
if ( ! IsFormationValide ( formationDTO ) )
{
throw new FormationInvalidException ( ) ;
return null ;
}
if ( formationDTO = = null & & ! formationDTO . Id . HasValue & & formationDTO . Id . Value ! = idFormation )
throw new FormationIncompatibleIdException ( ) ;
Formation formation = epContext . Formation . Find ( idFormation ) ;
Formation formation = epContext . Formation . Find ( idFormation ) ;
if ( formation = = null )
if ( formation = = null )
{
return null ;
return null ;
}
formation = SetFormation ( formation , formationDTO ) ;
formation = SetFormation ( formation , formationDTO ) ;
try
{
epContext . SaveChanges ( ) ;
epContext . SaveChanges ( ) ;
}
catch ( Exception ex )
{
throw ;
}
return GetFormationDTO ( formation ) ;
return GetFormationDTO ( formation ) ;
}
}
@ -832,27 +737,19 @@ namespace EPAServeur.Services
/// <returns></returns>
/// <returns></returns>
public async Task < FormationDTO > UpdateFormationAsync ( long? idFormation , FormationDTO formationDTO )
public async Task < FormationDTO > UpdateFormationAsync ( long? idFormation , FormationDTO formationDTO )
{
{
if ( ! IsFormationValide ( formationDTO ) )
throw new FormationInvalidException ( ) ;
if ( formationDTO = = null & & ! formationDTO . Id . HasValue & & formationDTO . Id . Value ! = idFormation )
if ( formationDTO = = null & & ! formationDTO . Id . HasValue & & formationDTO . Id . Value ! = idFormation )
{
throw new FormationIncompatibleIdException ( ) ;
return null ;
}
Formation formation = await epContext . Formation . FindAsync ( idFormation ) ;
Formation formation = await epContext . Formation . FindAsync ( idFormation ) ;
if ( formation = = null )
if ( formation = = null )
{
return null ;
return null ;
}
formation = SetFormation ( formation , formationDTO ) ;
formation = SetFormation ( formation , formationDTO ) ;
try
await epContext . SaveChangesAsync ( ) ;
{
await epContext . SaveChangesAsync ( ) ;
}
catch ( Exception ex )
{
throw ;
}
return GetFormationDTO ( formation ) ;
return GetFormationDTO ( formation ) ;
}
}
@ -862,25 +759,19 @@ namespace EPAServeur.Services
/// </summary>
/// </summary>
/// <param name="idFormation"></param>
/// <param name="idFormation"></param>
/// <returns></returns>
/// <returns></returns>
public bool DeleteFormationById ( long? idFormation )
public FormationDTO DeleteFormationById ( long? idFormation )
{
{
Formation formation = epContext . Formation . Find ( idFormation ) ;
Formation formation = epContext . Formation . Find ( idFormation ) ;
if ( formation = = null )
if ( formation = = null )
return false ;
throw new FormationNotFoundException ( ) ;
epContext . Remove ( formation ) ;
epContext . Remove ( formation ) ;
try
{
epContext . SaveChanges ( ) ;
}
catch ( Exception )
{
throw ;
}
return true ;
epContext . SaveChanges ( ) ;
return GetFormationDTO ( formation ) ;
}
}
/// <summary>
/// <summary>
@ -888,29 +779,32 @@ namespace EPAServeur.Services
/// </summary>
/// </summary>
/// <param name="idFormation"></param>
/// <param name="idFormation"></param>
/// <returns></returns>
/// <returns></returns>
public async Task < bool > DeleteFormationByIdAsync ( long? idFormation )
public async Task < FormationDTO > DeleteFormationByIdAsync ( long? idFormation )
{
{
Formation formation = await epContext . Formation . FindAsync ( idFormation ) ;
Formation formation = await epContext . Formation . FindAsync ( idFormation ) ;
if ( formation = = null )
if ( formation = = null )
return false ;
throw new FormationNotFoundException ( ) ;
epContext . Remove ( formation ) ;
epContext . Remove ( formation ) ;
try
await epContext . SaveChangesAsync ( ) ;
{
await epContext . SaveChangesAsync ( ) ;
}
catch ( Exception )
{
throw ;
}
return true ;
return GetFormationDTO ( formation ) ;
}
}
# endregion
# endregion
#region Méthodes Privée
#region Méthodes Privée
/// <summary>
/// Vérifier si un objet FormationDTO est valide pour ajout ou mise à jour
/// </summary>
/// <remarks> Un objet FormationDTO est valide si aucune de ses propriétés n'est à null</remarks>
/// <param name="formation"></param>
/// <returns>true si l'objet est valide, false sinon</returns>
private bool IsFormationValide ( FormationDTO formation )
{
return ! ( formation = = null | | formation . IdAgence = = null | | formation . Intitule = = null | | formation . Organisme = = null ) ;
}
#region Object to DTO
#region Object to DTO
/// <summary>
/// <summary>