コード例 #1
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            repository.Delete(id);
            await repository.SaveChangesAsync();

            return(RedirectToAction("Index", "CookBooks"));
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public IActionResult DeleteConfirmation(int id)
        {
            var recipe = recipeRepository
                         .RecipeContext
                         .Recipes
                         .Where(r => r.Id == id)
                         .FirstOrDefault();

            recipeRepository.Delete(id);
            return(View(recipe));
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 public ActionResult <string> Delete(int id)
 {
     try
     {
         return(Ok(_repo.Delete(id)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
コード例 #7
0
        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ę");
            }
        }
コード例 #8
0
        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"));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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());
        }
コード例 #11
0
 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();
 }
コード例 #12
0
        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);
            }
        }
コード例 #13
0
        public ActionResult Delete(int id, Recipe recipe)
        {
            try
            {
                RecipeRepository recipeRepository = new RecipeRepository();

                using (recipeRepository)
                {
                    recipeRepository.Delete(id);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #14
0
        /// <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);
        }
コード例 #15
0
 public void Delete(int id)
 {
     recipeRepository.Delete(id);
     // Add call to delete all notes for a recipe.
 }
コード例 #16
0
 public Task Delete(string id)
 {
     return(_repository.Delete(id));
 }
コード例 #17
0
        public void Delete(RecipeModel obj)
        {
            var recipe = _recipeMapper.MapRecipeModelToRecipeEntity(obj);

            _recipeRepository.Delete(recipe);
        }
コード例 #18
0
 public void Delete(int id)
 {
     RecipeRepository.Delete(id);
 }
コード例 #19
0
ファイル: RecipeBuilder.cs プロジェクト: JornWildt/Peach
 protected override void DisposeInstance(Recipe item)
 {
     RecipeRepository.Delete(item.Id);
 }