private void EditRecipe(Recipe recipe) { PropertiesTitle = "Edit Recipe"; PropertiesName = recipe.Name == null ? "" : recipe.Name; PropertiesDescription = recipe.Description == null ? "" : recipe.Description; List <string> cs = new List <string>(); foreach (Coffee c in CoffeeHelper.GetCoffees().Result) { cs.Add(c.Name); } if (recipe.CoffeType != null) { cs.Remove(recipe.CoffeType.Name); cs.Insert(0, recipe.CoffeType.Name); } PropertiesCoffees = cs; ShowPropertiesDescription = true; ShowPropertiesRecipes = false; ShowPropertiesCoffees = true; IsPropertiesRecipeBook = false; IsPropertiesRecipe = true; IsPropertiesCoffee = false; }
private async void SaveCoffee(object obj) { if (string.IsNullOrWhiteSpace(PropertiesName)) { return; } Coffee coffee = propertiesObject as Coffee; coffee.Name = PropertiesName; await CoffeeHelper.AddOrUpdateCoffee(coffee); LoadCoffees(); }
private void DeletePropertiesCommand() { if (propertiesObject is RecipeBook) { RecipeBookHelper.RemoveRecipeBook(propertiesObject as RecipeBook); LoginUser.RecipeBooks.Remove(propertiesObject as RecipeBook); LoadRecipeBooks(); } else if (propertiesObject is Recipe) { RecipeHelper.RemoveRecipe(propertiesObject as Recipe); LoadRecipes(); } else if (propertiesObject is Coffee) { CoffeeHelper.RemoveCoffee(propertiesObject as Coffee); LoadCoffees(); } ShowProperties = false; }
public void NewRecipe() { propertiesObject = new Recipe(); PropertiesTitle = "Add new recipe"; PropertiesName = ""; PropertiesDescription = ""; List <string> cs = new List <string>(); foreach (Coffee c in CoffeeHelper.GetCoffees().Result) { cs.Add(c.Name); } PropertiesCoffees = cs; ShowPropertiesDescription = true; ShowPropertiesRecipes = false; ShowPropertiesCoffees = true; IsPropertiesRecipeBook = false; IsPropertiesRecipe = true; IsPropertiesCoffee = false; }
private async void SaveRecipe(object obj) { if (string.IsNullOrWhiteSpace(PropertiesName)) { return; } Recipe recipe = propertiesObject as Recipe; recipe.Name = PropertiesName; recipe.Description = string.IsNullOrWhiteSpace(PropertiesDescription) ? "No Description" : PropertiesDescription; if (obj is ComboBox) { ComboBox cb = obj as ComboBox; Coffee c = CoffeeHelper.GetCoffees().Result.Where(x => x.Name == cb.SelectedItem.ToString()).SingleOrDefault(); if (c != null) { recipe.CoffeType = c; } } await RecipeHelper.AddOrUpdateRecipe(recipe); LoadRecipes(); }
private void LoadCoffees() { Coffees = (ObservableCollection <Coffee>)CoffeeHelper.GetCoffees().Result; }
private void LoadCoffees(string coffeesSearch) { var cofs = CoffeeHelper.GetCoffees().Result; Coffees = new ObservableCollection <Coffee>(cofs.Where(c => c.Name.ToLower().Contains(coffeesSearch.ToLower()))); }