Пример #1
0
        public async Task <BbqEventViewModel> EditEventAsync(BbqEventViewModel input)
        {
            bool isNew = false;
            var  model = new BbqEventViewModel();

            if (input == null)
            {
                isNew = true;
            }
            else
            {
                model.Load(input);
            }

            var dialog = new Dialogs.EventEditorDialog();

            dialog.Event = model;

            var result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                model = dialog.Event;

                var entity = isNew ? new BbqEvent() : await this.dataProvider.GetEventByIdAsync(model.Id);

                entity.Load(model);

                if (isNew)
                {
                    await this.dataProvider.InsertEventAsync(entity);
                }
                else
                {
                    await this.dataProvider.UpdateEventAsync(entity);
                }

                return(model);
            }

            return(null);
        }
Пример #2
0
        public async Task <BbqEventViewModel> SelectEventAsync()
        {
            var selectDialog = new Dialogs.SelectEventDialog();

            BbqEventViewModel selectedEvent = null;

            do
            {
                var result = await selectDialog.ShowAsync();

                if (result == ContentDialogResult.Primary && selectDialog.SelectedEvent != null)
                {
                    selectedEvent = new BbqEventViewModel();
                    selectedEvent.Load(selectDialog.SelectedEvent);
                }
                else if (result == ContentDialogResult.Secondary)
                {
                    selectedEvent = await this.eventEditor.EditEventAsync(null);
                }
            }while (selectedEvent == null);

            return(selectedEvent);
        }