예제 #1
0
        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);
        }
예제 #2
0
        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());
        }
예제 #3
0
        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();
        }
예제 #4
0
        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());
        }
예제 #5
0
 public IActionResult Recipe()
 {
     return(View(_recipeRepository.GetAllRecipes()));
 }
예제 #6
0
 // GET: Recipe/GetAllRecipes
 public ActionResult GetAllRecipes()
 {
     ModelState.Clear();
     return(View(_repo.GetAllRecipes()));
 }
예제 #7
0
 public void OnGet()
 {
     Recipes = recipeRepository.GetAllRecipes();
 }