public async Task DeleteCategory(string name) { var category = await GetCategoryByNameIfExists(name); _context.Remove(category); await Save(); }
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(); }
public void Delete(int entityId) { var entityToRemove = recipeContext.Find <TEntity>(entityId); if (entityToRemove != null) { recipeContext.Remove(entityToRemove); } recipeContext.SaveChanges(); }
public async Task <IActionResult> Delete(Guid id) { var userIngredient = new UserFridgeIngredient { Id = id }; _context.Remove(userIngredient); await _context.SaveChangesAsync(); return(NoContent()); }
public void DeleteIngredientsListItem(int itemId) { var entityToRemove = recipeContext.IngredientsListItems.Find(itemId); if (entityToRemove != null) { recipeContext.Remove(entityToRemove); } recipeContext.SaveChanges(); }
public async Task <IActionResult> Delete(Recipe recipe) { if (ModelState.IsValid) { _context.Remove(recipe); await _context.SaveChangesAsync(); return(RedirectToAction("Favorites")); } return(RedirectToAction("Index")); }
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()); }
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); }