Example #1
0
        public SearchPageViewModel(IPatientSelectorViewModel patientSelectorViewModel,
                                   ISharedStateReadOnly <Patient> selectedPatientVariable,
                                   ISharedState <Date> selectedDateVariable,
                                   IViewModelCommunication viewModelCommunication,
                                   ICommandService commandService,
                                   IClientReadModelRepository readModelRepository,
                                   IClientMedicalPracticeRepository medicalPracticeRepository,
                                   Action <string> errorCallBack)
        {
            this.selectedPatientVariable   = selectedPatientVariable;
            this.viewModelCommunication    = viewModelCommunication;
            this.commandService            = commandService;
            this.readModelRepository       = readModelRepository;
            this.medicalPracticeRepository = medicalPracticeRepository;
            this.errorCallBack             = errorCallBack;
            this.selectedDateVariable      = selectedDateVariable;

            NoAppointmentsAvailable = false;

            selectedPatientVariable.StateChanged += OnSelectedPatientVariableChanged;

            PatientSelectorViewModel = patientSelectorViewModel;

            DeleteAppointment = new ParameterrizedCommand <DisplayAppointmentData>(DoDeleteAppointment);
            ModifyAppointment = new ParameterrizedCommand <DisplayAppointmentData>(DoModifyAppointment);

            SelectedPatient = NoPatientSelected;

            DisplayedAppointments = new ObservableCollection <DisplayAppointmentData>();
        }
        public ClosedDayGridViewModel(AggregateIdentifier identifier,
                                      ClientMedicalPracticeData medicalPractice,
                                      IViewModelCommunication viewModelCommunication,
                                      ISharedStateReadOnly <Size> appointmentGridSizeVariable)
        {
            this.viewModelCommunication      = viewModelCommunication;
            this.appointmentGridSizeVariable = appointmentGridSizeVariable;

            Identifier = identifier;
            IsActive   = false;

            viewModelCommunication.RegisterViewModelAtCollection <IAppointmentGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.AppointmentGridViewModelCollection,
                this
                );

            appointmentGridSizeVariable.StateChanged += OnGridSizeChanged;

            TimeGridViewModel = new TimeGridViewModel(Identifier, viewModelCommunication,
                                                      medicalPractice, appointmentGridSizeVariable.Value);

            TherapyPlaceRowViewModels = new ObservableCollection <ITherapyPlaceRowViewModel>();

            PracticeIsClosedAtThisDay = true;
        }
Example #3
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();
        }
        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);
        }
 public ConfirmChangesMessageHandler(IViewModelCommunication viewModelCommunication,
                                     ICommandService commandService,
                                     ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                     Action <string> errorCallback)
 {
     this.viewModelCommunication           = viewModelCommunication;
     this.commandService                   = commandService;
     this.appointmentModificationsVariable = appointmentModificationsVariable;
     this.errorCallback = errorCallback;
 }
        public NotificationServiceContainerViewModel(IViewModelCommunication viewModelCommunication)
        {
            this.viewModelCommunication = viewModelCommunication;

            CurrentVisibleNotifications = new ObservableCollection <INotificationViewModel>();
            notifications = new Dictionary <Guid, INotificationViewModel>();

            viewModelCommunication.RegisterViewModelMessageHandler <ShowNotification>(this);
            viewModelCommunication.RegisterViewModelMessageHandler <HideNotification>(this);
        }
        public NotificationViewModel(string message,
                                     Guid notificationId,
                                     IViewModelCommunication viewModelCommunication)
        {
            Message = message;

            HideNotification = new Command(() =>
            {
                viewModelCommunication.Send(new HideNotification(notificationId));
            });
        }
 public AppointmentModificationsBuilder(IClientMedicalPracticeRepository medicalPracticeRepository,
                                        IClientReadModelRepository readModelRepository,
                                        IViewModelCommunication viewModelCommunication,
                                        ISharedState <Date> selectedDateVariable,
                                        ISharedStateReadOnly <Size> gridSizeVariable)
 {
     this.medicalPracticeRepository = medicalPracticeRepository;
     this.readModelRepository       = readModelRepository;
     this.viewModelCommunication    = viewModelCommunication;
     this.selectedDateVariable      = selectedDateVariable;
     this.gridSizeVariable          = gridSizeVariable;
 }
Example #9
0
        public TherapyPlaceRowViewModel(IViewModelCommunication viewModelCommunication,
                                        IClientTherapyPlaceTypeRepository therapyPlaceTypeRepository,
                                        TherapyPlace therapyPlace,
                                        Color roomDisplayColor,
                                        TherapyPlaceRowIdentifier identifier,
                                        AdornerControl adornerControl,
                                        Time timeSlotBegin,
                                        Time timeSlotEnd,
                                        ISharedStateReadOnly <AppointmentModifications> appointmentModificationsVariable,
                                        Width initialGridWidth,
                                        Action <string> errorCallback)
        {
            this.viewModelCommunication     = viewModelCommunication;
            this.therapyPlaceTypeRepository = therapyPlaceTypeRepository;
            this.therapyPlace = therapyPlace;
            this.appointmentModificationsVariable = appointmentModificationsVariable;

            therapyPlaceTypeRepository.UpdatedTherapyPlaceTypeAvailable += OnUpdatedTherapyPlaceTypeAvailable;

            IsVisible             = true;
            RoomColor             = roomDisplayColor;
            Identifier            = identifier;
            TherapyPlaceName      = therapyPlace.Name;
            AppointmentViewModels = new ObservableCollection <IAppointmentViewModel>();

            viewModelCommunication.RegisterViewModelAtCollection <ITherapyPlaceRowViewModel, TherapyPlaceRowIdentifier>(
                Constants.ViewModelCollections.TherapyPlaceRowViewModelCollection,
                this
                );

            appointmentModificationsVariable.StateChanged += OnAppointmentModificationsChanged;
            OnAppointmentModificationsChanged(appointmentModificationsVariable.Value);

            TimeSlotBegin = timeSlotBegin;
            TimeSlotEnd   = timeSlotEnd;

            AdornerControl = adornerControl;

            GridWidth = initialGridWidth;

            therapyPlaceTypeRepository.RequestTherapyPlaceTypes(
                placeType =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    PlaceTypeIcon = GetIconForTherapyPlaceType(placeType.IconType);
                });
            },
                therapyPlace.TypeId,
                errorCallback
                );
        }
Example #10
0
        public AppointmentModifications(Appointment originalAppointment,
                                        Guid medicalPracticeId,
                                        IClientMedicalPracticeRepository medicalPracticeRepository,
                                        IClientReadModelRepository readModelRepository,
                                        IViewModelCommunication viewModelCommunication,
                                        ISharedState <Date> selectedDateVariable,
                                        ISharedStateReadOnly <Size> gridSizeVariable,
                                        bool isInitialAdjustment,
                                        Action <string> errorCallback)
        {
            OriginalAppointment            = originalAppointment;
            IsInitialAdjustment            = isInitialAdjustment;
            this.medicalPracticeRepository = medicalPracticeRepository;
            this.selectedDateVariable      = selectedDateVariable;
            this.gridSizeVariable          = gridSizeVariable;
            this.errorCallback             = errorCallback;
            this.readModelRepository       = readModelRepository;
            this.viewModelCommunication    = viewModelCommunication;

            versions = new VersionManager <ModificationDataSet>(100);

            versions.CurrentVersionChanged    += OnCurrentVersionChanged;
            versions.PropertyChanged          += OnVersionsManagerPropertyChanged;
            selectedDateVariable.StateChanged += OnSelectedDateVariableChanged;
            gridSizeVariable.StateChanged     += OnGridSizeVariableChanged;

            OnGridSizeVariableChanged(gridSizeVariable.Value);

            var aggregateIdentifier = new AggregateIdentifier(originalAppointment.Day, medicalPracticeId);

            InitialLocation = new TherapyPlaceRowIdentifier(aggregateIdentifier, originalAppointment.TherapyPlace.Id);

            medicalPracticeRepository.RequestMedicalPractice(
                practice =>
            {
                Application.Current.Dispatcher.Invoke(() => currentMedicalPracticeVersion = practice);
            },
                InitialLocation.PlaceAndDate.MedicalPracticeId,
                InitialLocation.PlaceAndDate.Date,
                errorCallback
                );

            var initialDataSet = new ModificationDataSet(originalAppointment.StartTime,
                                                         originalAppointment.EndTime,
                                                         originalAppointment.Description,
                                                         originalAppointment.Label,
                                                         InitialLocation,
                                                         true);

            versions.AddnewVersion(initialDataSet);
        }
Example #11
0
        public MainViewModel(IViewModelCommunication viewModelCommunication,
                             IOverviewPageViewModel overviewPageViewModel,
                             ISearchPageViewModel searchPageViewModel,
                             IOptionsPageViewModel optionsPageViewModel,
                             ISharedStateReadOnly <AppointmentModifications> appointmentModificationsVariable)
        {
            this.viewModelCommunication           = viewModelCommunication;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            OverviewPageViewModel = overviewPageViewModel;
            SearchPageViewModel   = searchPageViewModel;
            OptionsPageViewModel  = optionsPageViewModel;

            SelectedPage = 0;
        }
        public TherapyPlaceRowViewModelBuilder(IViewModelCommunication viewModelCommunication,
                                               IClientMedicalPracticeRepository medicalPracticeRepository,
                                               IClientTherapyPlaceTypeRepository therapyPlaceTypeRepository,
                                               AdornerControl adornerControl,
                                               ISharedStateReadOnly <AppointmentModifications> appointmentModificationsVariable,
                                               ISharedStateReadOnly <Size> appointmentGridSizeVariable)
        {
            this.viewModelCommunication     = viewModelCommunication;
            this.medicalPracticeRepository  = medicalPracticeRepository;
            this.therapyPlaceTypeRepository = therapyPlaceTypeRepository;

            this.adornerControl = adornerControl;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.appointmentGridSizeVariable      = appointmentGridSizeVariable;
        }
 public AppointmentViewModelBuilder(IViewModelCommunication viewModelCommunication,
                                    IClientLabelRepository labelRepository,
                                    ICommandService commandService,
                                    ISharedState <ViewModels.AppointmentView.Helper.AppointmentModifications> appointmentModificationsVariable,
                                    ISharedState <Date> selectedDateVariable,
                                    AdornerControl adornerControl,
                                    IAppointmentModificationsBuilder appointmentModificationsBuilder)
 {
     this.viewModelCommunication           = viewModelCommunication;
     this.labelRepository                  = labelRepository;
     this.commandService                   = commandService;
     this.appointmentModificationsVariable = appointmentModificationsVariable;
     this.selectedDateVariable             = selectedDateVariable;
     this.adornerControl                   = adornerControl;
     this.appointmentModificationsBuilder  = appointmentModificationsBuilder;
 }
Example #14
0
        public AppointmentGridViewModel(AggregateIdentifier identifier,
                                        ClientMedicalPracticeData medicalPractice,
                                        IViewModelCommunication viewModelCommunication,
                                        ISharedStateReadOnly <Size> gridSizeVariable,
                                        ISharedStateReadOnly <Guid?> roomFilterVariable,
                                        ISharedStateReadOnly <Guid> displayedMedicalPracticeVariable,
                                        ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                        IAppointmentViewModelBuilder appointmentViewModelBuilder,
                                        AppointmentsOfADayReadModel readModel,
                                        IEnumerable <ITherapyPlaceRowViewModel> therapyPlaceRowViewModels,
                                        Action <string> errorCallback)
        {
            this.medicalPractice                  = medicalPractice;
            this.viewModelCommunication           = viewModelCommunication;
            this.gridSizeVariable                 = gridSizeVariable;
            this.roomFilterVariable               = roomFilterVariable;
            this.displayedMedicalPracticeVariable = displayedMedicalPracticeVariable;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.appointmentViewModelBuilder      = appointmentViewModelBuilder;
            this.readModel     = readModel;
            this.errorCallback = errorCallback;

            // Initial appointment-Creation is done at the AppointmentGridBuilder

            IsActive = false;
            PracticeIsClosedAtThisDay = false;

            gridSizeVariable.StateChanged   += OnGridSizeChanged;
            roomFilterVariable.StateChanged += OnGlobalRoomFilterVariableChanged;

            viewModelCommunication.RegisterViewModelAtCollection <IAppointmentGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.AppointmentGridViewModelCollection,
                this
                );

            Identifier = identifier;

            readModel.AppointmentChanged += OnReadModelAppointmentChanged;

            TimeGridViewModel = new TimeGridViewModel(Identifier, viewModelCommunication,
                                                      medicalPractice, gridSizeVariable.Value);

            TherapyPlaceRowViewModels = new ObservableCollection <ITherapyPlaceRowViewModel>(therapyPlaceRowViewModels);


            OnGlobalRoomFilterVariableChanged(roomFilterVariable.Value);
        }
Example #15
0
        public GridContainerViewModel(IViewModelCommunication viewModelCommunication,
                                      IClientMedicalPracticeRepository medicalPracticeRepository,
                                      ISharedStateReadOnly <Date> selectedDateVariable,
                                      ISharedStateReadOnly <Guid> selectedMedicalPracticeIdVariable,
                                      ISharedState <Size> appointmentGridSizeVariable,
                                      IEnumerable <AggregateIdentifier> initialGridViewModelsToCache,
                                      int maximumCashedGrids,                                     /* TODO */
                                      IAppointmentGridViewModelBuilder appointmentGridViewModelBuilder,
                                      Action <string> errorCallback)
        {
            // TODO caching implementieren

            this.viewModelCommunication            = viewModelCommunication;
            this.medicalPracticeRepository         = medicalPracticeRepository;
            this.selectedDateVariable              = selectedDateVariable;
            this.selectedMedicalPracticeIdVariable = selectedMedicalPracticeIdVariable;
            this.appointmentGridSizeVariable       = appointmentGridSizeVariable;
            this.appointmentGridViewModelBuilder   = appointmentGridViewModelBuilder;
            this.errorCallback = errorCallback;

            LoadedAppointmentGrids          = new ObservableCollection <IAppointmentGridViewModel>();
            cachedAppointmentGridViewModels = new Dictionary <AggregateIdentifier, IAppointmentGridViewModel>();

            currentDisplayedAppointmentGridIdentifier = null;

            foreach (var identifier in initialGridViewModelsToCache)
            {
                AddGridViewModel(identifier);
            }

            selectedDateVariable.StateChanged += OnSelectedDateStateChanged;
            selectedMedicalPracticeIdVariable.StateChanged += OnDisplayedPracticeStateChanged;

            medicalPracticeRepository.RequestPraticeVersion(
                practiceVersion =>
            {
                var newIdentifier = new AggregateIdentifier(selectedDateVariable.Value, selectedMedicalPracticeIdVariable.Value, practiceVersion);
                TryToShowGridViewModel(newIdentifier);
            },
                selectedMedicalPracticeIdVariable.Value,
                selectedDateVariable.Value,
                errorCallback
                );
        }
        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);
        }
        public AppointmentGridViewModelBuilder(IClientMedicalPracticeRepository medicalPracticeRepository,
                                               IClientReadModelRepository readModelRepository,
                                               IViewModelCommunication viewModelCommunication,
                                               ISharedStateReadOnly <Size> gridSizeVariable,
                                               ISharedStateReadOnly <Guid?> roomFilterVariable,
                                               ISharedStateReadOnly <Guid> displayedMedicalPracticeVariable,
                                               ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                               IAppointmentViewModelBuilder appointmentViewModelBuilder,
                                               ITherapyPlaceRowViewModelBuilder therapyPlaceRowViewModelBuilder)

        {
            this.medicalPracticeRepository        = medicalPracticeRepository;
            this.readModelRepository              = readModelRepository;
            this.viewModelCommunication           = viewModelCommunication;
            this.gridSizeVariable                 = gridSizeVariable;
            this.roomFilterVariable               = roomFilterVariable;
            this.displayedMedicalPracticeVariable = displayedMedicalPracticeVariable;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.appointmentViewModelBuilder      = appointmentViewModelBuilder;
            this.therapyPlaceRowViewModelBuilder  = therapyPlaceRowViewModelBuilder;
        }
        public TimeGridViewModel(AggregateIdentifier identifier,
                                 IViewModelCommunication viewModelCommunication,
                                 ClientMedicalPracticeData medicalPractice,
                                 Size initalSize)
        {
            this.viewModelCommunication = viewModelCommunication;

            viewModelCommunication.RegisterViewModelAtCollection <ITimeGridViewModel, AggregateIdentifier>(
                Constants.ViewModelCollections.TimeGridViewModelCollection,
                this
                );

            Identifier = identifier;

            timeSlotStart = medicalPractice.HoursOfOpening.GetOpeningTime(identifier.Date);
            timeSlotEnd   = medicalPractice.HoursOfOpening.GetClosingTime(identifier.Date);

            TimeSlotLines  = new ObservableCollection <TimeSlotLine>();
            TimeSlotLabels = new ObservableCollection <TimeSlotLabel>();

            SetnewSize(initalSize);
        }
Example #19
0
 public MainWindowBuilder(ILocalSettingsRepository localSettingsRepository,
                          IClientPatientRepository patientRepository,
                          IClientMedicalPracticeRepository medicalPracticeRepository,
                          IClientReadModelRepository readModelRepository,
                          IClientTherapyPlaceTypeRepository therapyPlaceTypeRepository,
                          IClientLabelRepository labelRepository,
                          ICommandService commandService,
                          IViewModelCommunication viewModelCommunication,
                          ISession session,
                          Action <string> errorCallback)
 {
     this.localSettingsRepository    = localSettingsRepository;
     this.patientRepository          = patientRepository;
     this.medicalPracticeRepository  = medicalPracticeRepository;
     this.readModelRepository        = readModelRepository;
     this.therapyPlaceTypeRepository = therapyPlaceTypeRepository;
     this.labelRepository            = labelRepository;
     this.commandService             = commandService;
     this.viewModelCommunication     = viewModelCommunication;
     this.session       = session;
     this.errorCallback = errorCallback;
 }
Example #20
0
        public UndoRedoViewModel(IViewModelCommunication viewModelCommunication,
                                 ISharedState <AppointmentModifications> appointmentModificationsVariable,
                                 ISession session,
                                 Action <string> errorCallback)
        {
            this.viewModelCommunication           = viewModelCommunication;
            this.appointmentModificationsVariable = appointmentModificationsVariable;
            this.session       = session;
            this.errorCallback = errorCallback;

            currentButtonMode = ButtonMode.ViewMode;
            currentAppointmentModifications = null;

            Undo = new Command(UndoAction, UndoPossible);
            Redo = new Command(RedoAction, RedoPossible);


            appointmentModificationsVariable.StateChanged += OnAppointmentModificationsVariableChanged;

            session.UndoPossibleChanged += OnUndoPossibleChanged;
            session.RedoPossibleChanged += OnRedoPossibleChanged;
        }
 public MainViewModelBuilder(IClientMedicalPracticeRepository medicalPracticeRepository,
                             IClientReadModelRepository readModelRepository,
                             IClientPatientRepository patientRepository,
                             IClientTherapyPlaceTypeRepository therapyPlaceTypeRepository,
                             IClientLabelRepository labelRepository,
                             ICommandService commandService,
                             ILocalSettingsRepository localSettingsRepository,
                             IViewModelCommunication viewModelCommunication,
                             ISession session,
                             AdornerControl adornerControl)
 {
     this.medicalPracticeRepository  = medicalPracticeRepository;
     this.readModelRepository        = readModelRepository;
     this.patientRepository          = patientRepository;
     this.therapyPlaceTypeRepository = therapyPlaceTypeRepository;
     this.labelRepository            = labelRepository;
     this.commandService             = commandService;
     this.localSettingsRepository    = localSettingsRepository;
     this.viewModelCommunication     = viewModelCommunication;
     this.session        = session;
     this.adornerControl = adornerControl;
 }
Example #22
0
 public RejectChangesMessageHandler(IViewModelCommunication viewModelCommunication,
                                    ISharedState <AppointmentModifications> appointmentModificationsVariable)
 {
     this.viewModelCommunication           = viewModelCommunication;
     this.appointmentModificationsVariable = appointmentModificationsVariable;
 }
Example #23
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);
        }