public ActionResult GetRecipeByCategory(int catID) { RecipesVM recipes = new RecipesVM(); recipes.Recipes = rr.GetRecipesByCategory(catID); return(PartialView("RecipeEditDelete", recipes)); }
public ActionResult RecipeCategories() { RecipesVM recipes = new RecipesVM(); recipes.RecipeCategories = rr.GetAllRecipeCategoriesList(); return(View(recipes)); }
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)); }
public Recipes() { InitializeComponent(); try { (this.ApplicationBar.Buttons[0] as ApplicationBarIconButton).Text = AppResources.Add; DataContext = new RecipesVM(); } catch (Exception ex) { LittleWatson.ReportException(ex); } }
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)); }