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;
        }
예제 #2
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
                );
        }
예제 #3
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);
        }
예제 #4
0
        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);
        }
예제 #5
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);
        }