Beispiel #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>();
        }
Beispiel #2
0
        public MedicalPracticeSelectorViewModel(ISession session,
                                                IClientMedicalPracticeRepository medicalPracticeRepository,
                                                ILocalSettingsRepository localSettingsRepository,
                                                ISharedState <Guid> selectedMedicalPracticeIdVariable,
                                                ISharedStateReadOnly <AppointmentModifications> appointmentModificationsVariable,
                                                Action <string> errorCallback)
        {
            this.localSettingsRepository           = localSettingsRepository;
            this.selectedMedicalPracticeIdVariable = selectedMedicalPracticeIdVariable;
            this.appointmentModificationsVariable  = appointmentModificationsVariable;

            selectedMedicalPracticeIdVariable.StateChanged += OnSelectedMedicalPracticeIdVariableChanged;
            appointmentModificationsVariable.StateChanged  += OnAppointmentModificationVariableChanged;

            AvailableMedicalPractices = session.LoggedInUser
                                        .ListOfAccessablePractices
                                        .Select(practiceId => new MedicalPracticeDisplayData(practiceId, practiceId.ToString()))
                                        .ToObservableCollection();

            foreach (var medicalPracticeDisplayData in AvailableMedicalPractices)
            {
                medicalPracticeRepository.RequestMedicalPractice(
                    practice =>
                {
                    medicalPracticeDisplayData.PracticeName = practice.Name;
                },
                    medicalPracticeDisplayData.MedicalPracticeId,
                    errorCallback
                    );
            }

            SelectedMedicalPractice = AvailableMedicalPractices.First(practice => practice.MedicalPracticeId == selectedMedicalPracticeIdVariable.Value);

            PracticeIsSelectable = true;
        }
Beispiel #3
0
        /// <summary>
        /// Makes sure that the observable is initialized against the shared state and any other objects along the tree.
        /// </summary>
        /// <typeparam name="T">The type to return.</typeparam>
        /// <param name="sharedState">The shared state to attach to.</param>
        /// <param name="initializerFunction">The initializer function.</param>
        /// <returns>The observable you wannt.</returns>
        public static T Observable <T>(this ISharedState sharedState, Func <T> initializerFunction)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (initializerFunction is null)
            {
                throw new ArgumentNullException(nameof(initializerFunction));
            }

            try
            {
                SharedState.SetAsyncLocalState(sharedState);
                var result = initializerFunction();
                if (((IReactiveObject)result).SharedState != sharedState)
                {
                    // shared state should have been assigned.
                    throw new ArgumentOutOfRangeException(nameof(initializerFunction));
                }

                return(result);
            }
            finally
            {
                SharedState.SetAsyncLocalState(null);
            }
        }
Beispiel #4
0
        public PatientSelectorViewModel(IClientPatientRepository patientRepository,
                                        ISharedState <Patient> selectedPatientSharedVariable,
                                        Action <string> errorCallback)
        {
            this.patientRepository             = patientRepository;
            this.selectedPatientSharedVariable = selectedPatientSharedVariable;
            this.errorCallback = errorCallback;

            Patients         = new CollectionViewSource();
            Patients.Filter += Filter;
            SearchFilter     = "";

            patientRepository.NewPatientAvailable     += PatientRepositoryChanged;
            patientRepository.UpdatedPatientAvailable += PatientRepositoryChanged;

            patientRepository.RequestAllPatientList(
                patientList =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    Patients.Source = patientList;
                    UpdateForNewInput();
                });
            },
                errorCallback
                );
        }
        /// <summary>
        /// Executes a function while storing and restoring the computation depth.
        /// This allows the computed to modify state.
        /// </summary>
        /// <typeparam name="T">The result type of the function.</typeparam>
        /// <param name="sharedState">The shared state to operate on.</param>
        /// <param name="function">The function to execute.</param>
        /// <returns>The return value of the function.</returns>
        public static T AllowStateChangesInsideComputed <T>(this ISharedState sharedState, Func <T> function)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (function is null)
            {
                throw new ArgumentNullException(nameof(function));
            }

            var previousComputationDeph = sharedState.ComputationDepth;

            sharedState.ComputationDepth = 0;

            try
            {
                return(function());
            }
            finally
            {
                sharedState.ComputationDepth = previousComputationDeph;
            }
        }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Reaction"/> class.
 /// </summary>
 /// <param name="sharedState">The shared state to use.</param>
 /// <param name="name">The name to use.</param>
 /// <param name="onInvalidate">Handler to run when this reaction is invalidated. This handler should call <see cref="Track"/>.</param>
 /// <param name="errorHandler">The error handler for this reaction.</param>
 internal Reaction(ISharedState sharedState, string name, Action onInvalidate, Action <Reaction, Exception> errorHandler)
 {
     // resolve state state from context if necessary.
     this.SharedState  = Net.SharedState.ResolveState(sharedState);
     this.onInvalidate = onInvalidate ?? throw new ArgumentNullException(nameof(onInvalidate));
     this.errorHandler = errorHandler;
     this.Name         = !string.IsNullOrEmpty(name) ? name : $"{this.SharedState.GetUniqueId()}";
 }
Beispiel #7
0
        /// <summary>
        /// Traces the tracking derivation on the Shared State.
        /// </summary>
        /// <param name="sharedState">The Shared State to trace.</param>
        /// <param name="traceMode">The trace mode to use.</param>
        public static void Trace(this ISharedState sharedState, TraceMode traceMode = TraceMode.Log)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            sharedState.TrackingDerivation?.Trace(traceMode);
        }
        /// <summary>
        /// Gets the reference enhancer from the Shared State.
        /// </summary>
        /// <param name="sharedState">The shared state that should provide the reference enhancer.</param>
        /// <returns>The IEnhancer instance.</returns>
        public static IEnhancer ReferenceEnhancer(this ISharedState sharedState)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            return(sharedState.Enhancers.Single(x => x is Types.ReferenceEnhancer));
        }
 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 EditDescriptionWindowBuilder(Appointment appointmentToEdit,
                                     IClientLabelRepository labelRepository,
                                     ISharedState <AppointmentModifications> modificationsVar,
                                     Action <string> errorCallback)
 {
     this.modificationsVar  = modificationsVar;
     this.errorCallback     = errorCallback;
     this.appointmentToEdit = appointmentToEdit;
     this.labelRepository   = labelRepository;
 }
Beispiel #11
0
        public DateSelectorViewModel(ISharedState <Date> selectedDateVariable)
        {
            this.selectedDateVariable = selectedDateVariable;

            SelectToday = new Command(() => SelectedDate = TimeTools.Today());

            selectedDateVariable.StateChanged += OnSelectedDateChanged;

            SelectedDate = selectedDateVariable.Value;
        }
 public LogoutRequestHandler(Action logoutSuccessfulCallback,
                             ClientUserData user,
                             ISharedState <ConnectionInfo> connectionInfoVariable,
                             Action <string> errorCallback)
     : base(errorCallback)
 {
     this.user = user;
     this.connectionInfoVariable   = connectionInfoVariable;
     this.logoutSuccessfulCallback = logoutSuccessfulCallback;
 }
Beispiel #13
0
 public GetAppointmentsOfADayRequestHandler(Action <IReadOnlyList <AppointmentTransferData>, AggregateIdentifier, uint> dataReceivedCallback,
                                            ISharedState <ConnectionInfo> connectionInfoVariable,
                                            Date day, Guid medicalPracticeId,
                                            Action <string> errorCallback)
     : base(errorCallback)
 {
     this.dataReceivedCallback   = dataReceivedCallback;
     this.connectionInfoVariable = connectionInfoVariable;
     this.day = day;
     this.medicalPracticeId = medicalPracticeId;
 }
Beispiel #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Atom"/> class.
        /// </summary>
        /// <param name="sharedState">The shared state where this atom is created on.</param>
        /// <param name="name">The name for this Atom.</param>
        internal Atom(ISharedState sharedState, string name)
        {
            // resolve state state from context if necessary.
            this.SharedState = Net.SharedState.ResolveState(sharedState);

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.Name = name;
        }
 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;
 }
Beispiel #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObserverObject"/> class.
        /// </summary>
        /// <param name="sharedState">The shared state this observer is connected to.</param>
        /// <param name="name">The name of the observer.</param>
        /// <param name="buildRenderTreeAction">The action that should be executed to build the render tree.</param>
        /// <param name="stateChangedAction">The action that is used to force StateHasChanged for this Component.</param>
        public ObserverObject(ISharedState sharedState, string name, Action <RenderTreeBuilder> buildRenderTreeAction, Action stateChangedAction)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.sharedState           = sharedState ?? throw new ArgumentNullException(nameof(sharedState));
            this.name                  = name;
            this.buildRenderTreeAction = buildRenderTreeAction ?? throw new ArgumentNullException(nameof(buildRenderTreeAction));
            this.stateChangedAction    = stateChangedAction ?? throw new ArgumentNullException(nameof(stateChangedAction));
        }
Beispiel #17
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);
        }
Beispiel #18
0
        /// <summary>
        /// Creates a computed value.
        /// </summary>
        /// <typeparam name="T">The type of the elements.</typeparam>
        /// <param name="sharedState">The shared state to operate on.</param>
        /// <param name="getter">The getter function to use.</param>
        /// <param name="name">The name of the observable collection.</param>
        /// <returns>The computed value.</returns>
        public static IComputedValue <T> Computed <T>(this ISharedState sharedState, Func <T> getter, string name = null)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (string.IsNullOrEmpty(name))
            {
                name = $"{nameof(ComputedValue<T>)}@{sharedState.GetUniqueId()}";
            }

            return(new ComputedValue <T>(sharedState, new ComputedValueOptions <T>(getter, name)));
        }
        public async Task Produce(ISharedState state)
        {
            await state.Insert(new ActualWork(0));

            Console.WriteLine("Produced: 0");

            await state.Insert(new ActualWork(1));

            Console.WriteLine("Produced: 1");

            await state.Insert(new WorkCompleted());

            Console.WriteLine("Produced: Completed");
        }
        /// <summary>
        ///  Converts a <see cref="System.IObservable{T}" /> into an <see cref="IObservableValue{T}"></see> which stores the current value(as `Current`).
        ///  The subscription can be canceled through the `Dispose` method. Takes an initial value as second optional argument.
        /// </summary>
        /// <typeparam name="T">The type to observe.</typeparam>
        /// <param name="sharedState">The shared state to use.</param>
        /// <param name="observable">The observable to "convert".</param>
        /// <param name="initialValue">The initial value for the <see cref="IObservableValue{T}" />.</param>
        /// <param name="exceptionHandler">The exception handler to use.</param>
        /// <returns>An observable value.</returns>
        public static RxObserver <T> FromObservable <T>(this ISharedState sharedState, IObservable <T> observable, T initialValue = default, Action <Exception> exceptionHandler = null)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (observable is null)
            {
                throw new ArgumentNullException(nameof(observable));
            }

            return(new RxObserver <T>(sharedState, observable, initialValue, exceptionHandler));
        }
        /// <summary>
        /// Tries to get a Task scheduler or throws an exception.
        /// </summary>
        /// <param name="sharedState">The shared state to use.</param>
        /// <returns>The task scheduler.</returns>
        /// <exception cref="InvalidOperationException">When a task scheduler was not specified or could not be inferred from a SynchronizationContext.</exception>
        internal static TaskScheduler GetTaskScheduler(this ISharedState sharedState)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (sharedState.Configuration.SynchronizationContext != null)
            {
                return(sharedState.Configuration.TaskScheduler);
            }

            throw new InvalidOperationException(Resources.TaskSchedulerNull);
        }
Beispiel #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObservableCollection{T}"/> class.
        /// </summary>
        /// <param name="sharedState">The <see cref="ISharedState"/> instance this observableCollection belongs to.</param>
        /// <param name="enhancer">The <see cref="IEnhancer"/> implementation to use.</param>
        /// <param name="name">The name of the ObservableCollection.</param>
        /// <param name="initialValues">The initial values to use.</param>
        public ObservableCollection(ISharedState sharedState, IEnhancer enhancer, IEnumerable <T> initialValues, string name = null)
        {
            this.SharedState = sharedState ?? throw new ArgumentNullException(nameof(sharedState));
            this.enhancer    = enhancer ?? throw new ArgumentNullException(nameof(enhancer));

            if (string.IsNullOrEmpty(name))
            {
                name = $"{nameof(ObservableCollection<T>)}@{this.SharedState.GetUniqueId()}";
            }

            this.Name      = name;
            this.innerList = initialValues != null ? new List <T>(initialValues) : new List <T>();
            this.atom      = new Atom(sharedState, name);
        }
        /// <summary>
        /// Gets the enhancer specified by the type from the Shared State.
        /// </summary>
        /// <param name="sharedState">The shared state that should provide the reference enhancer.</param>
        /// <param name="enhancerType">The type of the enhancer.</param>
        /// <returns>The IEnhancer instance.</returns>
        /// <exception cref="ArgumentNullException"> When either of the arguments is null.</exception>
        /// <exception cref="InvalidOperationException"> When the type was not found in the list of enhancers.</exception>
        public static IEnhancer GetEnhancer(this ISharedState sharedState, Type enhancerType)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (enhancerType is null)
            {
                throw new ArgumentNullException(nameof(enhancerType));
            }

            return(sharedState.Enhancers.Single(x => x.GetType() == enhancerType));
        }
Beispiel #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Atom"/> class.
        /// </summary>
        /// <param name="sharedState">The shared state where this atom is created on.</param>
        /// <param name="name">The name for this Atom.</param>
        internal Atom(ISharedState sharedState, string name)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.SharedState = sharedState;
            this.Name        = name;
        }
        public PatientSelectorViewModel(IPatientRepository patientRepository,
                                        ISharedState <Patient> selectedPatientSharedVariable)
        {
            this.patientRepository             = patientRepository;
            this.selectedPatientSharedVariable = selectedPatientSharedVariable;

            patientRepository.PatientAdded    += PatientRepositoryUpdated;
            patientRepository.PatientModified += PatientRepositoryUpdated;

            Patients         = new CollectionViewSource();
            Patients.Filter += Filter;
            Patients.Source  = patientRepository.GetAllPatients();

            SearchFilter = "";
        }
Beispiel #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObservableDictionary{TKey, TValue}"/> class.
        /// </summary>
        /// <param name="sharedState">The <see cref="ISharedState"/> instance this observableDictionary belongs to.</param>
        /// <param name="enhancer">The <see cref="IEnhancer"/> implementation to use.</param>
        /// <param name="initialValues">The initial values.</param>
        /// <param name="name">The name of the ObservableDictionary.</param>
        public ObservableDictionary(ISharedState sharedState, IEnhancer enhancer, IDictionary <TKey, TValue> initialValues, string name = null)
        {
            this.SharedState = sharedState ?? throw new ArgumentNullException(nameof(sharedState));
            this.enhancer    = enhancer ?? throw new ArgumentNullException(nameof(enhancer));

            if (string.IsNullOrEmpty(name))
            {
                name = $"{nameof(ObservableDictionary<TKey, TValue>)}@{this.SharedState.GetUniqueId()}";
            }

            this.Name            = name;
            this.innerDictionary = initialValues != null ? new Dictionary <TKey, TValue>(initialValues) : new Dictionary <TKey, TValue>();
            this.hasDictionary   = new Dictionary <TKey, ObservableValue <bool> >();

            this.atom = new Atom(sharedState, name);
        }
 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;
 }
Beispiel #28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RxObserver{T}"/> class.
        /// </summary>
        /// <param name="sharedState">The shared state.</param>
        /// <param name="observable">The observable.</param>
        /// <param name="exceptionHandler">The exception handler.</param>
        /// <param name="initialValue">The initial value.</param>
        internal RxObserver(ISharedState sharedState, IObservable <T> observable, T initialValue, Action <Exception> exceptionHandler)
        {
            if (observable is null)
            {
                throw new ArgumentNullException(nameof(observable));
            }

            this.sharedState      = sharedState ?? throw new ArgumentNullException(nameof(sharedState));
            this.exceptionHandler = exceptionHandler ?? throw new ArgumentNullException(nameof(exceptionHandler));
            this.sharedState.RunInAction(() =>
            {
                this.observableValue       = new ObservableValue <T>(this.sharedState, $"RxObserver<{typeof(T)}>", this.sharedState.ReferenceEnhancer());
                this.observableValue.Value = initialValue;
                observable.Subscribe(this);
            });
        }
Beispiel #29
0
        /// <summary>
        /// Starts an action that changes state and recomputes the state tree.
        /// </summary>
        /// <param name="sharedState">The shared state instance to use.</param>
        /// <param name="actionName">The name of the action.</param>
        /// <param name="scope">The scope of the action.</param>
        /// <param name="arguments">The arguments to the action.</param>
        /// <returns>An <see cref="ActionRunInfo"/> instance containing the information on the currently running action.</returns>
        public static ActionRunInfo StartAction(ISharedState sharedState, string actionName, object scope, object[] arguments)
        {
            if (sharedState is null)
            {
                throw new ArgumentNullException(nameof(sharedState));
            }

            if (arguments is null)
            {
                arguments = Array.Empty <object>();
            }

            var notifySpy          = !string.IsNullOrEmpty(actionName);
            var previousDerivation = sharedState.StartUntracked();

            sharedState.StartBatch();
            var previousAllowStateChanges = sharedState.StartAllowStateChanges(true);
            var previousAllowStateReads   = sharedState.StartAllowStateReads(true);

            var actionRunInfo = new ActionRunInfo()
            {
                SharedState               = sharedState,
                Name                      = string.IsNullOrEmpty(actionName) ? $"Action@{sharedState.NextActionId}" : actionName,
                PreviousDerivation        = previousDerivation,
                PreviousAllowStateChanges = previousAllowStateChanges,
                PreviousAllowStateReads   = previousAllowStateReads,
                NotifySpy                 = notifySpy,
                StartDateTime             = DateTime.UtcNow,
                ActionId                  = sharedState.NextActionId++,
                ParentActionId            = sharedState.CurrentActionId,
            };

            if (notifySpy)
            {
                sharedState.OnSpy(actionRunInfo, new ActionStartSpyEventArgs()
                {
                    Name      = actionRunInfo.Name,
                    ActionId  = actionRunInfo.ActionId,
                    Context   = scope,
                    Arguments = arguments,
                    StartTime = actionRunInfo.StartDateTime,
                });
            }

            sharedState.CurrentActionId = actionRunInfo.ActionId;
            return(actionRunInfo);
        }
Beispiel #30
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);
        }