public ActionBarViewModel(ISession session,
                                  IConnectionStatusViewModel connectionStatusViewModel,
                                  IViewModelCommunication viewModelCommunication,
                                  IWindowBuilder <Views.AboutDialog> dialogBuilder)
        {
            this.session = session;
            this.viewModelCommunication = viewModelCommunication;
            this.dialogBuilder          = dialogBuilder;
            ConnectionStatusViewModel   = connectionStatusViewModel;

            var titleBuilder = new StringBuilder();

#if DEBUG
            titleBuilder.Append(">>> DEBUG <<<    ");
#endif
            titleBuilder.Append("OnkoTePla - Version ");
            titleBuilder.Append(ApplicationInfo.ClientVersion);

#if DEBUG
            titleBuilder.Append("    >>> DEBUG <<<");
#endif

            Title = titleBuilder.ToString();

            ShowOverview = new Command(() => viewModelCommunication.Send(new ShowPage(MainPage.Overview)));
            ShowSearch   = new Command(() => viewModelCommunication.Send(new ShowPage(MainPage.Search)));
            ShowOptions  = new Command(() => viewModelCommunication.Send(new ShowPage(MainPage.Options)));

            ShowAbout = new Command(ShowAboutDialog);
            Logout    = new Command(DoLogOut);

            session.ApplicationStateChanged += OnApplicationStateChanged;
            OnApplicationStateChanged(session.CurrentApplicationState);
        }
示例#2
0
        public OverviewPageViewModel(IViewModelCommunication viewModelCommunication,
                                     IDateDisplayViewModel dateDisplayViewModel,
                                     IMedicalPracticeSelectorViewModel medicalPracticeSelectorViewModel,
                                     IRoomFilterViewModel roomFilterViewModel,
                                     IDateSelectorViewModel dateSelectorViewModel,
                                     IGridContainerViewModel gridContainerViewModel,
                                     IUndoRedoViewModel undoRedoViewModel,
                                     IWindowBuilder <Views.AddAppointmentDialog> addAppointmentDialogBuilder,
                                     PrintDialogWindowBuilder printDialogBuilder,
                                     ISharedStateReadOnly <AppointmentModifications> appointmentModificationsVariable,
                                     ISharedStateReadOnly <Guid> selectedMedicalPracticeIdVariable,
                                     ISharedStateReadOnly <Date> selectedDayVariable,
                                     IClientMedicalPracticeRepository medicalPracticeRepository,
                                     Action <string> errorCallback)
        {
            this.appointmentModificationsVariable  = appointmentModificationsVariable;
            this.selectedMedicalPracticeIdVariable = selectedMedicalPracticeIdVariable;
            this.selectedDayVariable         = selectedDayVariable;
            this.medicalPracticeRepository   = medicalPracticeRepository;
            this.errorCallback               = errorCallback;
            DateDisplayViewModel             = dateDisplayViewModel;
            MedicalPracticeSelectorViewModel = medicalPracticeSelectorViewModel;
            RoomFilterViewModel              = roomFilterViewModel;
            DateSelectorViewModel            = dateSelectorViewModel;
            GridContainerViewModel           = gridContainerViewModel;
            UndoRedoViewModel = undoRedoViewModel;

            ChangeConfirmationVisible = false;
            AddAppointmentPossible    = false;


            appointmentModificationsVariable.StateChanged  += OnCurrentModifiedAppointmentVariableChanged;
            selectedMedicalPracticeIdVariable.StateChanged += OnSelectedMedicalPracticeIdVariableChanged;
            selectedDayVariable.StateChanged += OnSelectedDayVariablChanged;

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

                var dialogWindow = addAppointmentDialogBuilder.BuildWindow();
                dialogWindow.ShowDialog();
                //addAppointmentDialogBuilder.DisposeWindow(dialogWindow);

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

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

                var dialogWindow = printDialogBuilder.BuildWindow(new AggregateIdentifier(selectedDayVariable.Value,
                                                                                          selectedMedicalPracticeIdVariable.Value));
                dialogWindow.ShowDialog();
                //printDialogBuilder.DisposeWindow(dialogWindow);

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

            UpdateAddAppointmentPossible();
        }
        private void ShowAboutDialog()
        {
            viewModelCommunication.Send(new ShowDisabledOverlay());

            var dialogWindow = dialogBuilder.BuildWindow();

            dialogWindow.ShowDialog();

            viewModelCommunication.Send(new HideDisabledOverlay());
        }
示例#4
0
        private void EndEditing()
        {
            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()
                    );
            }

            viewModelCommunication.Send(new ShowNotification("Die Terminbearbeitung wurde aufgrund von Konflikten abgebrochen!", 5));
        }
示例#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()
                    );
            }));
        }
        public NotificationViewModel(string message,
                                     Guid notificationId,
                                     IViewModelCommunication viewModelCommunication)
        {
            Message = message;

            HideNotification = new Command(() =>
            {
                viewModelCommunication.Send(new HideNotification(notificationId));
            });
        }
示例#7
0
 public void Process(ShowPage message)
 {
     if (appointmentModificationsVariable.Value == null)
     {
         SelectedPage = (int)message.Page;
     }
     else
     {
         viewModelCommunication.Send(new ShowNotification("Seite kann nicht gewechselt werden, da Termin noch in Bearbeitung", 10));
     }
 }
        public ActionBarViewModel(ISession session,
                                  IConnectionStatusViewModel connectionStatusViewModel,
                                  IViewModelCommunication viewModelCommunication,
                                  IWindowBuilder <Views.AboutDialog> dialogBuilder)
        {
            this.session = session;
            this.viewModelCommunication = viewModelCommunication;
            this.dialogBuilder          = dialogBuilder;
            ConnectionStatusViewModel   = connectionStatusViewModel;

            ShowOverview = new Command(() => viewModelCommunication.Send(new ShowPage(MainPage.Overview)));
            ShowSearch   = new Command(() => viewModelCommunication.Send(new ShowPage(MainPage.Search)));
            ShowOptions  = new Command(() => viewModelCommunication.Send(new ShowPage(MainPage.Options)));

            ShowAbout = new Command(ShowAboutDialog);
            Logout    = new Command(DoLogOut);

            session.ApplicationStateChanged += OnApplicationStateChanged;
            OnApplicationStateChanged(session.CurrentApplicationState);
        }
示例#9
0
        private async void RedoAction()
        {
            switch (currentButtonMode)
            {
            case ButtonMode.StartOfEditMode:
            case ButtonMode.EditsAvailable:
            {
                currentAppointmentModifications.Redo();
                break;
            }

            case ButtonMode.ViewMode:
            {
                var dialog = new UserDialogBox("",
                                               session.GetCurrentRedoActionMsg(),
                                               MessageBoxButton.OKCancel);

                var result = await dialog.ShowMahAppsDialog();

                if (result == MessageDialogResult.Affirmative)
                {
                    session.Redo(
                        operationSuccessful =>
                        {
                            if (!operationSuccessful)
                            {
                                Application.Current.Dispatcher.Invoke(() =>
                                {
                                    viewModelCommunication.Send(new ShowNotification($"redo nicht möglich: eventhistory wird zurückgesetzt", 5));
                                    session.ResetUndoRedoHistory();
                                });
                            }
                        },
                        errorCallback
                        );
                }
                break;
            }
            }
        }
        public void Process(ShowNotification message)
        {
            var notificationId        = Guid.NewGuid();
            var notificationViewModel = new NotificationViewModel(message.NotificationMessage,
                                                                  notificationId,
                                                                  viewModelCommunication);

            if (message.SecondsToShow > 0)
            {
                Application.Current.Dispatcher.DelayInvoke(
                    () => viewModelCommunication.Send(new HideNotification(notificationId)),
                    TimeSpan.FromSeconds(message.SecondsToShow)
                    );
            }

            notifications.Add(notificationId, notificationViewModel);
            CurrentVisibleNotifications.Add(notificationViewModel);
        }
示例#11
0
        private void OnSelectedDateVariableChanged(Date date)
        {
            if (date != CurrentLocation.PlaceAndDate.Date)
            {
                medicalPracticeRepository.RequestMedicalPractice(
                    newMedicalPractice =>
                {
                    if (newMedicalPractice.HoursOfOpening.IsOpen(date))
                    {
                        readModelRepository.RequestAppointmentSetOfADay(
                            fixedAppointmentSet =>
                        {
                            IDictionary <TherapyPlace, IList <Appointment> > sortedAppointments = new Dictionary <TherapyPlace, IList <Appointment> >();

                            foreach (var therapyPlace in newMedicalPractice.GetAllTherapyPlaces())
                            {
                                sortedAppointments.Add(therapyPlace, new List <Appointment>());
                            }

                            foreach (var appointment in fixedAppointmentSet.Appointments)
                            {
                                if (appointment != OriginalAppointment)
                                {
                                    sortedAppointments[appointment.TherapyPlace].Add(appointment);
                                }
                            }

                            var openingTime = newMedicalPractice.HoursOfOpening.GetOpeningTime(date);
                            var closingTime = newMedicalPractice.HoursOfOpening.GetClosingTime(date);

                            var appointmentDuration = new Duration(BeginTime, EndTime);

                            foreach (var therapyRowData in sortedAppointments)
                            {
                                var slots        = ComputeAllSlotsWithinARow(openingTime, closingTime, therapyRowData.Value);
                                var suitableSlot = GetSlotForAppointment(slots, appointmentDuration);

                                if (suitableSlot != null)
                                {
                                    Application.Current.Dispatcher.Invoke(() =>
                                    {
                                        SetNewLocation(
                                            new TherapyPlaceRowIdentifier(new AggregateIdentifier(date,
                                                                                                  CurrentLocation.PlaceAndDate.MedicalPracticeId),
                                                                          therapyRowData.Key.Id),
                                            suitableSlot.Begin,
                                            suitableSlot.Begin + appointmentDuration
                                            );
                                    });

                                    return;
                                }
                            }

                            viewModelCommunication.Send(
                                new ShowNotification("cannot move the OriginalAppointment to that day. No timeslot is big enough!", 5)
                                );

                            selectedDateVariable.Value = CurrentLocation.PlaceAndDate.Date;
                        },
                            new AggregateIdentifier(date, currentMedicalPracticeVersion.Id),
                            errorCallback
                            );
                    }
                    else
                    {
                        Application.Current.Dispatcher.Invoke(() =>
                        {
                            viewModelCommunication.Send(
                                new ShowNotification("cannot move an OriginalAppointment to a day where the practice is closed!", 5)
                                );
                        });

                        selectedDateVariable.Value = CurrentLocation.PlaceAndDate.Date;
                    }
                },
                    currentMedicalPracticeVersion.Id,
                    date,
                    errorCallback
                    );
            }
        }
示例#12
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
                    );
            }
        }