public IEnumerable <MeasureV2Model> Get(int foodid) { var results = TheRepository.GetMeasuresForFood(foodid) .ToList() .Select(m => TheModelFactory.Create2(m)); return(results); }
public MeasureV2Model Get(int foodid, int id) { var res = TheRepository.GetMeasure(id); if (res.Food.Id == foodid) { return(TheModelFactory.Create2(res)); } return(null); }
public MeasureV2Model Get(int foodid, int id) { Measure measure = TheRepository.GetMeasure(id); if (measure.Food.Id == foodid) { return(TheModelFactory.Create2(measure)); } return(null); }
public HttpResponseMessage Get(int foodid, int id) { var results = TheCountingKsRepository.GetMeasure(id); if (results == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Measure Not Found.")); } if (results.Food.Id == foodid) { return(Request.CreateResponse(HttpStatusCode.Found, TheModelFactory.Create2(results))); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Measure Not Found For Food.")); } }
public object Get(bool includeTags = true, int page = 0) { IQueryable <Book> query; if (includeTags) { query = TheRepository.GetAllBooksWithTags(); } else { query = TheRepository.GetAllBooks(); } var baseQuery = query.OrderBy(f => f.Title); var totalCount = baseQuery.Count(); var totalPages = Math.Ceiling((double)totalCount / PAGE_SIZE); var helper = new UrlHelper(Request); var prevUrl = page > 0 ? helper.Link("Book", new { page = page - 1 }): ""; var nextUrl = page < totalPages - 1 ? helper.Link("Book", new { page = page + 1 }): ""; var results = baseQuery.Skip(PAGE_SIZE * page) .Take(PAGE_SIZE) .ToList() .Select(f => (BookWithTagsV2Model)TheModelFactory.Create2(f)); return(new { TotalCount = totalCount, TotalPages = totalPages, PrevPageUrl = prevUrl, NextPageUrl = nextUrl, Results = results }); }
public BookWithTagsV2Model Get(int bookid) { return((BookWithTagsV2Model)TheModelFactory.Create2(TheRepository.GetBook(bookid))); }