// GET: Ingredients public async Task <IActionResult> Index(string ingredientTypeSearch, string searchString) { // Use LINQ to get list of types. IQueryable <IngredientType> ingredientQuery = from m in _context.Ingredient orderby m.type select m.type; var ingredients = from m in _context.Ingredient select m; if (!string.IsNullOrEmpty(searchString)) { ingredients = ingredients.Where(s => s.name.Contains(searchString)); } if (!string.IsNullOrEmpty(ingredientTypeSearch)) { IngredientType ingredientType = strToIngredientType(ingredientTypeSearch); Debug.WriteLine("ingredientType = ", ingredientType); ingredients = ingredients.Where(x => x.type == ingredientType); } var ingredientTypeVM = new IngredientTypeViewModel { types = new SelectList(await ingredientQuery.Distinct().ToListAsync()), Ingredients = await ingredients.ToListAsync() }; return(View(ingredientTypeVM)); }
// GET: IngredientTypes/Create public ActionResult Create() { IngredientTypeViewModel ingredientTypeViewModel = new IngredientTypeViewModel(); ingredientTypeViewModel.CrepeTypes = db.CrepeTypes.ToList(); return(View(ingredientTypeViewModel)); }
private void countChild(IngredientTypeViewModel obj, int count) { obj.CountChild = count; }