|
|
|
|
using EPAServeur.Context;
|
|
|
|
|
using EPAServeur.IServices;
|
|
|
|
|
using EPAServeur.Models.Notes;
|
|
|
|
|
using IO.Swagger.DTO;
|
|
|
|
|
using IO.Swagger.ModelCollaborateur;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace EPAServeur.Services
|
|
|
|
|
{
|
|
|
|
|
public class NoteService : INoteService
|
|
|
|
|
{
|
|
|
|
|
private readonly CollaborateurService collaborateurService;
|
|
|
|
|
private readonly EpContext context;
|
|
|
|
|
|
|
|
|
|
public NoteService(CollaborateurService _collaborateurService, EpContext _context)
|
|
|
|
|
{
|
|
|
|
|
collaborateurService = _collaborateurService;
|
|
|
|
|
context = _context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool AjouterNote(DetailsNoteDTO nouvelleNote)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<AffichageNoteDTO> GetNotByCollaborateur(Guid? idAuteur, Guid? idCollaborateur)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DetailsNoteDTO GetNoteById(int? idNote)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<AffichageNoteDTO> GetNotes()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<AffichageNoteDTO> GetNotesByAuteur(Guid? idAuteur)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool SupprimerNote(int? idNote)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateNote(int? idNote, DetailsNoteDTO note)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Object to DTO
|
|
|
|
|
private AffichageNoteDTO NoteToAffichageDTO(Note note)
|
|
|
|
|
{
|
|
|
|
|
CollaborateurDTO collaborateur = collaborateurService.GetCollaborateurById(note.IdCollaborateur);
|
|
|
|
|
AffichageNoteDTO affichage = new AffichageNoteDTO()
|
|
|
|
|
{
|
|
|
|
|
Id = note.Id,
|
|
|
|
|
Collaborateur = collaborateur.Prenom + collaborateur.Nom,
|
|
|
|
|
Titre = note.Titre,
|
|
|
|
|
DateMiseAjour = note.DateUpdate
|
|
|
|
|
};
|
|
|
|
|
return affichage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DetailsNoteDTO NoteToDetailSDTO(Note note)
|
|
|
|
|
{
|
|
|
|
|
DetailsNoteDTO details = new DetailsNoteDTO()
|
|
|
|
|
{
|
|
|
|
|
Id = note.Id,
|
|
|
|
|
DateCreation = note.DateCreation,
|
|
|
|
|
DateMiseAjour = note.DateUpdate,
|
|
|
|
|
Titre = note.Titre,
|
|
|
|
|
Texte = note.Texte,
|
|
|
|
|
IdAuteur = note.IdAuteur,
|
|
|
|
|
Collaborateur = collaborateurService.GetCollaborateurById(note.IdCollaborateur)
|
|
|
|
|
};
|
|
|
|
|
return details;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//DTO to Object
|
|
|
|
|
private Note DetailsNoteDTOToNouvelleNote(DetailsNoteDTO detailsNoteDTO)
|
|
|
|
|
{
|
|
|
|
|
Note note = new Note()
|
|
|
|
|
{
|
|
|
|
|
IdAuteur = detailsNoteDTO.IdAuteur.Value,
|
|
|
|
|
IdCollaborateur = detailsNoteDTO.Collaborateur.Id.Value,
|
|
|
|
|
Texte = detailsNoteDTO.Texte,
|
|
|
|
|
Titre = detailsNoteDTO.Titre,
|
|
|
|
|
DateCreation = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
return note;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|