Beispiel #1
0
        private async void OpenEditDayMealDialogAsync(DayMeal meal)
        {
            var mealClone = meal.Clone();

            var dialog = _dialogs.For <DayMealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "Modified meal";
            dialog.Data.SubmitButtonTitle = "Save";
            dialog.Data.DayMeal           = DayMealViewModel.FromModel(mealClone);

            var dialogResult = await dialog.Show();

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

            mealClone = dialog.Data.DayMeal.ToModel();
            EatingDay.Meals.Replace(meal, mealClone);
        }
Beispiel #2
0
        private async void OpenAddDayMealDialogAsync()
        {
            var meal = new DayMeal
            {
                Hour = DateTime.Today.Hour
            };

            var dialog = _dialogs.For <DayMealDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New meal";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.DayMeal           = DayMealViewModel.FromModel(meal);

            var dialogResult = await dialog.Show();

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

            meal = dialog.Data.DayMeal.ToModel();
            EatingDay.Meals.Add(meal);
            EatingDay.Meals.Refresh(meal);
        }