Ejemplo n.º 1
0
        public IActionResult getActorsFromTo(int from, int to)
        {
            ResponsePagine <List <ActorDTO> > responsePagine = new ResponsePagine <List <ActorDTO> >()
            {
                Status      = StatusCodes.Status500InternalServerError,
                Errors      = null,
                Message     = null,
                Succeded    = false,
                Value       = null,
                FirstPage   = null,
                From        = from,
                To          = to,
                LastPage    = null,
                TotalRecord = -1,
            };

            try
            {
                IQueryable <ActorDTO> queryActors = _bllManager.getActorsFromTo(from, to);
                if (queryActors == null)
                {
                    responsePagine.Status = StatusCodes.Status404NotFound;
                    responsePagine.Errors = "getActorsFromTo(from=" + from + ", to=" + to + ") RETURN null";
                }
                else
                {
                    int nbrActor = _bllManager.getActorsFromTo();
                    if (nbrActor != -1)
                    {
                        if (queryActors.ToList().Count > 0)
                        {
                            responsePagine.Status    = StatusCodes.Status200OK;
                            responsePagine.Succeded  = true;
                            responsePagine.Value     = queryActors.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 d'actor trouvé = 0";
                        }
                    }
                    else
                    {
                        responsePagine.Status = StatusCodes.Status404NotFound;
                        responsePagine.Errors = "nombre d'actor trouvé = -1";
                    }
                }
            }
            catch (Exception e)
            {
                responsePagine.Errors =
                    "getActorsFromTo(from=" + from + ", to=" + to + ") EXCEPTION : " + e.ToString();
            }

            return(StatusCode(responsePagine.Status, responsePagine));
        }
Ejemplo n.º 2
0
        public IActionResult FindListFilmByPartialActorName(int from, int to, string nomActeur)
        {
            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.FindListFilmByPartialActorName(from, to, nomActeur);
                if (queryFilm == null)
                {
                    responsePagine.Status = StatusCodes.Status404NotFound;
                    responsePagine.Errors = "FindListFilmByPartialActorName(from=" + from + ", to=" + to + ", nom auteur=" + nomActeur + ") RETURN null";
                }
                else
                {
                    int nbrFilm = _bllManager.FindListFilmByPartialActorName(nomActeur);
                    if (nbrFilm != -1)
                    {
                        if (queryFilm.ToList().Count > 0)
                        {
                            responsePagine.Status    = StatusCodes.Status200OK;
                            responsePagine.Succeded  = true;
                            responsePagine.Value     = queryFilm.ToList();
                            responsePagine.FirstPage = ApiRoute.Films.FilmBase + "/nomacteur=" + nomActeur + "/from=0/to=" + ((to - @from).ToString());
                            responsePagine.LastPage  = ApiRoute.Films.FilmBase + "/nomacteur=" + nomActeur + "/from=" +
                                                       (nbrFilm - (to - @from)).ToString() + "/to=" + nbrFilm;
                            responsePagine.TotalRecord = nbrFilm;
                        }
                        else
                        {
                            responsePagine.Status = StatusCodes.Status404NotFound;
                            responsePagine.Errors = "nombre de films trouvé pour l'acteur dont le nom contient(" + nomActeur + ") = 0";
                        }
                    }
                    else
                    {
                        responsePagine.Status = StatusCodes.Status404NotFound;
                        responsePagine.Errors = "nombre de films trouvé pour l'acteur dont le nom contient(" + nomActeur + ") = -1";
                    }
                }
            }
            catch (Exception e)
            {
                responsePagine.Errors =
                    "FindListFilmByPartialActorName(from=" + from + ", to=" + to + ", nom auteur=" + nomActeur + ") EXCEPTION : " + e.ToString();
            }

            return(StatusCode(responsePagine.Status, responsePagine));
        }