Ejemplo n.º 1
0
        private void CancelBtn_Click(object sender, RoutedEventArgs e)
        {
            ParentView.Show_WaitView("Cancelando platillo");
            List <Ingredients> ingredientsList = new List <Ingredients>();

            if (_dish.Ingredients != null)
            {
                ingredientsList = _dish.Ingredients.ToList();
            }


            var selectedIngredients = ingredientsList.Where(x => x.Dish == _dish.Id);

            using (var db = App.DbFactory.Open())
            {
                foreach (var ingredient in selectedIngredients)
                {
                    db.Delete(ingredient);
                }
                _dish.Ingredients = null;
                db.Delete(_dish);
            }

            ParentView.Show_DishesView();
        }
Ejemplo n.º 2
0
 private void OnClick_AcceptBtn(object sender, RoutedEventArgs e)
 {
     if (NameTxt.Text == "" || NameTxt.Text == " " || NameTxt.Text == string.Empty)
     {
         WarningText.Visibility = Visibility.Visible;
     }
     else
     {
         ParentView.Show_WaitView("Creando platillo");
         Dishes dish;
         using (var db = App.DbFactory.Open())
         {
             db.Save(new Dishes
             {
                 Name = NameTxt.Text
             });
             dish = db.Select <Dishes>().Where(x => x.Name == NameTxt.Text).FirstOrDefault();
         }
         ParentView.Show_NewDishView(dish);
     }
 }