public IActionResult GetCommentsFromTo(int from, int to) { ResponsePagine <List <CommentDTO> > responsePagine = new ResponsePagine <List <CommentDTO> >() { Status = StatusCodes.Status500InternalServerError, Errors = null, Message = null, Succeded = false, Value = null, FirstPage = null, From = from, To = to, LastPage = null, TotalRecord = -1, }; try { IQueryable <CommentDTO> queryComments = _bllManager.getCommentsFromTo(from, to); if (queryComments == null) { responsePagine.Status = StatusCodes.Status404NotFound; responsePagine.Errors = "GetCommentsFromTo(from=" + from + ", to=" + to + ") RETURN null"; } else { int nbrActor = _bllManager.getActorsFromTo(); if (nbrActor != -1) { if (queryComments.ToList().Count > 0) { responsePagine.Status = StatusCodes.Status200OK; responsePagine.Succeded = true; responsePagine.Value = queryComments.ToList(); responsePagine.FirstPage = ApiRoute.Actors.ActorBase + "/from=0/to=" + ((to - @from).ToString()); responsePagine.LastPage = ApiRoute.Actors.ActorBase + "/from=" + (nbrActor - (to - @from)).ToString() + "/to=" + nbrActor; responsePagine.TotalRecord = nbrActor; } else { responsePagine.Status = StatusCodes.Status404NotFound; responsePagine.Errors = "nombre de comments trouvé = 0"; } } else { responsePagine.Status = StatusCodes.Status404NotFound; responsePagine.Errors = "nombre de comments trouvé = -1"; } } } catch (Exception e) { responsePagine.Errors = "GetCommentsFromTo(from=" + from + ", to=" + to + ") EXCEPTION : " + e.ToString(); } return(StatusCode(responsePagine.Status, responsePagine)); }
public void testGetCommentsFromTo(int from, int to) { BllManager bllManager = new BllManager(); List <CommentDTO> comments = bllManager.getCommentsFromTo(from, to).ToList(); Console.WriteLine("Comments de " + from + " a " + to + " :"); int i = 1; foreach (CommentDTO comment in comments) { Console.WriteLine("Comments [" + i + "]" + " : " + comment.ToStringWithFilm()); i++; } Console.WriteLine("Comments de : " + "Comments de " + from + " a " + to); Assert.Pass(); }
public void testGetNumberCommentsFromTo() { BllManager bllManager = new BllManager(); Console.WriteLine("nombre de comments dans la bd = " + bllManager.getCommentsFromTo()); }