Exemple #1
0
        private async void OpenEditEatingDayDialogAsync(EatingDay day)
        {
            var dayClone = day.Clone();

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

            dialog.Data.DialogTitle       = "Modified day";
            dialog.Data.SubmitButtonTitle = "Save";
            dialog.Data.EatingDay         = EatingDayViewModel.FromModel(dayClone);

            var dialogResult = await dialog.Show();

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

            dayClone = dialog.Data.EatingDay.ToModel();
            Days.Replace(day, dayClone);
            _eatingDayRepository.Update(dayClone);
        }
Exemple #2
0
        private async void OpenAddEatingDayDialogAsync()
        {
            var day = new EatingDay
            {
                Date = DateTime.Today
            };

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

            dialog.Data.DialogTitle       = "New day";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.EatingDay         = EatingDayViewModel.FromModel(day);

            var dialogResult = await dialog.Show();

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

            day = dialog.Data.EatingDay.ToModel();
            Days.Add(day);
            _eatingDayRepository.Create(day);
        }