示例#1
0
        public IActionResult GetFavoriteActors(int from, int to)
        {
            ResponsePagine <List <LightActorDTO> > responsePagine = new ResponsePagine <List <LightActorDTO> >()
            {
                Status      = StatusCodes.Status500InternalServerError,
                Errors      = null,
                Message     = null,
                Succeded    = false,
                Value       = null,
                FirstPage   = null,
                From        = from,
                To          = to,
                LastPage    = null,
                TotalRecord = -1,
            };

            try
            {
                IQueryable <LightActorDTO> queryActors = _bllManager.GetFavoriteActors(from, to);
                if (queryActors == null)
                {
                    responsePagine.Status = StatusCodes.Status404NotFound;
                    responsePagine.Errors = "GetFavoriteActors(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 + "/favorite/from=0/to=" + ((to - @from).ToString());
                            responsePagine.LastPage  = ApiRoute.Actors.ActorBase + "/favorite/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 =
                    "GetFavoriteActors(from=" + from + ", to=" + to + ") EXCEPTION : " + e.ToString();
            }

            return(StatusCode(responsePagine.Status, responsePagine));
        }
示例#2
0
        public void TestGetFavoriteActors(int from, int to)
        {
            BllManager           bllManager = new BllManager();
            List <LightActorDTO> actors     = bllManager.GetFavoriteActors(from, to).ToList();

            Console.WriteLine("Acteur qui joue dans 2 films ou plus : de " + from + ", to " + to);
            int i = 1;

            foreach (LightActorDTO actor in actors)
            {
                Console.WriteLine("[" + i + "]" + actor);
                i++;
            }

            Assert.Pass();
        }
示例#3
0
        public void testGetNumberFavoriteActor()
        {
            BllManager bllManager = new BllManager();

            Console.WriteLine("nombre d'acteur qui jouent dans au moins 2 films : " + bllManager.GetFavoriteActors());
        }