예제 #1
0
        public DomainEventSerializationDouble(AppointmentAdded appointmentAddedEvent)
            : this((DomainEvent)appointmentAddedEvent)
        {
            DomainEventType = EventType.Added;

            Description    = appointmentAddedEvent.Description;
            StartTime      = new TimeSerializationDouble(appointmentAddedEvent.StartTime);
            EndTime        = new TimeSerializationDouble(appointmentAddedEvent.EndTime);
            TherapyPlaceId = appointmentAddedEvent.TherapyPlaceId;
            AppointmentId  = appointmentAddedEvent.AppointmentId;
            LabelId        = appointmentAddedEvent.LabelId;
        }
예제 #2
0
 private void HandleAddedEvent(AppointmentAdded addedEvent)
 {
     AppointmentData.Add(new AppointmentTransferData(addedEvent.PatientId,
                                                     addedEvent.Description,
                                                     addedEvent.AggregateId.Date,
                                                     addedEvent.StartTime,
                                                     addedEvent.EndTime,
                                                     addedEvent.TherapyPlaceId,
                                                     addedEvent.AppointmentId,
                                                     addedEvent.AggregateId.MedicalPracticeId,
                                                     addedEvent.LabelId));
 }
        private static void WriteEvent(XmlWriter writer, AppointmentAdded @event)
        {
            writer.WriteStartElement(AppointmentAddedEvent);

            writer.WriteAttributeString(DescriptionAttribute, @event.Description);
            writer.WriteAttributeString(TherapyPlaceIdAttribute, @event.TherapyPlaceId.ToString());
            writer.WriteAttributeString(StartTimeAttribute, @event.StartTime.ToString());
            writer.WriteAttributeString(EndTimeAttribute, @event.EndTime.ToString());
            writer.WriteAttributeString(AppointmentIdAttribute, @event.AppointmentId.ToString());
            writer.WriteAttributeString(LabelIdAttribute, @event.LabelId.ToString());

            writer.WriteEndElement();
        }
예제 #4
0
        private bool TryToAddEvent(AppointmentAdded addedEvent)
        {
            if (eventStreamAggregator.AppointmentData.Any(appointment => appointment.Id == addedEvent.AppointmentId))
            {
                return(false);
            }

            return(eventStreamAggregator
                   .AppointmentData
                   .Where(appointment => appointment.TherapyPlaceId == addedEvent.TherapyPlaceId)
                   .All(appointment => (appointment.StartTime <= addedEvent.StartTime || appointment.StartTime >= addedEvent.EndTime) &&
                        (appointment.EndTime <= addedEvent.StartTime || appointment.EndTime >= addedEvent.EndTime)));
        }
        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
                );
        }
예제 #6
0
        public override void Process(AppointmentAdded domainEvent)
        {
            if (domainEvent.PatientId != patientId)
            {
                return;
            }

            appointmentSet.AddAppointment(domainEvent.PatientId,
                                          domainEvent.Description,
                                          domainEvent.StartTime,
                                          domainEvent.EndTime,
                                          domainEvent.AggregateId.Date,
                                          domainEvent.TherapyPlaceId,
                                          domainEvent.LabelId,
                                          domainEvent.AppointmentId,
                                          domainEvent.AggregateId.MedicalPracticeId);
        }
예제 #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!Check())
            {
                return;
            }

            Appointment ap = new Appointment();

            ap.ConfirmedBy   = txtConfirmedBy.Text;
            ap.CustomerGroup = cbCustomerGroup.Text;
            ap.Date          = date.Value;


            string startTime = GetTime((int)nudStartHour.Value, (int)nudStartMin.Value,
                                       cbStartTime.SelectedIndex == 0 ? "AM" : "PM");
            string endTime = GetTime((int)nudEndHour.Value, (int)nudEndMin.Value,
                                     cbEndTime.SelectedIndex == 0 ? "AM" : "PM");

            ap.StartTime = startTime;
            ap.EndTime   = endTime;

            ap.Location = txtLocation.Text.Trim();

            ap.Requestor    = txtRequestor.Text.Trim();
            ap.CustomerName = txtTitle.Text.Trim();


            CurrentAppointment = ap;

            if (Update)
            {
                CurrentAppointment.ID = UpdateId;
                this.ap.Update(CurrentAppointment);
                AppointmentUpdated?.Invoke();
            }
            else
            {
                CurrentAppointment.ID = this.ap.AddAppointment(ap, UserData.UserId);
                AppointmentAdded?.Invoke();
            }

            Reset();
            this.Hide();
        }
        public override void Process(AppointmentAdded domainEvent)
        {
            if (domainEvent.AggregateId != Identifier)
            {
                return;
            }

            if (AggregateVersion != domainEvent.AggregateVersion)
            {
                throw new VersionNotApplicapleException("@handle appointmentAdded @readmodel");
            }

            appointmentSet.AddAppointment(domainEvent.PatientId,
                                          domainEvent.Description,
                                          domainEvent.StartTime,
                                          domainEvent.EndTime,
                                          domainEvent.AggregateId.Date,
                                          domainEvent.TherapyPlaceId,
                                          domainEvent.AppointmentId,
                                          domainEvent.LabelId,
                                          errorCallback);

            AggregateVersion = domainEvent.AggregateVersion + 1;
        }
예제 #9
0
 /// <summary>
 /// Invoke AppointmentAdded event
 /// </summary>
 /// <param name="appointment">Added appointment</param>
 internal static void Call_AppointmentAdded(Appointment appointment)
 {
     AppointmentAdded?.Invoke(appointment);
 }