Ajout du service engagement et de l'api engagement

develop
jboinembalome 4 years ago
parent 991401d487
commit cd6439a643
  1. 4
      ApiCollaborateur/ReferentApi.cs
  2. 98
      Context/EpContext.cs
  3. 87
      Controllers/EngagementsApi.cs
  4. 4
      DTO/EpInformationDTO.cs
  5. 20
      IServices/IEngagementService.cs
  6. 4
      Models/EP/Ep.cs
  7. 323
      Services/EngagementService.cs
  8. 2
      Startup.cs

@ -986,7 +986,7 @@ namespace IO.Swagger.ApiCollaborateur
if (refId == null)
throw new ApiException(400, "Missing required parameter 'refId' when calling ReferentApi->ChercherRefId");
var localVarPath = "/referent/{refId}";
var localVarPath = "/referents/{refId}";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new List<KeyValuePair<String, String>>();
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader);
@ -1052,7 +1052,7 @@ namespace IO.Swagger.ApiCollaborateur
if (refId == null)
throw new ApiException(400, "Missing required parameter 'refId' when calling ReferentApi->ChercherRefId");
var localVarPath = "/referent/{refId}";
var localVarPath = "/referents/{refId}";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new List<KeyValuePair<String, String>>();
var localVarHeaderParams = new Dictionary<String, String>(this.Configuration.DefaultHeader);

@ -506,14 +506,14 @@ namespace EPAServeur.Context
//COM --> Commercial
//DEL --> Delivery
// 10 EP
/*
Ep ep;
DemandeFormation df;
ParticipationFormation pf;
//DemandeFormation df;
//ParticipationFormation pf;
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "COM1",
IdCollaborateur = Guid.Parse("1ec99fde-f756-11ea-adc1-0242ac120002"),
IdReferent = Guid.Parse("1ec9a204-f756-11ea-adc1-0242ac120002"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -526,20 +526,20 @@ namespace EPAServeur.Context
CV = "CV.pdf",
DateSaisie = new DateTime(2018, 6, 20)
};
df = new DemandeFormation
{
Description = "Description formation",
DemandeRH = false,
DateDemande = new DateTime(2018, 7, 8),
};
//df = new DemandeFormation
//{
// Description = "Description formation",
// DemandeRH = false,
// DateDemande = new DateTime(2018, 7, 8),
//};
Ep.Add(ep);
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("779bf1cf-4d38-48fb-8550-3d583384523b"),
IdReferent = Guid.Parse("ecf528c3-e509-402f-87bb-c8821467e350"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -556,8 +556,8 @@ namespace EPAServeur.Context
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("006226f6-51b2-4a02-a302-7447f7fccc04"),
IdReferent = Guid.Parse("ecf528c3-e509-402f-87bb-c8821467e350"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -574,8 +574,8 @@ namespace EPAServeur.Context
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("f960f851-16b6-4631-952e-d05f38d8d80f"),
IdReferent = Guid.Parse("6aa62dcb-f7c9-4c0c-af40-e934a4d6a7eb"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -592,8 +592,8 @@ namespace EPAServeur.Context
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("efb063b2-ce1e-4d19-8340-d4b0b022d0d0"),
IdReferent = Guid.Parse("3fa56dc6-8597-4030-a0b2-1619b98c428d"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -610,8 +610,8 @@ namespace EPAServeur.Context
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("e5d36da4-df16-4d19-8a11-1ba2f6efc80c"),
IdReferent = Guid.Parse("3fa56dc6-8597-4030-a0b2-1619b98c428d"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -627,8 +627,8 @@ namespace EPAServeur.Context
Ep.Add(ep);
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("9e1ee839-4477-4d64-9b4d-80654c97c39f"),
IdReferent = Guid.Parse("efb063b2-ce1e-4d19-8340-d4b0b022d0d0"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -645,8 +645,8 @@ namespace EPAServeur.Context
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("3f532f4c-a5c9-466c-b7c1-fdc6bc48780e"),
IdReferent = Guid.Parse("efb063b2-ce1e-4d19-8340-d4b0b022d0d0"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -663,8 +663,8 @@ namespace EPAServeur.Context
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("59a8becb-bc0a-4d3d-adb1-8a8bd13c48c9"),
IdReferent = Guid.Parse("e5d36da4-df16-4d19-8a11-1ba2f6efc80c"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -681,8 +681,8 @@ namespace EPAServeur.Context
ep = new Ep
{
IdCollaborateur = "C1",
IdReferent = "C6",
IdCollaborateur = Guid.Parse("a00eb610-d735-4a83-ac5a-7b89cbd4b42d"),
IdReferent = Guid.Parse("d3f69a83-8a29-4971-8d3c-2d0cf320dad2"),
IdAgence = 1,
IdBu = 2,
Fonction = "Dev",
@ -696,9 +696,47 @@ namespace EPAServeur.Context
DateSaisie = new DateTime(2018, 6, 20)
};
Ep.Add(ep);
*/
Engagement engagement;
engagement = new Engagement
{
Action = "Je m'engage à...",
Disposition = "interne",
Modalite = "Modalite",
DateLimite = new DateTime(2017, 7, 7),
Realise = false,
Realisable = true,
RaisonNonRealisable = null,
Ep = ep
};
Engagement.Add(engagement);
engagement = new Engagement
{
Action = "Je m'engage à faire...",
Disposition = "externe",
Modalite = "Modalite 2",
DateLimite = new DateTime(2017, 7, 8),
Realise = true,
Realisable = true,
RaisonNonRealisable = null,
Ep = ep
};
Engagement.Add(engagement);
engagement = new Engagement
{
Action = "Je m'engage à faire...",
Disposition = "externe",
Modalite = "Modalite 3",
DateLimite = new DateTime(2017, 7, 8),
Realise = null,
Realisable = null,
RaisonNonRealisable = "Aucune formation disponible",
Ep = ep
};
Engagement.Add(engagement);
//AVoir un tableau pour dire combien de demande de formations seront faites pour chaque EP
//Avoir un tableau pour dire combien de demande de Participation seront faites et accepter (max : 11)
//La formation associée sera choisie de manière aléatoire parmi celles créées (pas grave si la cohérence niveau date est foireuse....)

@ -18,6 +18,7 @@ using IO.Swagger.Attributes;
using IO.Swagger.Security;
using Microsoft.AspNetCore.Authorization;
using IO.Swagger.DTO;
using EPAServeur.IServices;
namespace IO.Swagger.Controllers
{
@ -27,6 +28,12 @@ namespace IO.Swagger.Controllers
[ApiController]
public class EngagementsApiController : ControllerBase
{
private readonly IEngagementService engagementService;
public EngagementsApiController(IEngagementService _engagementService)
{
engagementService = _engagementService;
}
/// <summary>
///
/// </summary>
@ -41,7 +48,7 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/engagements")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetEngagements")]
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")]
@ -49,17 +56,18 @@ namespace IO.Swagger.Controllers
public virtual IActionResult GetEngagements([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? idAgence, [FromQuery]string texte, [FromQuery]string tri)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(List<EngagementDTO>));
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(403, default(ErreurDTO));
string exampleJson = null;
exampleJson = "[ {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n}, {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n} ]";
IEnumerable<EngagementDTO> engagements = engagementService.GetEngagements(asc, numPage, parPAge, idAgence, texte, tri);
if (engagements == null)
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucun engagement"
};
return NotFound(erreur);
}
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<EngagementDTO>>(exampleJson)
: default(List<EngagementDTO>); //TODO: Change the data returned
return new ObjectResult(example);
return Ok(engagements);
}
/// <summary>
@ -76,7 +84,7 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/engagements/enattente")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetEngagementsEnAttente")]
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")]
@ -84,17 +92,18 @@ namespace IO.Swagger.Controllers
public virtual IActionResult GetEngagementsEnAttente([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? idAgence, [FromQuery]string texte, [FromQuery]string tri)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(List<EngagementDTO>));
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(403, default(ErreurDTO));
string exampleJson = null;
exampleJson = "[ {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n}, {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n} ]";
IEnumerable<EngagementDTO> engagements = engagementService.GetEngagementsEnAttente(asc, numPage, parPAge, idAgence, texte, tri);
if (engagements == null)
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucun engagement en attente"
};
return NotFound(erreur);
}
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<EngagementDTO>>(exampleJson)
: default(List<EngagementDTO>); //TODO: Change the data returned
return new ObjectResult(example);
return Ok(engagements);
}
/// <summary>
@ -111,7 +120,7 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpGet]
[Route("/api/engagements/repondus")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("GetEngagementsRepondus")]
[SwaggerResponse(statusCode: 200, type: typeof(List<EngagementDTO>), description: "OK")]
@ -119,17 +128,18 @@ namespace IO.Swagger.Controllers
public virtual IActionResult GetEngagementsRepondus([FromQuery][Required()]bool? asc, [FromQuery][Required()]int? numPage, [FromQuery][Required()]int? parPAge, [FromQuery]long? idAgence, [FromQuery]string texte, [FromQuery]string tri)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(List<EngagementDTO>));
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(403, default(ErreurDTO));
string exampleJson = null;
exampleJson = "[ {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n}, {\n \"realisable\" : true,\n \"realise\" : true,\n \"action\" : \"action\",\n \"id\" : 2,\n \"datePrevisionnelle\" : \"2000-01-23T04:56:07.000+00:00\",\n \"dispositif\" : \"dispositif\",\n \"modalite\" : \"modalite\",\n \"raisonNonRealisable\" : \"raisonNonRealisable\"\n} ]";
IEnumerable<EngagementDTO> engagements = engagementService.GetEngagementsRepondus(asc, numPage, parPAge, idAgence, texte, tri);
if (engagements == null)
{
ErreurDTO erreur = new ErreurDTO()
{
Code = "404",
Message = "Aucun engagement en repondu"
};
return NotFound(erreur);
}
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<EngagementDTO>>(exampleJson)
: default(List<EngagementDTO>); //TODO: Change the data returned
return new ObjectResult(example);
return Ok(engagements);
}
/// <summary>
@ -142,19 +152,18 @@ namespace IO.Swagger.Controllers
/// <response code="403">Acces interdit</response>
[HttpPut]
[Route("/api/engagements/{idEngagement}/repondre")]
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
//[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
[ValidateModelState]
[SwaggerOperation("RepondreEngagement")]
[SwaggerResponse(statusCode: 403, type: typeof(ErreurDTO), description: "Acces interdit")]
public virtual IActionResult RepondreEngagement([FromBody]EngagementDTO body, [FromRoute][Required]long? idEngagement)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200);
//if (body != null && body.Realise == false && string.IsNullOrWhiteSpace(body.RaisonNonRealisable))
// return null; // A traiter ! Retourner une erreur
//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));
EngagementDTO engagement = engagementService.RepondreEngagement(body, idEngagement);
throw new NotImplementedException();
return Ok(engagement);
}
}
}

@ -38,14 +38,14 @@ namespace IO.Swagger.DTO
/// </summary>
[Required]
[DataMember(Name="type")]
public int? Type { get; set; }
public string Type { get; set; }
/// <summary>
/// Gets or Sets Statut
/// </summary>
[Required]
[DataMember(Name="statut")]
public int? Statut { get; set; }
public string Statut { get; set; }
/// <summary>
/// Gets or Sets DateDisponibilite

@ -0,0 +1,20 @@
using EPAServeur.Context;
using IO.Swagger.DTO;
using IO.Swagger.ModelCollaborateur;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EPAServeur.IServices
{
public interface IEngagementService
{
IEnumerable<EngagementDTO> GetEngagements(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
IEnumerable<EngagementDTO> GetEngagementsEnAttente(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
IEnumerable<EngagementDTO> GetEngagementsRepondus(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri);
EngagementDTO RepondreEngagement(EngagementDTO engagement, long? idEngagement);
}
}

@ -24,8 +24,8 @@ namespace EPAServeur.Models.EP
public class Ep
{
public long Id { get; set; }
public string IdCollaborateur { get; set; }
public string IdReferent { get; set; }
public Guid IdCollaborateur { get; set; }
public Guid IdReferent { get; set; }
public long IdAgence { get; set; }
public long IdBu { get; set; }
public string Fonction { get; set; }

@ -0,0 +1,323 @@
using EPAServeur.Context;
using EPAServeur.IServices;
using EPAServeur.Models.EP;
using EPAServeur.Models.Formation;
using EPAServeur.Models.SaisieChamp;
using IO.Swagger.DTO;
using IO.Swagger.ModelCollaborateur;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace EPAServeur.Services
{
public class EngagementService : IEngagementService
{
#region Variables
private readonly EpContext epContext;
private readonly ICollaborateurService collaborateurService;
#endregion
#region Contructeurs
/// <summary>
/// Constructeur de la classe EngagementService
/// </summary>
/// <param name="_epContext"></param>
public EngagementService(EpContext _epContext, ICollaborateurService _collaborateurService)
{
epContext = _epContext;
collaborateurService = _collaborateurService;
}
#endregion
#region Méthodes Service
public IEnumerable<EngagementDTO> GetEngagements(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri)
{
IEnumerable<Engagement> engagements;
IEnumerable<EngagementDTO> engagementDTOs;
if (texte == null)
texte = "";
else
texte = texte.ToLower();
int skip = (numPage.Value - 1) * parPAge.Value;
int take = parPAge.Value;
if (idAgence != null)
{
try
{
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Ep.IdAgence == idAgence);
}
catch (Exception ex)
{
throw;
}
}
else
{
try
{
engagements = epContext.Engagement.Include(engagement => engagement.Ep);
}
catch (Exception ex)
{
throw;
}
}
if (engagements == null)
return null;
engagementDTOs = engagements.Where(engagement => engagement.Modalite.ToLower().Contains(texte)).Select(engagement => GetEngagementDTO(engagement));
return engagementDTOs;
}
public IEnumerable<EngagementDTO> GetEngagementsEnAttente(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri)
{
IEnumerable<Engagement> engagements;
IEnumerable<EngagementDTO> engagementDTOs;
if (texte == null)
texte = "";
else
texte = texte.ToLower();
int skip = (numPage.Value - 1) * parPAge.Value;
int take = parPAge.Value;
if (idAgence != null)
{
try
{
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Ep.IdAgence == idAgence && engagement.Realise == null);
}
catch (Exception ex)
{
throw;
}
}
else
{
try
{
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Realise == null);
}
catch (Exception ex)
{
throw;
}
}
if (engagements == null)
return null;
engagementDTOs = engagements.Where(engagement => engagement.Modalite.ToLower().Contains(texte)).Select(engagement => GetEngagementDTO(engagement));
return engagementDTOs;
}
public IEnumerable<EngagementDTO> GetEngagementsRepondus(bool? asc, int? numPage, int? parPAge, long? idAgence, string texte, string tri)
{
IEnumerable<Engagement> engagements;
IEnumerable<EngagementDTO> engagementDTOs;
if (texte == null)
texte = "";
else
texte = texte.ToLower();
int skip = (numPage.Value - 1) * parPAge.Value;
int take = parPAge.Value;
if (idAgence != null)
{
try
{
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Ep.IdAgence == idAgence && engagement.Realise != null);
}
catch (Exception ex)
{
throw;
}
}
else
{
try
{
engagements = epContext.Engagement.Include(engagement => engagement.Ep).Where(engagement => engagement.Realise != null);
}
catch (Exception ex)
{
throw;
}
}
if (engagements == null)
return null;
engagementDTOs = engagements.Where(engagement => engagement.Modalite.ToLower().Contains(texte)).Select(engagement => GetEngagementDTO(engagement));
return engagementDTOs;
}
/// <summary>
/// Donner une réponse à un engagement
/// </summary>
/// <param name="engagementDTO"></param>
/// <param name="idEngagement"></param>
/// <returns></returns>
public EngagementDTO RepondreEngagement(EngagementDTO engagementDTO, long? idEngagement)
{
if (!IsEngagementValide(engagementDTO))
return null;
if (engagementDTO.Id != idEngagement)
return null;
if (engagementDTO.Realise == false && string.IsNullOrWhiteSpace(engagementDTO.RaisonNonRealisable))
return null; // Créer une exception pour ce cas
Engagement engagement = epContext.Engagement.Include(engagement => engagement.Ep).FirstOrDefault(engagement => engagement.Id == idEngagement);
if (engagement == null)
return null;
engagement.Realise = engagementDTO.Realise;
if (engagement.Realise == false)
{
engagement.Realisable = engagementDTO.Realisable;
engagement.RaisonNonRealisable = engagementDTO.RaisonNonRealisable;
}
epContext.SaveChanges();
return GetEngagementDTO(engagement);
}
#endregion
#region Méthodes Privée
private bool IsEngagementValide(EngagementDTO engagementDTO)
{
return !(engagementDTO == null || engagementDTO.Id == null || engagementDTO.Action == null || engagementDTO.DatePrevisionnelle == null || engagementDTO.Dispositif == null || engagementDTO.Modalite == null);
}
#region Object to DTO
/// <summary>
/// Récupère un objet EngagementDTO en fonction d'un objet Engagement
/// </summary>
/// <param name="engagement"></param>
/// <returns></returns>
private EngagementDTO GetEngagementDTO(Engagement engagement)
{
EngagementDTO engagementDTO = new EngagementDTO()
{
Id = engagement.Id,
Action = engagement.Action,
DatePrevisionnelle = engagement.DateLimite,
Dispositif = engagement.Disposition,
Modalite = engagement.Modalite,
RaisonNonRealisable = engagement.RaisonNonRealisable,
Realisable = engagement.Realisable,
Realise = engagement.Realise,
Ep = GetEpInformationDTO(engagement.Ep)
};
return engagementDTO;
}
/// <summary>
/// Récupère un objet EpInformationDTO en fonction d'un objet Ep
/// </summary>
/// <param name="ep"></param>
/// <returns></returns>
private EpInformationDTO GetEpInformationDTO(Ep ep)
{
EpInformationDTO epInformationDTO = new EpInformationDTO()
{
Id = ep.Id,
Type = ep.TypeEP.ToString(),
Statut = ep.Statut.ToString(),
DatePrevisionnelle = ep.DatePrevisionnelle,
Obligatoire = ep.Obligatoire,
Collaborateur = collaborateurService.GetProfilById(ep.IdCollaborateur)
//Referent = null //collaborateurService.GetProfilById(ep.IdReferent)
//Ajouter la date de disponibilité
};
return epInformationDTO;
}
#endregion
#region DTO to Object
/// <summary>
/// Modifie un objet Engagement en fonction d'un objet FormationDTO
/// </summary>
/// <param name="engagement"></param>
/// <param name="engagementDTO"></param>
/// <returns></returns>
private Engagement SetEngagement(Engagement engagement, EngagementDTO engagementDTO)
{
engagement.Action = engagementDTO.Action;
engagement.DateLimite = engagementDTO.DatePrevisionnelle.Value;
engagement.Disposition = engagementDTO.Dispositif;
engagement.Modalite = engagementDTO.Modalite;
engagement.RaisonNonRealisable = engagementDTO.RaisonNonRealisable;
engagement.Realisable = engagementDTO.Realisable;
engagement.Realise = engagementDTO.Realise;
engagement.Ep = GetEp(engagementDTO.Ep);
return engagement;
}
/// <summary>
/// Récupère un objet Ep en fonction d'un objet EpDTO
/// </summary>
/// <param name="origineFormationDTO"></param>
/// <returns></returns>
private Ep GetEp(EpInformationDTO epInformationDTO)
{
if (epInformationDTO == null)
return null;
// Traiter
Enum.TryParse(epInformationDTO.Type, out TypeChamp typeChamp);
Enum.TryParse(epInformationDTO.Statut, out StatutEP statutEP);
Ep ep = new Ep()
{
Id = epInformationDTO.Id.Value,
TypeEP = typeChamp,
Statut = statutEP,
DatePrevisionnelle = epInformationDTO.DatePrevisionnelle.Value,
Obligatoire = epInformationDTO.Obligatoire.Value,
IdReferent = epInformationDTO.Referent.Id.Value,
IdCollaborateur = epInformationDTO.Collaborateur.Id.Value,
// Ajouter la date de disponibilité
};
return ep;
}
#endregion
#endregion
}
}

@ -59,7 +59,7 @@ namespace EPAServeur
services.AddScoped<IFormationService, FormationService>();
services.AddScoped<INoteService, NoteService>();
services.AddScoped<IReferentService, ReferentService>();
services.AddScoped<IEngagementService, EngagementService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

Loading…
Cancel
Save