public void AddRecipe_AddsRecipeToRootLevelWithNewId_GivenNoParentAncestryPath() { //Arrange var title = "Completely new recipe"; var description = "Completely new description"; string parentAncestryPath = null; var expectedNode = new RecipeNode() { RecipeID = 12, AncestryPath = "12/" }; var expectedLogEntry = new RecipeLogEntry() { VersionID = 15, RecipeID = 12, Title = title, Description = description }; //Act var recipeId = _repo.AddRecipe(title, description, parentAncestryPath); var actualNode = _repo.GetRecipeNode(recipeId); var actualLogEntry = _repo.GetLatestLogEntryFor(recipeId); //Assert Assert.True(recipeId > 0); Assert.Equal(actualNode, expectedNode, new NodeEqualityComparer()); Assert.Equal(actualLogEntry, expectedLogEntry, new LogEntryEqualityComparer()); _fixture.ResetRepository(); }
public int AddRecipe(AddRecipeDto item) { int newRecipeId = _recipeRepository.AddRecipe(item); if (item.fatherRecipeId != 0) { _recipeRepository.AddChildrenRecipe(newRecipeId); } return(newRecipeId); }
public async Task <Int32> AddRecipe(RecipeDto recipe) { var recipeIdResult = await _recipesRepository.AddRecipe(new Recipe { Name = recipe.Name, Instructions = recipe.Instructions, UserId = recipe.UserId, }); await _recipesRepository.AddIngredients(recipe.Ingredients.Select(i => new Ingredient { Name = i.Name, Quantity = i.Quantity, RecipeId = recipeIdResult }).ToList()); return(recipeIdResult); }