public IActionResult GetCommentFromId(int id) { ResponseSingleObject <CommentDTO> responseSingleObject = new ResponseSingleObject <CommentDTO>() { Status = StatusCodes.Status500InternalServerError, Errors = null, Message = null, Succeded = false, Value = null }; try { CommentDTO commentDto = _bllManager.getCommentFromId(id); if (commentDto == null) { responseSingleObject.Status = StatusCodes.Status404NotFound; responseSingleObject.Errors = "aucun comment trouvé"; } else { responseSingleObject.Status = StatusCodes.Status200OK; responseSingleObject.Value = commentDto; } } catch (Exception e) { responseSingleObject.Errors = "GetNumberCommentsFromTo() EXCEPTION : " + e.ToString(); } return(StatusCode(responseSingleObject.Status, responseSingleObject)); }
public void testInsertComment() { Console.WriteLine("insert comment..."); _bllManager.InsertComment(_comment); Console.WriteLine("insert comment ok : affichage à partir de la lecture de la bd :"); FullFilmDTO film = _bllManager.GetFullFilmDetailsByIdFilm(_comment.Film.Id); int idComment = 0; foreach (CommentDTO filmComment in film.Comments) { idComment = filmComment.Id; } Console.WriteLine("Film : \n" + film.ToStringAll()); _comment = _bllManager.getCommentFromId(idComment); Console.WriteLine("Comment : \n" + _comment.ToStringWithFilm()); Assert.Pass(); }