ajout de la methode getNotePadByIdUserAndIdInquiry
continuous-integration/drone/push Build is passing Details

notePad
Victor GABORIT 1 year ago
parent 79f898cd47
commit a1ea2de7bb

@ -24,7 +24,23 @@ public class NotepadController(ILogger<NotepadController> logger, INotePadServic
}
catch (ArgumentException)
{
logger.LogError("[ERREUR] Aucun bloc n'a été trouvé pour l'id {id}", id);
logger.LogError("[ERREUR] Aucun bloc n'a été trouvé pour l'id {id}.", id);
return NotFound();
}
}
[HttpGet("notePad/{idUser:int}/{idInquiry:int}")]
[ProducesResponseType(typeof(UserDto), 200)]
[ProducesResponseType(typeof(string), 404)]
public IActionResult GetNotePadByIdInquiryAndIdUser(int idUser, int idInquiry)
{
try
{
logger.LogInformation(" [INFORMATION] Le bloc note a été trouvé.");
return Ok(notePadService.GetNotePadByIdUserAndIdInquiry(idUser, idInquiry));
}
catch (ArgumentException)
{
logger.LogError("[ERREUR] Aucun bloc n'a été trouvé.");
return NotFound();
}
}

@ -8,4 +8,7 @@ namespace API.Service;
public class NotePadDataServiceApi(INotePadService<NotepadEntity> notePadService) : INotePadService<NotepadDto>
{
public NotepadDto GetNotePadById(int id) => notePadService.GetNotePadById(id).FromEntityToDto();
public NotepadDto GetNotePadByIdUserAndIdInquiry(int idUser, int idInquiry) =>
notePadService.GetNotePadByIdUserAndIdInquiry(idUser, idInquiry).FromEntityToDto();
}

@ -23,4 +23,15 @@ public class NotePadDataService : INotePadService<NotepadEntity>
}
return notePadEntity;
}
public NotepadEntity GetNotePadByIdUserAndIdInquiry(int idUser, int idInquiry)
{
var notPadEntity = DbContext.Notepads.FirstOrDefault(n => n.InquiryId == idInquiry && n.UserId == idUser);
if (notPadEntity == null)
{
throw new ArgumentException("impossible de trouver le bloc note", nameof(idInquiry));
}
return notPadEntity;
}
}

@ -3,5 +3,6 @@ namespace Shared;
public interface INotePadService<TNotePad>
{
public TNotePad GetNotePadById(int id);
public TNotePad GetNotePadByIdUserAndIdInquiry(int idUser, int idInquiry);
}
Loading…
Cancel
Save