public void AddRecipe_MinimalRecipe_NoErrors() { AddRecipeDto addRecipeDto = new AddRecipeDto() { Title = "recipe title", RecipeCategoryId = RecipeCategoryId, }; Assert.DoesNotThrowAsync(async() => { await _recipeRepository.AddRecipe(addRecipeDto); }); }
public ActionResult Insert(string name, int type, string link, int origin, int meal) { if (Session["User"] == null) { //TODO: return error that you must be login before adding recipies return(null); } RecipeRepository repo = new RecipeRepository(ConnectionString); Recipe recipe = new Recipe { Name = name, Link = link }; recipe.RecipeType.Id = type; recipe.Origin.Id = origin; recipe.Meal.Id = meal; User user = Session["User"] as User; recipe.User = user; repo.AddRecipe(recipe); ViewBag.Recipies = repo.GetRecipies(); List <BaseItem> meals = repo.GetMealType(); meals.Insert(0, new BaseItem { Id = -1, Name = "-" }); ViewBag.Meals = meals; return(View("Index")); }
public ViewResult RecipeList() { //https://lovingitvegan.com/vegan-pumpkin-pie/ for (int i = 0; i < 5; i++) { RecipeRepository.AddRecipe(new Recipe { RecipeName = "Vegan Pumpkin Pie", Description = "Since it’s Thanksgiving coming up for a lot of people and this is a perfect Thanksgiving pie, my timing is simply perfect on this one. Which is rare, hence the self-congratulatory aspect.", Ingredients = " 1 15oz (425g) Can Puréed Pumpkin (not pumpkin pie filling)\n" + "3 / 4 cup(180ml) Coconut Milk(full fat)\n" + "3 / 4 cup(150g) Brown Sugar\n" + "1 / 4 cup(32g) Cornstarch\n" + "1 / 4 cup(60ml) Maple Syrup\n" + "1 tsp Vanilla Extract\n" + "3 tsp Pumpkin Pie Spice\n" + "1 / 2 tsp Salt\n" + "1 Vegan Pie Crust homemade or store - bought(must be uncooked)\n", Instructions = "Preheat the oven to 350°F (180°C).\nAdd all the filling ingredients to a blender and blend until perfectly smooth\n" + "Pour out over your uncooked pie crust and smooth with a spoon.\nBake in the oven for 60 minutes. When you remove it from the oven, it will still be quite wobbly in the center, this is completely fine, it will firm up when cooling.\n" + "Allow to cool on the counter and then place into the refrigerator to set completely, around 4 hours at least or overnight if possible until completely chilled and set.\n" + "Decorate the pie and serve with whipped coconut cream.\nKeep leftovers covered in the fridge where it will last for up to a week." }); } return(View(RecipeRepository.GetRecipes)); }
public void AddRecipe_NewRecordAddedWithProperValues() { //Arrange var dbOptions = new DbContextOptionsBuilder <RecipeDbContext>() .UseInMemoryDatabase(databaseName: $"RecipeDb{Guid.NewGuid()}") .Options; var sieveOptions = Options.Create(new SieveOptions()); var fakeRecipe = new FakeRecipe { }.Generate(); //Act using (var context = new RecipeDbContext(dbOptions)) { var service = new RecipeRepository(context, new SieveProcessor(sieveOptions)); service.AddRecipe(fakeRecipe); context.SaveChanges(); } //Assert using (var context = new RecipeDbContext(dbOptions)) { context.Recipes.Count().Should().Be(1); var recipeById = context.Recipes.FirstOrDefault(r => r.RecipeId == fakeRecipe.RecipeId); recipeById.Should().BeEquivalentTo(fakeRecipe); recipeById.RecipeId.Should().Be(fakeRecipe.RecipeId); recipeById.RecipeTextField1.Should().Be(fakeRecipe.RecipeTextField1); recipeById.RecipeTextField2.Should().Be(fakeRecipe.RecipeTextField2); recipeById.RecipeDateField1.Should().Be(fakeRecipe.RecipeDateField1); } }
public IActionResult Add(Recipe recipe) { if (ModelState.IsValid) { _recipeRepository.AddRecipe(recipe); TempData["Message"] = "Your entry was successfully added!"; return(RedirectToAction("Recipe")); } return(View(recipe)); }
private void AddDrink(object sender, RoutedEventArgs e) { Recipe recipe = new Recipe(); recipe.Name = DrinkName.Text; recipe.Instructions = DrinkInstructions.Text; recipe.IngredientList = GetUserIngredients(); RecipeRepo.AddRecipe(recipe); var mainWindow = Application.Current.Windows .Cast <Window>() .FirstOrDefault(window => window is MainWindow) as MainWindow; mainWindow.recipePopulator.DrinkRecipes.Add(recipe); mainWindow.ingredientPopulator.AddUserIngredient(recipe.IngredientList); mainWindow.SetIngredientData(); Close(); }
private void AddNewRecipeButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(RecipeNameTextBoxAddRecipe.Text)) { MessageBox.Show("Recipe name is a required field!"); } else { var recipeToAdd = new Recipe { Name = RecipeNameTextBoxAddRecipe.Text, PreparationTime = (int)HoursNumericUpDown.Value * 60 + (int)MinutesNumericUpDown.Value, Ingredients = _ingredientsToAdd }; recipeToAdd.Restaurants.Add(_recipeRepository.GetRestaurant(_restaurantOfRecipeName)); _recipeRepository.AddRecipe(recipeToAdd); Close(); } }
public ActionResult AddRecipe(Recipe rec) { try { if (ModelState.IsValid) { if (_repo.AddRecipe(rec)) { ViewBag.Message = "Recipe added successfully"; return(RedirectToAction("GetAllRecipes")); } } return(View()); } catch { return(View()); } }
public ViewResult InsertPage(Recipes recipes) { RecipeRepository.AddRecipe(recipes); return(View("DataPage", RecipeRepository.recipes)); }
public int AddRecipe(AddRecipeViewModel model) { return(recipeRepository.AddRecipe(model)); }
public int Create(Recipe recipe) { return(recipeRepository.AddRecipe(recipe)); }
public ViewResult AddRecipe(Recipe recipe) { RecipeRepository.AddRecipe(recipe); return(View("AddRecipe")); }