예제 #1
0
        public ActionResult GetCustomers(int page, int pageItems)
        {
            List <Customer> sortedList = new List <Customer>();

            foreach (Customer c in Customers)
            {
                var cars = c.OwnedCars.OrderBy(x => x.Manufacteur)
                           .Skip(pageItems * page)
                           .Take(pageItems)
                           .ToList();

                sortedList.Add(new Customer
                {
                    Name      = c.Name,
                    OwnedCars = cars,
                });
            }

            //var customers = sortedList.Skip(SKIP * page).Take(SKIP).ToList();
            var customers = sortedList;

            var links = Hypermedia.MainMedia(Cars);

            return(Ok(new { Customers = customers, Links = links }));
        }
예제 #2
0
        public ActionResult <List <Car> > GetCars()
        {
            if (Cars == null)
            {
                return(NotFound("Nu exista nicio masina in lista"));
            }

            var links = Hypermedia.MainMedia(Cars);

            return(Ok(new { Cars = Cars, Links = links }));
        }