示例#1
0
        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;
        }
示例#2
0
        private async void SaveCoffee(object obj)
        {
            if (string.IsNullOrWhiteSpace(PropertiesName))
            {
                return;
            }
            Coffee coffee = propertiesObject as Coffee;

            coffee.Name = PropertiesName;
            await CoffeeHelper.AddOrUpdateCoffee(coffee);

            LoadCoffees();
        }
示例#3
0
 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;
 }
示例#4
0
        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;
        }
示例#5
0
        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();
        }
示例#6
0
 private void LoadCoffees()
 {
     Coffees = (ObservableCollection <Coffee>)CoffeeHelper.GetCoffees().Result;
 }
示例#7
0
        private void LoadCoffees(string coffeesSearch)
        {
            var cofs = CoffeeHelper.GetCoffees().Result;

            Coffees = new ObservableCollection <Coffee>(cofs.Where(c => c.Name.ToLower().Contains(coffeesSearch.ToLower())));
        }