コード例 #1
0
        public void AddAppointment(Guid patientId, string description,
                                   Time startTime, Time endTime, Date day,
                                   Guid therapyPlaceId, Guid appointmentId,
                                   Guid labelId,
                                   Action <string> errorCallback)
        {
            patientRepository.RequestPatient(
                patient =>
            {
                labelRepository.RequestLabel(
                    label =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        var newAppointment = new Appointment(patient,
                                                             description,
                                                             medicalPractice.GetTherapyPlaceById(therapyPlaceId),
                                                             day,
                                                             startTime,
                                                             endTime,
                                                             appointmentId,
                                                             label);

                        ObservableAppointments.AddAppointment(newAppointment);
                    });
                },
                    labelId,
                    errorCallback
                    );
            },
                patientId,
                errorCallback
                );
        }
コード例 #2
0
        public void Process(AddAppointment command)
        {
            if (session.LoggedInUser == null)
            {
                errorCallback("commands can only be processed when a user is logged in");
                return;
            }

            var addedEvent = new AppointmentAdded(command.AggregateId,
                                                  command.AggregateVersion,
                                                  session.LoggedInUser.Id,
                                                  TimeTools.GetCurrentTimeStamp(),
                                                  command.ActionTag,
                                                  command.PatientId,
                                                  command.Description,
                                                  command.StartTime,
                                                  command.EndTime,
                                                  command.TherapyPlaceId,
                                                  command.LabelId,
                                                  command.AppointmentId);

            connectionService.TryAddEvents(
                addingWasSuccesscful =>
            {
                if (!addingWasSuccesscful)
                {
                    errorCallback("adding events failed");
                }
                else
                {
                    if (command.ActionTag == ActionTag.RegularAction)
                    {
                        patientRepository.RequestPatient(patient =>
                        {
                            Application.Current.Dispatcher.Invoke(() =>
                            {
                                session.ReportUserAction(userActionBuilder.BuildAddedAction(command, patient));
                            });
                        },
                                                         command.PatientId,
                                                         errorCallback);
                    }
                }
            },
                new List <DomainEvent> {
                addedEvent
            },
                errorCallback
                );
        }
コード例 #3
0
        public void Process(ReplaceAppointment command)
        {
            if (session.LoggedInUser == null)
            {
                errorCallback("commands can only be processed when a user is logged in");
                return;
            }

            var eventList = new List <DomainEvent>();

            if (command.NewDate == command.OriginalDate)
            {
                eventList.Add(new AppointmentReplaced(command.SourceAggregateId,
                                                      command.SourceAggregateVersion,
                                                      session.LoggedInUser.Id,
                                                      command.PatientId,
                                                      TimeTools.GetCurrentTimeStamp(),
                                                      command.ActionTag,
                                                      command.NewDescription,
                                                      command.NewDate,
                                                      command.NewStartTime,
                                                      command.NewEndTime,
                                                      command.NewTherapyPlaceId,
                                                      command.NewLabelId,
                                                      command.OriginalAppointmendId));
            }
            else
            {
                eventList.Add(new AppointmentDeleted(command.SourceAggregateId,
                                                     command.SourceAggregateVersion,
                                                     session.LoggedInUser.Id,
                                                     command.PatientId,
                                                     TimeTools.GetCurrentTimeStamp(),
                                                     GetDividedActionTag(command.ActionTag),
                                                     command.OriginalAppointmendId));

                eventList.Add(new AppointmentAdded(command.DestinationAggregateId,
                                                   command.DestinationAggregateVersion,
                                                   session.LoggedInUser.Id,
                                                   TimeTools.GetCurrentTimeStamp(),
                                                   GetDividedActionTag(command.ActionTag),
                                                   command.PatientId,
                                                   command.NewDescription,
                                                   command.NewStartTime,
                                                   command.NewEndTime,
                                                   command.NewTherapyPlaceId,
                                                   command.NewLabelId,
                                                   command.OriginalAppointmendId));
            }

            connectionService.TryAddEvents(
                addingWasSuccesscful =>
            {
                if (!addingWasSuccesscful)
                {
                    errorCallback("adding events failed");
                }
                else
                {
                    if (command.ActionTag == ActionTag.RegularAction)
                    {
                        practiceRepository.RequestMedicalPractice(
                            sourcePractice =>
                        {
                            practiceRepository.RequestMedicalPractice(
                                destinationPractice =>
                            {
                                patientRepository.RequestPatient(
                                    patient =>
                                {
                                    Application.Current.Dispatcher.Invoke(() =>
                                    {
                                        session.ReportUserAction(userActionBuilder.BuildReplacedAction(command,
                                                                                                       patient,
                                                                                                       sourcePractice.GetTherapyPlaceById(command.OriginalTherapyPlaceId),
                                                                                                       destinationPractice.GetTherapyPlaceById(command.NewTherapyPlaceId)));
                                    });
                                },
                                    command.PatientId,
                                    errorCallback
                                    );
                            },
                                command.DestinationAggregateId.MedicalPracticeId,
                                command.DestinationAggregateId.PracticeVersion,
                                errorCallback
                                );
                        },
                            command.SourceAggregateId.MedicalPracticeId,
                            command.SourceAggregateId.PracticeVersion,
                            errorCallback
                            );
                    }
                }
            },
                eventList,
                errorCallback
                );
        }