Example #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));
        }
Example #2
0
        public void testGetActorsFromTo(int from, int to)
        {
            BllManager      bllManager = new BllManager();
            List <ActorDTO> actors     = bllManager.getActorsFromTo(from, to).ToList();

            Console.WriteLine("Acteurs de " + from + " a " + to + " :");
            int i = 1;

            foreach (ActorDTO actor in actors)
            {
                Console.WriteLine("Acteurs [" + i + "]" + " : " + actor.ToStringWithFilms());
                i++;
            }
            Console.WriteLine("Acteurs de : " + "Acteurs de " + from + " a " + to);

            Assert.Pass();
        }
Example #3
0
        public void testGetNumberActorsFromTo()
        {
            BllManager bllManager = new BllManager();

            Console.WriteLine("nombre d'acteurs dans la bd = " + bllManager.getActorsFromTo());
        }