public ActionResult Index() { var repo = new CountingKsRepository(new CountingKsContext()); var results = repo.GetAllFoodsWithMeasures().Take(25).ToList(); return View(results); }
public ActionResult Index() { var repo = new CountingKsRepository(new CountingKsContext()); var results = repo.GetAllFoodsWithMeasures().Take(25).ToList(); return(View(results)); }
public HttpResponseMessage Get(bool includeMeasures = true, int pageIndex = 0, int pageSize = 0) { IQueryable <Food> query; if (pageIndex < 0) { pageIndex = 0; } if (pageSize <= 0) { pageSize = PAGE_SIZE_DEFAULT; } if (includeMeasures) { query = CountingKsRepository.GetAllFoodsWithMeasures(); } else { query = CountingKsRepository.GetAllFoods(); } query = query.OrderBy(x => x.Description); var totalRows = query.Count(); var result = query .Skip(pageIndex * pageSize) .Take(pageSize) .ToList() .Select(f => ModelFactory.Create(f)); var pagedResult = ModelFactory.CreatePagedResult(includeMeasures, pageIndex, pageSize, totalRows, result, Request); return(Request.CreateResponse(HttpStatusCode.OK, pagedResult)); }