示例#1
0
        private void Execute_Edit(object o)
        {
            if (_select_Item != null)
            {
                Add_food myEdit = new Add_food();
                myEdit.Title = "Изменение рецепта";
                EditViewModel myViewModel = new EditViewModel((FoodViewModel)_select_Item.Clone());
                myEdit.DataContext = myViewModel;

                if (myViewModel.CloseAction == null)
                {
                    myViewModel.CloseAction = new Action(myEdit.Close);
                }


                myEdit.ShowDialog();

                if (myViewModel.is_ok == true)
                {
                    _select_Item.Image_path      = myViewModel.Image_path;
                    _select_Item.Info_food       = myViewModel.Info_food;
                    _select_Item.List_ingridient = myViewModel.List_ingridient;
                    _select_Item.Name_food       = myViewModel.Name_food;
                }
            }
            else
            {
                Not_Element();
            }
        }
示例#2
0
        private void Execute(object o)
        {
            Add_food myAdd = new Add_food();

            myAdd.Title = "Создание рецепта";
            AddViewModel myViewModel = new AddViewModel();

            myAdd.DataContext = myViewModel;

            if (myViewModel.CloseAction == null)
            {
                myViewModel.CloseAction = new Action(myAdd.Close);
            }


            myAdd.ShowDialog();

            if (myViewModel.is_ok == true)
            {
                FoodsList.Add(new FoodViewModel(new Food(myViewModel.Name_food, myViewModel.Image_path, myViewModel.Info_food, myViewModel.List_ingridient)));
            }
        }