public void AssignCookingInstructionToRecipe_RecipeFoundInstructionNotFound_ReturnsFalse() { var recipe = new Recipe() { Name = "Fried Chicken" }; //add the recipe to the database var recipeRepository = new RecipeRepository(Context); recipeRepository.Add(recipe); var foundRecipe = recipeRepository.GetAll().ToList(); //there should only be one added record in the database Assert.AreEqual(1, foundRecipe.Count()); //add a cooking instruction where recipe is found and the cooking instruction is not if (foundRecipe != null) { var added = cookingInstructionRepository.AssignCookingInstructionsToRecipe(foundRecipe[0].RecipeId, 456456); //should return false Assert.IsFalse(added); } }
private void buttonOk_Click(object sender, EventArgs e) { _updatedRecipe = new Recipe { RecipeId = _recipe.RecipeId, Title = textBoxTitle.Text, Description = textBoxDesc.Text, Ingredients = textBoxIng.Text, CategoryId = _categoryId }; try { if (_isUpdate) { repository.Update(_updatedRecipe); } else { repository.Add(_updatedRecipe); } MessageBox.Show("Recipe saved!"); } catch (Exception) { MessageBox.Show("Recipe could not save!"); } Close(); }
public void Post([FromBody] Recipe Recipe) { if (ModelState.IsValid) { RecipeRepository.Add(Recipe); } }
public async Task <string> AddIngredient(string ingredient) { RecipeRepository repo = new RecipeRepository(_config, _loggerFactory); var response = await repo.Add(ingredient); return(response); }
public async Task <IngredientDB> AddIngredients(IngredientDB ingredients) { RecipeRepository repo = new RecipeRepository(_config, _loggerFactory); var response = await repo.Add(ingredients); return(response); }
//Repository public async Task <RecipeModel> AddRecipe(RecipeModel recipe) { RecipeRepository repo = new RecipeRepository(_config, _loggerFactory); var response = await repo.Add(recipe); return(response); }
public Recipe BuildRecipe(string key) { Recipe r = new Recipe(key, "Pancakes", "Wonderful"); RegisterInstance(r); RecipeRepository.Add(r); return(r); }
public void Post([FromBody] Recipe rcp) { ValidateCookbookSectionIds(rcp, sectionRepository.GetByCookbookId(rcp.CookbookId)); if (ModelState.IsValid) { recipeRepository.Add(rcp); } }
private void button1_Click(object sender, EventArgs e) { var repository = new RecipeRepository(); repository.Add(new Recipe { Title = textBox1.Text, Description = textBox2.Text }); Close(); }
protected void BuildBonneMos() { Recipe r = new Recipe("bonnemos", "Bønnemos", @"Svits løg og chili. Hæl bønnerne i og mos det hele."); r.AddIngredient(400, "g", "Sorte bønner"); r.AddIngredient(2, "stk", "Løg"); r.AddIngredient(4, "stk", "Chili"); RecipeRepository.Add(r); BonneMosRecipe = r; }
public void AddRecipe() { //create the new recipe var recipe = new Recipe() { Name = "Butter Chicken" }; //Add to the database recipeRepository.Add(recipe); //retrieve using the find method var foundRecipe = recipeRepository.Find(recipe => recipe.Name == recipe.Name) .FirstOrDefault(); //found it if (foundRecipe != null) { Assert.AreEqual(recipe.Name, foundRecipe.Name); } }
public IActionResult AddConfirmation(IFormCollection formCollection) { if (String.IsNullOrEmpty(formCollection["recipename"])) { return(View("Error")); } var recipe = new Recipe() { Name = formCollection["recipename"] }; recipeRepository.Add(recipe); return(View(recipe)); }
/// <summary> /// Method to add a recipe /// </summary> /// <param name="recipe">The recipe to be added</param> /// <returns>True if it was added</returns> public async Task <bool> AddRecipeAsync(RecipeDTO recipe) { var isAdded = true; try { var recipeToBeAdded = CreateRecipeEntity(recipe); await Task.Run(() => recipeRepository.Add(recipeToBeAdded)); } catch (Exception ex) { isAdded = false; // TODO:Add logging } return(isAdded); }
public void AddSingle_Test() { // Arrange - Create the repository var repository = new RecipeRepository(_context); // Arrange - Create the new recipe var sampleData = new SampleContext(); var expected = new Recipe { Name = "New Recipe One", Description = "Test New Description One", Category = (Category)sampleData.Categories.GetRandomEntity() }; expected.Steps.Add(new Step { Description = "New Step One", SortOrder = 1 }); expected.Steps.Add(new Step { Description = "New Step Two", SortOrder = 2 }); expected.Ingredients.Add(new Ingredient { Unit = 1, Measurement = (Measurement)sampleData.Measurements.GetRandomEntity(), Product = (Product)sampleData.Products.GetRandomEntity(), SortOrder = 1 }); expected.Ingredients.Add(new Ingredient { Unit = 2, Measurement = (Measurement)sampleData.Measurements.GetRandomEntity(), Product = (Product)sampleData.Products.GetRandomEntity(), SortOrder = 2 }); // Arrange - Set the expected count var expectedRecipeCount = repository.GetAll().Count() + 1; // Act - Perform the repository call repository.Add(expected); _context.SaveChanges(); // Assert - Check for the addition Assert.AreEqual(expectedRecipeCount, repository.GetAll().Count()); // Verify the entity (gets by name as this should be unique in this test) repository.FullEagerLoad(); var actual = repository.GetAll().SingleOrDefault(i => i.Name == expected.Name); Assert.IsNotNull(actual); CompareEntities(expected, actual); }
protected void BuildMexicanskeBurritos() { Recipe r = new Recipe("mexicanske-burritos", "Mexicanske burritos", @"Snit salat, skær tomat i både og løg og agurk i tern. Åben for dåsen med majs. Tænd ovnen på 180º C varmluft/200º C alm. ovn. Svits kødet i en gryde. Tilsæt krydderi og vand, og lad det simre ca. 5 min. Fyld de mexicanske wraps med kødet. Rul dem sammen, og læg dem i et ildfast fad. Drys osten udover. Gratineres i ovnen i ca. 10 minutter. Serverer de varme wraps med salat, creme fraiche og salsa til."); r.AddIngredient(0.5f, "stk", "Hovedsalat"); r.AddIngredient(200, "g", "Cherry tomater"); r.AddIngredient(1, "stk", "Rødløg"); r.AddIngredient(1, "stk", "Agurk"); r.AddIngredient(1, "ds", "Majs på dåse"); RecipeRepository.Add(r); MexicanskeBurritosRecipe = r; }
public IActionResult Recipe(Recipe recipe) { _recipeRepository.Add(recipe); return(CreatedAtAction("Get", new { id = recipe.Id }, recipe)); }
public static async Task EnsurePopulated(IApplicationBuilder app) { ApplicationDbContext context = app.ApplicationServices .GetRequiredService <ApplicationDbContext>(); context.Database.Migrate(); if (!context.Recipes.Any()) { ProductRepository productRepository = new ProductRepository(context); CategoryRepository categoryRepository = new CategoryRepository(context); RecipeRepository recipeRepository = new RecipeRepository(context); IngredientRepository ingredientRepository = new IngredientRepository(context); TypeRepository typeRepository = new TypeRepository(context); Type breakfast = new Type { Name = "Śniadanie" }; Type dinner = new Type { Name = "Obiad" }; Type supper = new Type { Name = "Kolacja" }; typeRepository.Add(supper); typeRepository.Add(dinner); typeRepository.Add(breakfast); Category dairyProduct = new Category { Name = "Nabiał" }; Category fruit = new Category { Name = "Owoc" };; Category wheatProduct = new Category { Name = "Produkt pszenny" }; Category meat = new Category { Name = "Mięso" }; Category vegetable = new Category { Name = "Warzywo" }; Category spices = new Category { Name = "Przyprawy" }; categoryRepository.Add(dairyProduct); categoryRepository.Add(vegetable); categoryRepository.Add(fruit); categoryRepository.Add(wheatProduct); categoryRepository.Add(meat); categoryRepository.Add(spices); Product eggs = new Product { Name = "Jajka", Measure = "szt.", Category = dairyProduct }; Product apple = new Product { Name = "Jabłko", Measure = "szt.", Category = fruit }; Product pasta = new Product { Name = "Makaron", Measure = "g", Category = wheatProduct }; Product chicken = new Product { Name = "Pierś z kurczaka", Measure = "g", Category = meat }; Product mushrooms = new Product { Name = "Pieczarki", Measure = "g", Category = vegetable }; Product sourCream = new Product { Name = "Śmietana", Measure = "ml", Category = dairyProduct }; Product carrot = new Product { Name = "Marchew", Measure = "szt.", Category = vegetable }; Product milk = new Product { Name = "Mleko", Measure = "ml", Category = dairyProduct }; Product flour = new Product { Name = "Mąka", Measure = "g", Category = wheatProduct }; Product sugar = new Product { Name = "Cukier", Measure = "g", Category = spices }; Product bread = new Product { Name = "Chleb", Measure = "szt.", Category = wheatProduct }; Product ham = new Product { Name = "Szynka", Measure = "szt.", Category = meat }; Product oatmealFlakes = new Product { Name = "Płatki owsiane", Measure = "g", Category = wheatProduct }; Product butter = new Product { Name = "Masło", Measure = "g", Category = dairyProduct }; Product banana = new Product { Name = "Banan", Measure = "szt.", Category = fruit }; Product rice = new Product { Name = "Ryż", Measure = "g", Category = wheatProduct }; Product spinach = new Product { Name = "Szpinak", Measure = "g", Category = vegetable }; Product broccoli = new Product { Name = "Brokuł", Measure = "g", Category = vegetable }; productRepository.Add(eggs); productRepository.Add(apple); productRepository.Add(pasta); productRepository.Add(chicken); productRepository.Add(mushrooms); productRepository.Add(sourCream); productRepository.Add(carrot); productRepository.Add(milk); productRepository.Add(flour); productRepository.Add(sugar); productRepository.Add(bread); productRepository.Add(ham); productRepository.Add(oatmealFlakes); productRepository.Add(butter); productRepository.Add(banana); Recipe pastaWithChicken = new Recipe { Name = "Makaron z kurczakiem i pieczarkami", Type = dinner, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 30, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\kurczak_pieczarki.jpg")) }; Recipe breadWithHam = new Recipe { Name = "Kanapka z szynką", Type = breakfast, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 10, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\kanapka_szynka.jpg")) }; Recipe pancakes = new Recipe { Name = "Naleśniki", Type = dinner, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 20, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\nalesniki.jpg")) }; Recipe porridge = new Recipe { Name = "Owsianka", Type = breakfast, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 15, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\owsianka.jpg")) }; Recipe omelette = new Recipe { Name = "Omlet", Type = breakfast, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 15, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\omlet.jpg")) }; Recipe scrambledEggs = new Recipe { Name = "Jajecznica", Type = breakfast, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 15, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\jajecznica.jpg")) }; Recipe riceWithChickenAndSpinach = new Recipe { Name = "Kurczak z ryżem i szpinakiem", Type = breakfast, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 45, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\kurczakRyżSzpinak.jpg")) }; Recipe riceWithChickenCarrotBroccoli = new Recipe { Name = "Kurczak z ryżem, marchewką i brokułem", Type = breakfast, Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at mattis dui. Duis vitae rhoncus lacus. Duis luctus eleifend dolor, ut facilisis magna vehicula ac. Vestibulum nec suscipit magna, et gravida sem. Quisque quis malesuada felis, in luctus tortor. Aenean pulvinar id turpis vel volutpat. Nullam libero urna, ultrices a mollis sit amet, ultricies at erat. Mauris nec pharetra neque. Praesent ipsum turpis, dictum vitae massa pulvinar, eleifend rhoncus tellus. Sed interdum elementum rhoncus. Sed ac nisl varius, faucibus sem eget, tempus risus. Maecenas eu leo eu massa consectetur venenatis nec sed lorem.", Time = 45, Img = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, @"wwwroot\seedImages\kurczakRyżMarchewkaBrokuł.jpg")) }; recipeRepository.Add(pastaWithChicken); recipeRepository.Add(breadWithHam); recipeRepository.Add(pancakes); recipeRepository.Add(porridge); recipeRepository.Add(omelette); recipeRepository.Add(scrambledEggs); recipeRepository.Add(riceWithChickenAndSpinach); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = chicken, Quantity = 200, Recipe = pastaWithChicken }, new Ingredient { Product = pasta, Quantity = 200, Recipe = pastaWithChicken }, new Ingredient { Product = mushrooms, Quantity = 100, Recipe = pastaWithChicken }, new Ingredient { Product = sourCream, Quantity = 200, Recipe = pastaWithChicken } }); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = bread, Quantity = 3, Recipe = breadWithHam }, new Ingredient { Product = butter, Quantity = 10, Recipe = breadWithHam }, new Ingredient { Product = ham, Quantity = 3, Recipe = breadWithHam } }); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = milk, Quantity = 250, Recipe = pancakes }, new Ingredient { Product = eggs, Quantity = 3, Recipe = pancakes }, new Ingredient { Product = flour, Quantity = 200, Recipe = pancakes }, new Ingredient { Product = sugar, Quantity = 10, Recipe = pancakes } }); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = milk, Quantity = 250, Recipe = porridge }, new Ingredient { Product = oatmealFlakes, Quantity = 150, Recipe = porridge }, new Ingredient { Product = apple, Quantity = 1, Recipe = porridge }, }); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = milk, Quantity = 50, Recipe = omelette }, new Ingredient { Product = oatmealFlakes, Quantity = 150, Recipe = omelette }, new Ingredient { Product = banana, Quantity = 1, Recipe = omelette }, new Ingredient { Product = eggs, Quantity = 3, Recipe = omelette } }); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = milk, Quantity = 30, Recipe = scrambledEggs }, new Ingredient { Product = butter, Quantity = 5, Recipe = scrambledEggs }, new Ingredient { Product = ham, Quantity = 4, Recipe = scrambledEggs }, new Ingredient { Product = eggs, Quantity = 3, Recipe = scrambledEggs } }); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = rice, Quantity = 100, Recipe = riceWithChickenAndSpinach }, new Ingredient { Product = butter, Quantity = 5, Recipe = riceWithChickenAndSpinach }, new Ingredient { Product = chicken, Quantity = 250, Recipe = riceWithChickenAndSpinach }, new Ingredient { Product = spinach, Quantity = 100, Recipe = riceWithChickenAndSpinach } }); ingredientRepository.AddIngredients(new List <Ingredient> { new Ingredient { Product = rice, Quantity = 100, Recipe = riceWithChickenCarrotBroccoli }, new Ingredient { Product = chicken, Quantity = 250, Recipe = riceWithChickenCarrotBroccoli }, new Ingredient { Product = broccoli, Quantity = 100, Recipe = riceWithChickenCarrotBroccoli }, new Ingredient { Product = carrot, Quantity = 3, Recipe = riceWithChickenCarrotBroccoli } }); } }
public void Add(RecipeModel obj) { var itemToAdd = _recipeMapper.MapRecipeModelToRecipeEntity(obj); _recipeRepository.Add(itemToAdd); }
public void Add(Recipe recipe) { _repo.Add(recipe); }
public void AddItem(RecipeModel item) { RecipeRepository.Add(RecipeMapper.ConvertRecipeModelToRecipe(item)); }