コード例 #1
0
ファイル: RecipeController.cs プロジェクト: HongLienLe/BlogV2
        public IActionResult Delete(int id)
        {
            _recipeRepository.DeleteRecipe(id);
            TempData["Message"] = "Your entry was successfully deleted!";

            return(RedirectToAction("Reciepe"));
        }
コード例 #2
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        String recipeName = Session["recipeName"].ToString();

        _objrepositry.DeleteRecipe(recipeName);
        Label1.Text = "Recipe Sucessfully Deleted";
    }
コード例 #3
0
    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");
    }
コード例 #4
0
        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"));
        }
コード例 #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());
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #8
0
ファイル: FormMainWindow.cs プロジェクト: Ronnehag/Recept
        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!");
        }
コード例 #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();
            }
        }
コード例 #10
0
 public void DeleteRecipe(int RecipeId)
 {
     recipeRepository.DeleteRecipe(RecipeId);
 }
コード例 #11
0
 private void DeleteExistingRecipeButton_Click(object sender, EventArgs e)
 {
     _recipeRepository.DeleteRecipe(ExistingRecipesListBox.Text);
     Close();
 }
コード例 #12
0
 public IActionResult OnGetDelete()
 {
     int.TryParse((string)RouteData.Values["Id"], out int id);
     recipeRepository.DeleteRecipe(id);
     return(Redirect("/Recipes/Index"));
 }
コード例 #13
0
 public int Delete(int id)
 {
     return(recipeRepository.DeleteRecipe(id));
 }
コード例 #14
0
 public IActionResult OnGetDelete(int id)
 {
     rr.DeleteRecipe(id);
     return(Redirect("/Recipes/index"));
 }