public async Task <ActionResult> DeleteConfirmed(int id) { repository.Delete(id); await repository.SaveChangesAsync(); return(RedirectToAction("Index", "CookBooks")); }
public void TestInsert() { Recipe recipe = new Recipe { Name = "Test af insert", CookTime = 25, ImgSrc = "https://tinyurl.com/usevcle" }; _uut.Insert(recipe); _uut.Save(); Assert.That(_context.Recipe.Contains(recipe), Is.True); _uut.Delete(recipe.RecipeId); _uut.Save(); }
public IActionResult DeleteRecipe(int id, string order_by = null) { var recipe = _recipeRepository.GetById(id); var category = recipe.RecipeCategory.Id; _recipeRepository.Delete(id); return(RedirectToRecipesByCategory(category, order_by)); }
public IActionResult DeleteConfirmation(int id) { var recipe = recipeRepository .RecipeContext .Recipes .Where(r => r.Id == id) .FirstOrDefault(); recipeRepository.Delete(id); return(View(recipe)); }
private async void removeBtn_Clicked(object sender, EventArgs e) { var recipe = recipeList.SelectedItem as Recipe; if (recipe != null) { await recipeRepository.Delete(recipe); recipes.Remove(recipe); } }
public ActionResult <string> Delete(int id) { try { return(Ok(_repo.Delete(id))); } catch (Exception e) { return(BadRequest(e)); } }
private async void RemoveRecipe(Recipe recipe) { bool ask = await Page.DisplayAlert("Usuwanie receptury", "Czy chcesz usunąć recepturę", "Tak", "Nie"); if (ask) { Items.Remove(recipe); RecipeRepository.Delete(recipe); CrossToastPopUp.Current.ShowToastMessage("Usunięto recepturę"); } }
public ActionResult Delete(int id) { var recipe = RecipeRepository.GetById(id); RecipeRepository.DeleteSpecials(recipe.Guid); RecipeRepository.Delete(recipe.Guid); RecipeRepository.DeleteVotes(recipe.Guid); ViewBag.Response = Globals.InfoRecipeDeleted; SessionHandler.ForceReload = true; return(View("Response")); }
public void DeleteItem(Guid id) { var compositions = CompositionRepository.GetList().Where(x => x.RecipeId == id).ToList(); compositions.ForEach(x => CompositionRepository.Delete(x.Id)); var reviews = ReviewRepository.GetList().Where(x => x.RecipeId == id).ToList(); reviews.ForEach(x => ReviewRepository.Delete(x.Id)); RecipeRepository.Delete(id); }
public IActionResult Delete(int id) { var user = GetCurrentUserProfile(); var recipe = _recipeRepository.GetById(id); if (user.Id != recipe.UserProfileId) { return(Forbid()); } _recipeRepository.Delete(id); return(NoContent()); }
public void Delete(int id) { Console.Clear(); Console.Write("Are you sure you want to delete the recipe? "); if (Validation.YesNo() == ConsoleKey.N) { return; } AamountIngredientRepository.Items.RemoveAll(r => r.IdRecipe == id); CookingStepRepository.Items.RemoveAll(r => r.IdRecipe == id); RecipeRepository.Delete(id); UnitOfWork.SaveAllData(); }
void Cleanup(ItemRepository itemRepository, RecipeRepository recipeRepository) { foreach (var metal in GetOreTypes()) { var crystal = $"Crystal {metal} Pure"; var i = itemRepository.GetByName(crystal).FirstOrDefault(); if (i == null) { continue; } foreach (var r in i.MadeFrom) { recipeRepository.Delete(r); } itemRepository.Delete(i); } return; var item = itemRepository.GetByName("Sapphire").FirstOrDefault(); var recipes = recipeRepository.GetByPrimaryResult(item); foreach (var r in recipes) { recipeRepository.Delete(r); } item = itemRepository.GetByName("Diamond").FirstOrDefault(); recipes = recipeRepository.GetByPrimaryResult(item); foreach (var r in recipes) { recipeRepository.Delete(r); } }
public ActionResult Delete(int id, Recipe recipe) { try { RecipeRepository recipeRepository = new RecipeRepository(); using (recipeRepository) { recipeRepository.Delete(id); } return(RedirectToAction("Index")); } catch { return(View()); } }
/// <summary> /// Merges the associated processing, craft and design observations for two recipes. Deletes source. /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> public int MergeRecipes(Recipe source, Recipe target) { //todo: update this when craft and design observations are implemented if (source == null) { throw new ArgumentNullException(nameof(source)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } if (source.Id == Guid.Empty) { throw new InvalidOperationException("Source is transient."); } if (target.Id == Guid.Empty) { throw new InvalidOperationException("Target is transient."); } if (!DuplicateChecker.RecipesAreEqual(source, target)) { throw new InvalidOperationException("Recipes are not duplicates. Cannot merge."); } var obs = _processingObservationRepository.GetByRecipe(source).ToArray(); foreach (var o in obs) { o.Recipe = target; _processingObservationRepository.Save(o); } _recipeRepository.Delete(source); return(obs.Length); }
public void Delete(int id) { recipeRepository.Delete(id); // Add call to delete all notes for a recipe. }
public Task Delete(string id) { return(_repository.Delete(id)); }
public void Delete(RecipeModel obj) { var recipe = _recipeMapper.MapRecipeModelToRecipeEntity(obj); _recipeRepository.Delete(recipe); }
public void Delete(int id) { RecipeRepository.Delete(id); }
protected override void DisposeInstance(Recipe item) { RecipeRepository.Delete(item.Id); }