public IActionResult FindFilmsByPartialTitle(int from, int to, string titre) { ResponsePagine <List <FilmDTO> > responsePagine = new ResponsePagine <List <FilmDTO> >() { Status = StatusCodes.Status500InternalServerError, Errors = null, Message = null, Succeded = false, Value = null, FirstPage = null, From = from, To = to, LastPage = null, TotalRecord = -1, }; try { IQueryable <FilmDTO> queryFilm = _bllManager.FindFilmsByPartialTitle(from, to, titre); if (queryFilm == null) { responsePagine.Status = StatusCodes.Status404NotFound; responsePagine.Errors = "FindFilmsByPartialTitle(from=" + from + ", to=" + to + ", titre=" + titre + ") RETURN null"; } else { int nbrFilm = _bllManager.FindFilmsByPartialTitle(titre); if (nbrFilm != -1) { if (queryFilm.ToList().Count > 0) { responsePagine.Status = StatusCodes.Status200OK; responsePagine.Succeded = true; responsePagine.Value = queryFilm.ToList(); responsePagine.FirstPage = ApiRoute.Films.FilmBase + "/titre=" + titre + "/from=0/to=" + ((to - @from).ToString()); responsePagine.LastPage = ApiRoute.Films.FilmBase + "/titre=" + titre + "/from=" + (nbrFilm - (to - @from)).ToString() + "/to=" + nbrFilm; responsePagine.TotalRecord = nbrFilm; } else { responsePagine.Status = StatusCodes.Status404NotFound; responsePagine.Errors = "nombre de films trouvé dont le titre contient(" + titre + ") = 0"; } } else { responsePagine.Status = StatusCodes.Status404NotFound; responsePagine.Errors = "nombre de films trouvé dont le titre contient(" + titre + ") = -1"; } } } catch (Exception e) { responsePagine.Errors = "FindFilmsByPartialTitle(from=" + from + ", to=" + to + ", titre=" + titre + ") EXCEPTION : " + e.ToString(); } return(StatusCode(responsePagine.Status, responsePagine)); }
public void testFindFilmsByPartialTitle(int from, int to, string titre) { BllManager bllManager = new BllManager(); IQueryable <FilmDTO> testNull = bllManager.FindFilmsByPartialTitle(from, to, titre); Console.WriteLine("Liste des films dont le titre contient : " + titre); if (testNull != null) { List <FilmDTO> films = testNull.ToList(); int i = 1; Console.WriteLine("DEBUG nbr films = " + films.Count); foreach (FilmDTO film in films) { Console.WriteLine("[" + i + "]\n" + film.ToStringAll()); i++; } } }
public void testFindNumberFilmsByPartialTitle(string titre) { BllManager bllManager = new BllManager(); Console.WriteLine("Nombre de films dont le titre contient(" + titre + ") = " + bllManager.FindFilmsByPartialTitle(titre)); }