Exemplo n.º 1
0
        public void showData()
        {
            var Recipes = RecipeBLL.Search(pageIndex, pageSize, sortBy, sortOrder, keyword);

            dgRecipes.ItemsSource = Recipes.Items;
            pageCount             = Recipes.PageCount;
        }
Exemplo n.º 2
0
        public IHttpActionResult GetRecipeWithIngredients(int recipeId)
        {
            RecipeBLL bll     = new RecipeBLL();
            var       recipes = bll.GetRecipeWithIngredients(recipeId);

            if (recipes == null)
            {
                return(Content(HttpStatusCode.NotFound, "Recipe does not exist."));
            }
            else
            {
                return(Ok(recipes));
            }
        }
Exemplo n.º 3
0
        public IHttpActionResult GetActiveRecipes()
        {
            RecipeBLL bll     = new RecipeBLL();
            var       recipes = bll.GetListOfActiveRecipes();

            if (recipes == null)
            {
                return(Content(HttpStatusCode.NotFound, "List of recipes does not exist."));
            }
            else
            {
                return(Ok(recipes));
            }
        }
Exemplo n.º 4
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Recipe recipe = ((FrameworkElement)sender).DataContext as Recipe;

            if (MessageBox.Show("Are you sure you want to delete " + recipe.Title + "?",
                                "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                var op = RecipeBLL.Delete(recipe.RecipeID);

                if (op.Code != "200")
                {
                    MessageBox.Show("Error : " + op.Message);
                }
                else
                {
                    MessageBox.Show("Recipe is successfully deleted from table");
                    showData();
                }
            }
            ;
        }
Exemplo n.º 5
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var op = RecipeBLL.Update(new Recipe()
            {
                RecipeID    = thisRecipe.RecipeID,
                Ingredients = txtIngredients.Text,
                UnitMeasure = txtUnitofMeasure.Text,
                Instruction = txtIngredients.Text,
                Title       = txtTitle.Text,
                Price       = txtPrice.Text
            });

            if (op.Code != "200")
            {
                MessageBox.Show("Error : " + op.Message);
            }
            else
            {
                MessageBox.Show("Succesfully Update");
            }
            myParentWindow.showData();
            this.Close();
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var op = RecipeBLL.Add(new Recipe()
            {
                Ingredients = txtIngredients.Text,
                Instruction = txtInstruction.Text,
                Price       = txtPrice.Text,
                Title       = txtTitle.Text,
                UnitMeasure = txtUnitofMeasure.Text,
                RecipeID    = Guid.NewGuid()
            });

            if (op.Code != "200")
            {
                MessageBox.Show("Error : " + op.Message);
            }
            else
            {
                MessageBox.Show("Ingrediets is Succesfully added to table");
            }
            myParentWindow.showData();
            this.Close();
        }