Example #1
0
        public IActionResult Delete(int id)
        {
            _recipeRepository.DeleteRecipe(id);
            TempData["Message"] = "Your entry was successfully deleted!";

            return(RedirectToAction("Reciepe"));
        }
    protected void Delete_Click(object sender, EventArgs e)
    {
        String recipeName = Session["recipeName"].ToString();

        _objrepositry.DeleteRecipe(recipeName);
        Label1.Text = "Recipe Sucessfully Deleted";
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(recipeGrid.DataKey.Value.ToString());

        _objrepositry.DeleteRecipe(id);
        update.Text = "Recipe Sucessfully Deleted";
        Response.Redirect("Recipes.aspx");
    }
        public ActionResult Delete(int Id)
        {
            Recipe deletedProduct = repository.DeleteRecipe(Id);

            if (deletedProduct != null)
            {
                TempData["message"] = string.Format("Usunięto {0}", deletedProduct.Name);
            }
            return(RedirectToAction("Index"));
        }
Example #5
0
 // DELETE: Recipe/DeleteRecipe/{id}
 public ActionResult DeleteRecipe(Guid id)
 {
     try
     {
         if (_repo.DeleteRecipe(id))
         {
             ViewBag.AlertMsg = "Recipe deleted successfully";
         }
         return(RedirectToAction("GetAllRecipes"));
     }
     catch
     {
         return(View());
     }
 }
Example #6
0
        /// <summary>
        /// Method to delete a recipe and all of its ingredients and cooking instructions
        /// </summary>
        /// <param name="recipe">The recipe to be deleted</param>
        /// <returns>True if the recipe was deleted</returns>
        public async Task <bool> DeleteRecipeAsync(RecipeDTO recipe)
        {
            var isDeleted = true;

            try
            {
                await Task.Run(() => recipeRepository.DeleteRecipe(recipe.RecipeId));
            }
            catch (Exception ex)
            {
                isDeleted = false;
            }

            return(isDeleted);
        }
Example #7
0
        public void DeleteRecipe_RemovesExpectedRecipe()
        {
            var recipe = new Recipe
            {
                Id       = 1,
                IsPublic = true,
                IsShared = true,
            };

            RecipeManagerContextHelper.AddRecipe(_recipeManagerContext, recipe);
            RecipeManagerContextHelper.DetachAllEntities(_recipeManagerContext);

            _recipeRepository.DeleteRecipe(recipe, true);
            var result = _recipeRepository.GetRecipeById(recipe.Id);

            Assert.IsNull(result);
        }
Example #8
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if (lBox_RecipeResults.SelectedIndex == -1)
            {
                return;
            }
            var value = (Recipe)lBox_RecipeResults.SelectedItem;

            var repo = new RecipeRepository();

            repo.DeleteRecipe(value.RecipeId);
            UpdateListBox();
            UpdateDescription();
            ResetDescription();

            MessageBox.Show("Receptet borttaget!");
        }
Example #9
0
        public void DeleteRecipe_ReturnsProperCount()
        {
            //Arrange
            var dbOptions = new DbContextOptionsBuilder <CarbonKitchenDbContext>()
                            .UseInMemoryDatabase(databaseName: $"RecipeDb{Guid.NewGuid()}")
                            .Options;
            var sieveOptions = Options.Create(new SieveOptions());

            var fakeRecipeOne = new FakeRecipe {
            }.Generate();
            var fakeRecipeTwo = new FakeRecipe {
            }.Generate();
            var fakeRecipeThree = new FakeRecipe {
            }.Generate();

            //Act
            using (var context = new CarbonKitchenDbContext(dbOptions))
            {
                context.Recipes.AddRange(fakeRecipeOne, fakeRecipeTwo, fakeRecipeThree);

                var service = new RecipeRepository(context, new SieveProcessor(sieveOptions));
                service.DeleteRecipe(fakeRecipeTwo);

                context.SaveChanges();

                //Assert
                var recipeList = context.Recipes.ToList();

                recipeList.Should()
                .NotBeEmpty()
                .And.HaveCount(2);

                recipeList.Should().ContainEquivalentOf(fakeRecipeOne);
                recipeList.Should().ContainEquivalentOf(fakeRecipeThree);
                Assert.DoesNotContain(recipeList, r => r == fakeRecipeTwo);

                context.Database.EnsureDeleted();
            }
        }
 public void DeleteRecipe(int RecipeId)
 {
     recipeRepository.DeleteRecipe(RecipeId);
 }
Example #11
0
 private void DeleteExistingRecipeButton_Click(object sender, EventArgs e)
 {
     _recipeRepository.DeleteRecipe(ExistingRecipesListBox.Text);
     Close();
 }
Example #12
0
 public IActionResult OnGetDelete()
 {
     int.TryParse((string)RouteData.Values["Id"], out int id);
     recipeRepository.DeleteRecipe(id);
     return(Redirect("/Recipes/Index"));
 }
Example #13
0
 public int Delete(int id)
 {
     return(recipeRepository.DeleteRecipe(id));
 }
 public IActionResult OnGetDelete(int id)
 {
     rr.DeleteRecipe(id);
     return(Redirect("/Recipes/index"));
 }