コード例 #1
0
        public ActionResult GetRecipeByCategory(int catID)
        {
            RecipesVM recipes = new RecipesVM();

            recipes.Recipes = rr.GetRecipesByCategory(catID);
            return(PartialView("RecipeEditDelete", recipes));
        }
コード例 #2
0
        public ActionResult RecipeCategories()
        {
            RecipesVM recipes = new RecipesVM();

            recipes.RecipeCategories = rr.GetAllRecipeCategoriesList();
            return(View(recipes));
        }
コード例 #3
0
        public ActionResult Index(int pageNumber = 1)
        {
            var recipesList = _recipeRepository.GetPaged(5, pageNumber);
            var vm          = new RecipesVM()
            {
                Recipes      = recipesList.Payload,
                TotalRecipes = recipesList.TotalItems,
                PagesToShow  = recipesList.TotalPages
            };

            return(View(vm));
        }
コード例 #4
0
ファイル: Recipes.xaml.cs プロジェクト: RemSoftDev/Wouter
        public Recipes()
        {
            InitializeComponent();

            try
            {
                (this.ApplicationBar.Buttons[0] as ApplicationBarIconButton).Text = AppResources.Add;

                DataContext = new RecipesVM();
            }
            catch (Exception ex) { LittleWatson.ReportException(ex); }
        }
コード例 #5
0
        public ActionResult Search(string searchTerm, int skip = 0, int take = 5)
        {
            if (string.IsNullOrEmpty(searchTerm))
            {
                return(RedirectToAction("Index"));
            }
            ViewBag.Message = "Search Page.";

            var recipes = _recipeRepository.GetQueryable();

            var recipeList = new List <Recipe>();

            if (!String.IsNullOrEmpty(searchTerm))
            {
                recipeList.AddRange(recipes.Where(s => s.Name.Contains(searchTerm)).ToList());
                recipeList.AddRange(recipes.Where(s => s.MealType.ToString().Equals(searchTerm.ToLower())).ToList());
                recipeList.AddRange(recipes.Where(r => r.Ingredients.Any(i => i.Name.Contains(searchTerm))));
                recipeList.AddRange(recipes.Where(s => s.WeightWatchersPoints.ToString() == searchTerm).ToList());
                recipeList.AddRange(recipes.Where(s => s.HealthyRating.ToString().Equals(searchTerm.ToLower())).ToList());
            }
            else
            {
                recipeList = recipes.ToList();
            }

            var recipesList = recipeList.Distinct().ToList().Skip(skip).Take(take);

            var vm = new RecipesVM()
            {
                Recipes      = recipesList,
                TotalRecipes = recipesList.Count(),
                PagesToShow  = (int)Math.Ceiling((float)recipesList.Count() / 5)
            };

            return(View(vm));
        }