Esempio n. 1
0
        private async void OpenEditMealDialogAsync(MealTemplate meal)
        {
            var mealClone = meal.Clone();
            var dialog    = _dialogs.For <MealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "Modified meal";
            dialog.Data.SubmitButtonTitle = "Save";
            dialog.Data.Meal = MealViewModel.FromModel(mealClone);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            mealClone = dialog.Data.Meal.ToModel();
            Meals.Replace(meal, mealClone);
            _mealRepository.Update(mealClone);
        }
Esempio n. 2
0
        private async void OpenAddMealDialogAsync()
        {
            var meal   = new MealTemplate();
            var dialog = _dialogs.For <MealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New meal";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.Meal = MealViewModel.FromModel(meal);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            meal = dialog.Data.Meal.ToModel();
            Meals.Add(meal);
            _mealRepository.Create(meal);
        }
Esempio n. 3
0
        private void RemoveMeal(MealTemplate meal)
        {
            Meals.Remove(meal);

            Task.Run(() => _mealRepository.Delete(meal));
        }