Ejemplo n.º 1
0
        private void BtnUpdateRecipe_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var recipeToUpdate = new Data.Recipe
                {
                    Id          = Int32.Parse(txtEditRecipeId.Text),
                    Name        = txtEditRecipeName.Text,
                    Ingredients = GetIngredientsToUpdate(ingredientsToUpdate),
                    Preparation = txtEditRecipePreparation.Text,
                    IsFavourite = txtEditRecipeIsFavourite.IsChecked.Value
                };

                Data.DataAccess.UpdateRecipe(recipeToUpdate);
                MessageBox.Show("The recipe updated successfully.");

                var navService = NavigationService.GetNavigationService(this);
                var recipe     = new Recipe(Int32.Parse(txtEditRecipeId.Text));
                navService?.Navigate(recipe);
            }
            catch (Exception)
            {
                MessageBox.Show("Update the recipe failed.");
            }
        }
Ejemplo n.º 2
0
        private void BtnEditRecipe_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                Data.Recipe recipe = Data.DataAccess.GetRecipeById(Int32.Parse(txtReadRecipeId.Text));

                var navService = NavigationService.GetNavigationService(this);
                var editRecipe = new EditRecipe(recipe);
                navService?.Navigate(editRecipe);
            }
            catch (Exception)
            {
                MessageBox.Show("Edit recipe failed.");
            }
        }
Ejemplo n.º 3
0
        public void GetRecipe(Data.Recipe recipe)
        {
            try
            {
                txtEditRecipeId.Text               = recipe.Id.ToString();
                txtEditRecipeName.Text             = recipe.Name;
                lstIngredientsToEdit.ItemsSource   = GetListIngredients(recipe.Ingredients);
                txtEditRecipePreparation.Text      = recipe.Preparation;
                txtEditRecipeIsFavourite.IsChecked = recipe.IsFavourite;

                editIngredients     = GetListIngredients(recipe.Ingredients);
                ingredientsToUpdate = editIngredients;
            }
            catch (Exception)
            {
                MessageBox.Show("Load the recipe failed.");
            }
        }
Ejemplo n.º 4
0
        private void BtnAddRecipe_OnClick(object sender, RoutedEventArgs e)
        {
            Data.Recipe recipe = new Data.Recipe
            {
                Name        = txtRecipeName.Text,
                Ingredients = GetIngredients(ingredients),
                Preparation = txtRecipePreparation.Text,
                IsFavourite = txtRecipeIsFavourite.IsChecked.Value
            };

            try
            {
                DataAccess.AddRecipe(recipe);
                MessageBox.Show("Recipe added successfully");

                var navService = NavigationService.GetNavigationService(this);
                var recipes    = new Recipes();
                navService?.Navigate(recipes);
            }
            catch (Exception)
            {
                MessageBox.Show("Could not add the recipe...");
            }
        }
Ejemplo n.º 5
0
 public RecipeToPrint(Data.Recipe recipe)
 {
     InitializeComponent();
     PrintDocument(recipe);
 }
Ejemplo n.º 6
0
 public EditRecipe(Data.Recipe recipe)
 {
     InitializeComponent();
     GetRecipe(recipe);
 }