示例#1
0
        public async Task DeleteCategory(string name)
        {
            var category = await GetCategoryByNameIfExists(name);

            _context.Remove(category);
            await Save();
        }
示例#2
0
        public void DeleteRecipe(Recipe recipe)
        {
            if (recipe == null)
            {
                throw new ArgumentNullException(nameof(recipe));
            }

            _context.Remove(recipe);
        }
        /// <summary>
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        /// <exception cref="KeyNotFoundException"></exception>
        public async Task DeleteRecipe(string name)
        {
            var recipe = await GetRecipeByNameIfExists(name);

            _context.Remove(recipe);
            await Save();

            _logger.LogInformation($"Deleted recipe {name}");
        }
        public void Delete(User user)
        {
            if (user == null)
            {
                throw new ActionFailedException("User is not found!");
            }

            userContext.Remove(user);
            //user ıcındekı recipeler taglar sılınecek
            userContext.SaveChanges();
        }
示例#5
0
        public void Delete(int entityId)
        {
            var entityToRemove = recipeContext.Find <TEntity>(entityId);

            if (entityToRemove != null)
            {
                recipeContext.Remove(entityToRemove);
            }

            recipeContext.SaveChanges();
        }
示例#6
0
        public async Task <IActionResult> Delete(Guid id)
        {
            var userIngredient = new UserFridgeIngredient {
                Id = id
            };

            _context.Remove(userIngredient);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#7
0
        public void DeleteIngredientsListItem(int itemId)
        {
            var entityToRemove = recipeContext.IngredientsListItems.Find(itemId);

            if (entityToRemove != null)
            {
                recipeContext.Remove(entityToRemove);
            }

            recipeContext.SaveChanges();
        }
示例#8
0
        public async Task <IActionResult> Delete(Recipe recipe)
        {
            if (ModelState.IsValid)
            {
                _context.Remove(recipe);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Favorites"));
            }

            return(RedirectToAction("Index"));
        }
示例#9
0
        public async Task <IActionResult> Delete(Guid id)
        {
            var userIngredient = _context.Users_ShoppingList.FirstOrDefault(s => s.Id.Equals(id));

            if (userIngredient == null)
            {
                return(BadRequest());
            }
            _context.Remove(userIngredient);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#10
0
 public void Delete <T>(T entity) where T : class
 {
     _logger.LogInformation($"Removing an object of type {entity.GetType()} to the context.");
     _context.Remove(entity);
 }
 public void DeleteRestaurant(Restaurant restaurant)
 {
     _context.Remove(restaurant);
 }
 public void DeleteIngredient(Ingredient ingredient)
 {
     _context.Remove(ingredient);
 }