public IQueryable <Category> GetCategories() { var _db = new Foodie.Models.FoodContext(); IQueryable <Category> query = _db.Categories; return(query); }
public IQueryable <Food> GetFoods([QueryString("id")] int?categoryId) { var _db = new Foodie.Models.FoodContext(); IQueryable <Food> query = _db.Foods; if (categoryId.HasValue && categoryId > 0) { query = query.Where(f => f.CategoryID == categoryId); } return(query); }
public IQueryable <Food> GetFood([QueryString("foodID")] int?foodId) { var _db = new Foodie.Models.FoodContext(); IQueryable <Food> query = _db.Foods; if (foodId.HasValue && foodId > 0) { query = query.Where(f => f.FoodID == foodId); } else { query = null; } return(query); }