Пример #1
0
        private void BindingFood(object sender, RoutedEventArgs e)
        {
            if (MainWindow.boolSearch == 0)
            {
                recipes   = RecipeDAO.getAllRecipesFromJson();
                totalItem = recipes.Count();

                int floor = totalItem / itemPerPage;
                totalPage = (totalItem % itemPerPage == 0) ? floor : (floor + 1);

                //MessageBox.Show(totalItem.ToString());

                if (recipes != null)
                {
                    DataListview.ItemsSource = getNextPageItems();
                }
                pageInfo.Text = $"{currentPage}/{totalPage}";
            }
            else
            {
                recipes   = RecipeDAO.SearchRecipe(MainWindow.dataSearch);
                totalItem = recipes.Count();

                int floor = totalItem / itemPerPage;
                totalPage = (totalItem % itemPerPage == 0) ? floor : (floor + 1);

                //MessageBox.Show(totalItem.ToString());

                if (recipes != null)
                {
                    DataListview.ItemsSource = getNextPageItems();
                }
                pageInfo.Text = $"{currentPage}/{totalPage}";
            }
        }
Пример #2
0
        public static List <Recipe> SearchRecipe(string searchName)
        {
            List <Recipe> recipes = RecipeDAO.getAllRecipesFromJson();
            var           query   = from c in recipes
                                    where c.Name.ToLower().Contains(searchName)
                                    select c;

            return(query.ToList());
        }