public bool tryDeleteRecipe(Recipe recipe, RecipeDataGateway context) { var lastSize = context.Recipes.Count(); try { //context.Recipes.Remove(recipe); context.SaveChanges(); } catch { } return(lastSize > context.Recipes.Count()); }
public void AddRecipe(Recipe recipe, RecipeDataGateway context) { ObservableCollection <ComponentEntity> newComponents = new ObservableCollection <ComponentEntity>(); foreach (var item in recipe.Components) { newComponents.Add( new ComponentEntity(item.Id, new IngredientEntity(item.Ingredient.Id, item.Ingredient.Name), item.Quantity, new UnitEntity(item.Unit.Id, item.Unit.SingularName, item.Unit.PluralName) )); } context.Recipes.Add(new RecipeEntity(recipe.Id, recipe.Name, newComponents)); context.SaveChanges(); }