Implémentation du service collaborateur

master
Yanaël GRETTE 4 years ago
parent 0506fa42a7
commit d93251c2ea
  1. 2
      ApiCollaborateur/CollaborateurApi.cs
  2. 5
      ClientCollaborateur/ApiClient.cs
  3. 6
      Controllers/CollaborateursApi.cs
  4. 6
      IServices/ICollaborateurService.cs
  5. 136
      Services/CollaborateurService.cs
  6. 1
      Startup.cs

@ -1186,7 +1186,7 @@ namespace IO.Swagger.ApiCollaborateur
/// <returns>Collaborateur</returns> /// <returns>Collaborateur</returns>
public Collaborateur ChercherCollabId (Guid? collabId) public Collaborateur ChercherCollabId (Guid? collabId)
{ {
ApiResponse<Collaborateur> localVarResponse = ChercherCollabIdWithHttpInfo(collabId); ApiResponse<Collaborateur> localVarResponse = ChercherCollabIdWithHttpInfo(collabId);
if(localVarResponse != null) if(localVarResponse != null)
return localVarResponse.Data; return localVarResponse.Data;
return null; return null;

@ -315,11 +315,6 @@ namespace IO.Swagger.ClientCollaborateur
{ {
return ConvertType(response.Content, type); return ConvertType(response.Content, type);
} }
Console.WriteLine(response.Content);
Console.WriteLine("JFPEIOZJEZPIOFJENPOI");
Console.WriteLine(type.Name);
Console.WriteLine("18616840684");
Console.WriteLine(response.Content);
// at this point, it must be a model (json) // at this point, it must be a model (json)
try try
{ {

@ -53,7 +53,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(..), ... //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(CollaborateurDTO)); // return StatusCode(200, default(CollaborateurDTO));
Console.WriteLine("COUCOU");
CollaborateurDTO collaborateurDTO = collaborateurService.GetCollaborateurById(idCollaborateur); CollaborateurDTO collaborateurDTO = collaborateurService.GetCollaborateurById(idCollaborateur);
if( collaborateurDTO == null) if( collaborateurDTO == null)
{ {
@ -62,9 +62,9 @@ namespace IO.Swagger.Controllers
Code = "404", Code = "404",
Message = "Le collaborateur n'existe pas", Message = "Le collaborateur n'existe pas",
}; };
return StatusCode(404, erreurDTO); return NotFound(erreurDTO);
} }
return StatusCode(200, collaborateurDTO); return Ok(collaborateurDTO);
//TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... //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)); // return StatusCode(403, default(ErreurDTO));

@ -15,11 +15,5 @@ namespace EPAServeur.IServices
ProfilDTO GetProfilByMail(string mail); ProfilDTO GetProfilByMail(string mail);
List<CollaborateurDTO> GetCollaborateurs(); List<CollaborateurDTO> GetCollaborateurs();
List<CollaborateurDTO> GetCollaborateursByReferent(Guid? idRefent); List<CollaborateurDTO> GetCollaborateursByReferent(Guid? idRefent);
//Object to DTO
CollaborateurDTO GetCollaborateurDTO(Collaborateur collaborateur);
BusinessUnitDTO GetBusinessUnitDTO(BU businessUnit);
AgenceDTO GetAgenceDTO(Agence agence);
ReferentDTO GetReferentDTO(Collaborateur referent);
} }
} }

@ -21,40 +21,6 @@ namespace EPAServeur.Services
collaborateurApi = _collaborateurApi; collaborateurApi = _collaborateurApi;
} }
//
public AgenceDTO GetAgenceDTO(Agence agence)
{
if (agence == null)
return null;
AgenceDTO agenceDTO = new AgenceDTO()
{
Id = agence.Id,
Nom = agence.Nom,
Bu = new List<BusinessUnitDTO>()
};
foreach(BU bu in agence.Bus)
{
agenceDTO.Bu.Add(new BusinessUnitDTO()
{
Id = bu.Id,
Nom = bu.Nom
});
}
return agenceDTO;
}
public BusinessUnitDTO GetBusinessUnitDTO(BU businessUnit)
{
if (businessUnit == null)
return null;
BusinessUnitDTO businessUnitDTO = new BusinessUnitDTO()
{
Id = businessUnit.Id,
Nom = businessUnit.Nom,
Agence = GetAgenceDTO(businessUnit.Agence)
};
return businessUnitDTO;
}
public CollaborateurDTO GetCollaborateurById(Guid? id) public CollaborateurDTO GetCollaborateurById(Guid? id)
{ {
@ -72,21 +38,6 @@ namespace EPAServeur.Services
return GetCollaborateurDTO(collaborateur); return GetCollaborateurDTO(collaborateur);
} }
public CollaborateurDTO GetCollaborateurDTO(Collaborateur collaborateur)
{
CollaborateurDTO collaborateurDTO = new CollaborateurDTO()
{
Id = collaborateur.Id,
Prenom = collaborateur.Prenom,
Nom = collaborateur.Nom,
MailApside = collaborateur.MailApside,
DateArrivee = collaborateur.DateArrivee,
};
collaborateurDTO.BusinessUnit = GetBusinessUnitDTO(collaborateur.BusinessUnit);
collaborateurDTO.Referent = GetReferentDTO(collaborateur.Referent);
return collaborateurDTO;
}
public List<CollaborateurDTO> GetCollaborateurs() public List<CollaborateurDTO> GetCollaborateurs()
{ {
@ -100,34 +51,85 @@ namespace EPAServeur.Services
public List<CollaborateurDTO> GetCollaborateursByReferent(Guid? idReferent) public List<CollaborateurDTO> GetCollaborateursByReferent(Guid? idReferent)
{ {
/* List<Collaborateur> collaborateurs = collaborateurApi.ChercherCollabRef(idReferent);
Collaborateur collaborateur = collaborateurApi.ChercherCollabRef(idReferent); List<CollaborateurDTO> collaborateursDTO = (from c in collaborateurs
CollaborateurDTO collaborateurDTO = new CollaborateurDTO() select GetCollaborateurDTO(c)).ToList();
//List<CollaborateurDTO> collaborateursDTO = collaborateurs.Select(c => GetCollaborateurDTO(c)).ToList();
return collaborateursDTO;
}
public ProfilDTO GetProfilByMail(string mail)
{
Collaborateur collaborateur = collaborateurApi.ChercherCollabMail(mail);
if (collaborateur == null)
return null;
return GetProfilDTO(collaborateur);
}
private ProfilDTO GetProfilDTO(Collaborateur collaborateur)
{
ProfilDTO profilDTO = new ProfilDTO()
{ {
Id = collaborateur.Id, //Id = collaborateur.Id,
Prenom = collaborateur.Prenom, DateArrivee = collaborateur.DateArrivee,
Nom = collaborateur.Nom,
MailApside = collaborateur.MailApside, MailApside = collaborateur.MailApside,
DateArrivee = collaborateur.DateArrivee Nom = collaborateur.Nom,
Prenom = collaborateur.Prenom,
BusinessUnit = GetBusinessUnitDTO(collaborateur.BusinessUnit)
}; };
collaborateurDTO.Referent = new ReferentDTO() return null;
}
//Object to DTO
private AgenceDTO GetAgenceDTO(Agence agence)
{
if (agence == null)
return null;
AgenceDTO agenceDTO = new AgenceDTO()
{ {
Id = collaborateur.Referent.Id, Id = agence.Id,
Prenom = collaborateur.Referent.Prenom, Nom = agence.Nom,
Nom = collaborateur.Referent.Nom, Bu = new List<BusinessUnitDTO>()
MailApside = collaborateur.Referent.MailApside
}; };
return collaborateurDTO; agenceDTO.Bu = agence.Bus.Select(bu => new BusinessUnitDTO()
*/ {
throw new NotImplementedException(); Id = bu.Id,
Nom = bu.Nom
}).ToList();
return agenceDTO;
} }
public ProfilDTO GetProfilByMail(string mail) private BusinessUnitDTO GetBusinessUnitDTO(BU businessUnit)
{ {
throw new NotImplementedException(); if (businessUnit == null)
return null;
BusinessUnitDTO businessUnitDTO = new BusinessUnitDTO()
{
Id = businessUnit.Id,
Nom = businessUnit.Nom,
Agence = GetAgenceDTO(businessUnit.Agence)
};
return businessUnitDTO;
}
private CollaborateurDTO GetCollaborateurDTO(Collaborateur collaborateur)
{
CollaborateurDTO collaborateurDTO = new CollaborateurDTO()
{
Id = collaborateur.Id,
Prenom = collaborateur.Prenom,
Nom = collaborateur.Nom,
MailApside = collaborateur.MailApside,
DateArrivee = collaborateur.DateArrivee,
};
collaborateurDTO.BusinessUnit = GetBusinessUnitDTO(collaborateur.BusinessUnit);
collaborateurDTO.Referent = GetReferentDTO(collaborateur.Referent);
return collaborateurDTO;
} }
public ReferentDTO GetReferentDTO(Collaborateur referent) private ReferentDTO GetReferentDTO(Collaborateur referent)
{ {
if (referent == null) if (referent == null)
return null; return null;

@ -31,7 +31,6 @@ namespace EPAServeur
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
Console.WriteLine("SERVICES");
services.AddControllers(); services.AddControllers();
services.AddAuthentication(BearerAuthenticationHandler.SchemeName) services.AddAuthentication(BearerAuthenticationHandler.SchemeName)
.AddScheme<AuthenticationSchemeOptions, BearerAuthenticationHandler>(BearerAuthenticationHandler.SchemeName, null); .AddScheme<AuthenticationSchemeOptions, BearerAuthenticationHandler>(BearerAuthenticationHandler.SchemeName, null);

Loading…
Cancel
Save