Esempio n. 1
0
        private void RejectChanges()
        {
            var isInitial             = appointmentModificationsVariable.Value.IsInitialAdjustment;
            var originalAppointmentId = appointmentModificationsVariable.Value.OriginalAppointment.Id;

            appointmentModificationsVariable.Value.Dispose();
            appointmentModificationsVariable.Value = null;

            if (isInitial)
            {
                viewModelCommunication.SendTo(                                                          //
                    Constants.ViewModelCollections.AppointmentViewModelCollection,                      // do nothing but
                    originalAppointmentId,                                                              // deleting the temporarly
                    new Dispose()                                                                       // created Appointment
                    );                                                                                  //
            }
            else
            {
                viewModelCommunication.SendTo(
                    Constants.ViewModelCollections.AppointmentViewModelCollection,
                    originalAppointmentId,
                    new RestoreOriginalValues()
                    );
            }
        }
Esempio n. 2
0
 private void ActivateGridViewModel(AggregateIdentifier identifier)
 {
     viewModelCommunication.SendTo(
         Constants.ViewModelCollections.AppointmentGridViewModelCollection,
         identifier,
         new Activate()
         );
 }
 private void OnGridSizeChanged(Size newGridSize)
 {
     if (IsActive)
     {
         viewModelCommunication.SendTo(
             Constants.ViewModelCollections.TimeGridViewModelCollection,
             Identifier,
             new NewSizeAvailable(newGridSize)
             );
     }
 }
Esempio n. 4
0
        private void OnGlobalRoomFilterVariableChanged(Guid?newRoomFilter)
        {
            if (IsActive)
            {
                if (displayedMedicalPracticeVariable.Value == medicalPractice.Id)
                {
                    if (newRoomFilter == null)
                    {
                        TherapyPlaceRowViewModels.Do(viewModel =>
                        {
                            viewModelCommunication.SendTo(
                                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection,
                                viewModel.Identifier,
                                new SetVisibility(true)
                                );
                        });
                    }
                    else
                    {
                        TherapyPlaceRowViewModels.Do(viewModel =>
                        {
                            viewModelCommunication.SendTo(
                                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection,
                                viewModel.Identifier,
                                new SetVisibility(false)
                                );
                        });

                        medicalPractice.GetRoomById(newRoomFilter.Value)
                        .TherapyPlaces
                        .Select(therapyPlace => therapyPlace.Id)
                        .Do(id =>
                        {
                            viewModelCommunication.SendTo(
                                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection,
                                new TherapyPlaceRowIdentifier(Identifier, id),
                                new SetVisibility(true)
                                );
                        });
                    }
                }
            }
        }
Esempio n. 5
0
        private void DoModifyAppointment(DisplayAppointmentData appointment)
        {
            viewModelCommunication.Send(new ShowPage(MainPage.Overview));

            viewModelCommunication.Send(new AsureDayIsLoaded(appointment.AppointmentRawData.MedicalPracticeId,
                                                             appointment.Day,
                                                             () =>
            {
                selectedDateVariable.Value = appointment.Day;

                viewModelCommunication.SendTo(
                    Constants.ViewModelCollections.AppointmentViewModelCollection,
                    appointment.AppointmentRawData.Id,
                    new SwitchToEditMode()
                    );
            }));
        }
Esempio n. 6
0
        public AppointmentViewModel(Appointment appointment,
                                    ICommandService commandService,
                                    IViewModelCommunication viewModelCommunication,
                                    TherapyPlaceRowIdentifier initialLocalisation,
                                    ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                    ISharedState <Date> selectedDateVariable,
                                    IAppointmentModificationsBuilder appointmentModificationsBuilder,
                                    IWindowBuilder <EditDescription> editDescriptionWindowBuilder,
                                    AdornerControl adornerControl,
                                    Action <string> errorCallback)
        {
            this.appointment         = appointment;
            this.initialLocalisation = initialLocalisation;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.selectedDateVariable             = selectedDateVariable;
            ViewModelCommunication = viewModelCommunication;
            AdornerControl         = adornerControl;

            viewModelCommunication.RegisterViewModelAtCollection <IAppointmentViewModel, Guid>(
                Constants.ViewModelCollections.AppointmentViewModelCollection,
                this
                );

            SwitchToEditMode = new ParameterrizedCommand <bool>(
                isInitalAdjusting =>
            {
                if (appointmentModificationsVariable.Value == null)
                {
                    CurrentAppointmentModifications = appointmentModificationsBuilder.Build(appointment,
                                                                                            initialLocalisation.PlaceAndDate.MedicalPracticeId,
                                                                                            isInitalAdjusting,
                                                                                            errorCallback);

                    CurrentAppointmentModifications.PropertyChanged += OnAppointmentModificationsPropertyChanged;
                    appointmentModificationsVariable.Value           = CurrentAppointmentModifications;
                    OperatingMode = OperatingMode.Edit;
                    appointmentModificationsVariable.StateChanged += OnCurrentModifiedAppointmentChanged;
                }
            }
                );

            DeleteAppointment = new Command(
                async() =>
            {
                var dialog = new UserDialogBox("", "Wollen Sie den Termin wirklich löschen?",
                                               MessageBoxButton.OKCancel);
                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    if (appointmentModificationsVariable.Value.IsInitialAdjustment)
                    {
                        viewModelCommunication.SendTo(                                                                                  //
                            Constants.ViewModelCollections.AppointmentViewModelCollection,                                              // do nothing but
                            appointmentModificationsVariable.Value.OriginalAppointment.Id,                                              // deleting the temporarly
                            new Dispose()                                                                                               // created Appointment
                            );                                                                                                          //
                    }
                    else
                    {
                        commandService.TryDeleteAppointment(
                            operationSuccessful =>
                        {
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                if (!operationSuccessful)
                                {
                                    Process(new RestoreOriginalValues());
                                    viewModelCommunication.Send(new ShowNotification("löschen des Termins fehlgeschlagen; bearbeitung wurde zurückgesetzt", 5));
                                }
                            });
                        },
                            currentLocation.PlaceAndDate,
                            appointment.Patient.Id,
                            appointment.Id,
                            appointment.Description,
                            appointment.StartTime,
                            appointment.EndTime,
                            appointment.TherapyPlace.Id,
                            appointment.Label.Id,
                            ActionTag.RegularAction,
                            errorCallback
                            );
                    }

                    appointmentModificationsVariable.Value = null;
                }
            }
                );

            EditDescription = new Command(
                () =>
            {
                viewModelCommunication.Send(new ShowDisabledOverlay());

                var dialog = editDescriptionWindowBuilder.BuildWindow();
                dialog.ShowDialog();

                viewModelCommunication.Send(new HideDisabledOverlay());
            }
                );

            ConfirmChanges = new Command(() => viewModelCommunication.Send(new ConfirmChanges()));
            RejectChanges  = new Command(() => viewModelCommunication.Send(new RejectChanges()));

            BeginTime   = appointment.StartTime;
            EndTime     = appointment.EndTime;
            Description = appointment.Description;
            LabelColor  = appointment.Label.Color;

            ShowDisabledOverlay = false;

            SetNewLocation(initialLocalisation, true);
        }
        public void Process(ConfirmChanges message)
        {
            var currentAppointmentModification = appointmentModificationsVariable.Value;

            if (currentAppointmentModification.IsInitialAdjustment)
            {
                commandService.TryAddNewAppointment(
                    operationSuccessful =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        if (operationSuccessful)
                        {
                            viewModelCommunication.SendTo(
                                Constants.ViewModelCollections.AppointmentViewModelCollection,
                                currentAppointmentModification.OriginalAppointment.Id,
                                new Dispose()
                                );

                            currentAppointmentModification.Dispose();
                            appointmentModificationsVariable.Value = null;
                        }
                        else
                        {
                            viewModelCommunication.Send(new ShowNotification("anlegen des Termins nicht möglich: versuch es noch einmal oder breche die operation ab", 5));
                        }
                    });
                },
                    currentAppointmentModification.CurrentLocation.PlaceAndDate,
                    currentAppointmentModification.OriginalAppointment.Patient.Id,
                    currentAppointmentModification.Description,
                    currentAppointmentModification.BeginTime,
                    currentAppointmentModification.EndTime,
                    currentAppointmentModification.CurrentLocation.TherapyPlaceId,
                    currentAppointmentModification.Label.Id,
                    Guid.NewGuid(),
                    ActionTag.RegularAction,
                    errorCallback
                    );
            }
            else
            {
                if (appointmentModificationsVariable.Value == null)
                {
                    return;
                }

                var originalAppointment = currentAppointmentModification.OriginalAppointment;

                if (originalAppointment.Description == currentAppointmentModification.Description &&
                    originalAppointment.StartTime == currentAppointmentModification.BeginTime &&
                    originalAppointment.EndTime == currentAppointmentModification.EndTime &&
                    originalAppointment.Day == currentAppointmentModification.CurrentLocation.PlaceAndDate.Date &&
                    originalAppointment.TherapyPlace.Id == currentAppointmentModification.CurrentLocation.TherapyPlaceId &&
                    originalAppointment.Label.Id == currentAppointmentModification.Label.Id)
                {
                    currentAppointmentModification.Dispose();                           //
                    appointmentModificationsVariable.Value = null;                      //
                    //	no changes to report
                    return;                                                             //
                }

                commandService.TryReplaceAppointment(

                    operationSuccessful =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        if (operationSuccessful)
                        {
                            currentAppointmentModification.Dispose();
                            appointmentModificationsVariable.Value = null;
                        }
                        else
                        {
                            viewModelCommunication.Send(new ShowNotification("anlegen des Termins nicht möglich: versuch es noch einmal oder breche die operation ab", 5));

                            viewModelCommunication.SendTo(
                                Constants.ViewModelCollections.AppointmentViewModelCollection,
                                originalAppointment.Id,
                                new RestoreOriginalValues()
                                );
                        }
                    });
                },
                    currentAppointmentModification.InitialLocation.PlaceAndDate,
                    currentAppointmentModification.CurrentLocation.PlaceAndDate,
                    currentAppointmentModification.OriginalAppointment.Patient.Id,
                    currentAppointmentModification.OriginalAppointment.Description,
                    currentAppointmentModification.Description,
                    currentAppointmentModification.InitialLocation.PlaceAndDate.Date,
                    currentAppointmentModification.CurrentLocation.PlaceAndDate.Date,
                    currentAppointmentModification.OriginalAppointment.StartTime,
                    currentAppointmentModification.BeginTime,
                    currentAppointmentModification.OriginalAppointment.EndTime,
                    currentAppointmentModification.EndTime,
                    currentAppointmentModification.InitialLocation.TherapyPlaceId,
                    currentAppointmentModification.CurrentLocation.TherapyPlaceId,
                    currentAppointmentModification.OriginalAppointment.Label.Id,
                    currentAppointmentModification.Label.Id,
                    currentAppointmentModification.OriginalAppointment.Id,
                    ActionTag.RegularAction,
                    errorCallback
                    );
            }
        }