public void Add(Ingredient ingredient) { var query = from Ingredient in _dbContext.MyIngredients where Ingredient.Name == ingredient.Name && Ingredient.IngredientType == ingredient.IngredientType select Ingredient; if (query.ToList <Ingredient>().Count == 0) { _dbContext.MyIngredients.Add(ingredient); _dbContext.SaveChanges(); } }
public void AddToFavorites(Recipe recipe) { _dbContext.MyFavorites.Add(recipe); _dbContext.SaveChanges(); }