public void GetRootShouldBeNotNull() { var rootId = _recipeRepository.GetAllRecipes()[0].Id; var root = _recipeRepository.GetRoot(x => x.Id.Equals((rootId))); root.ParentId.Should().BeNull(); root.Should().NotBeNull(); root.Id.Should().Equals(rootId); }
public IActionResult OnPost() { var selectedIngredients = Request.Form["selectedIngredients"].ToList(); //laver nye ingredients i Recipes fra de valgte values i selectlisten selectedIngredients.ForEach(i => Recipe.Ingredients.Add(new Ingredient { Id = int.Parse(i) })); if (ModelState.IsValid) { int newId = rr.NewRecipe(Recipe); return(RedirectToPage("/Recipes/edit", new { id = newId })); } Ingredients = new SelectList(ir.GetAllIngredients(), "Id", "Name"); Recipes = rr.GetAllRecipes(); return(Page()); }
public void OnGet() { FilterType = FilterType.ToLower(); if (FilterType != "all") { Recipes = recipeRepository.GetAllRecipesWithIngredients(); if (FilterType == "nonvegan") { Recipes.RemoveAll(x => x.IsVegetarian); } else if (FilterType == "vegan") { Recipes.RemoveAll(x => !x.IsVegetarian); } return; } Recipes = recipeRepository.GetAllRecipes(); }
public void Get_recipes_should_work() { //Arrange //For each Profile, include that profile in the MapperConfiguration var config = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperRepositoryProfile()); }); //Create a mapper that will be used by the DI container var mapper = config.CreateMapper(); var repo = new RecipeRepository(mapper); //Act var recipes = repo.GetAllRecipes().ToList(); //Assert Assert.IsNotNull(recipes); Assert.IsNotNull(recipes.FirstOrDefault().Ingredients); Assert.IsNotNull(recipes.FirstOrDefault().Ingredients.FirstOrDefault()); }
public IActionResult Recipe() { return(View(_recipeRepository.GetAllRecipes())); }
// GET: Recipe/GetAllRecipes public ActionResult GetAllRecipes() { ModelState.Clear(); return(View(_repo.GetAllRecipes())); }
public void OnGet() { Recipes = recipeRepository.GetAllRecipes(); }