private void AppointmentBooked(AppointmentBookedEvent @event)
        {
            _appointmentRepository.Save(@event.Source);

            //todo: still a problem here.
            //Some logic has slipped into here on how to raise a command to make a booking.
            var makeBookingCommand = new MakeBooking
            {
                Id            = @event.Source.Id.Value,
                EmployeeId    = @event.Source.ConsultantId,
                Start         = @event.Source.Date + @event.Source.StartTime,
                End           = @event.Source.Date + @event.Source.EndTime,
                BookingTypeId = Constants.SalesAppointmentBookingTypeId
            };

            _bus.Send(makeBookingCommand);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <Unit> Handle(BookAppointmentCommand request, CancellationToken cancellationToken)
        {
            var equipmentAvailable = await _equipmentService.GetEquipmentAvailableOnAppointmentDateAsync(request.AppointmentDate, request.StartTime, request.EndTime);

            var equipmentId = equipmentAvailable != null ? equipmentAvailable.EquipmentId : 0;
            var appointment = Appointment.BookAppointment(request.PatientId, equipmentId, request.ReferenceCode, request.AppointmentDate, request.StartTime, request.EndTime, _appointmentEquipmentIsAvailableValidator, _appointmentPatientMustExistRuleValidator);
            await _appointmentRepository.AddAsync(appointment);

            // raise events
            var patient = await _repository.GetByScalarValueAsync(new { Id = request.PatientId });

            // add to outbox for processing
            await _mediator.Publish(AppointmentBookedEvent.Create(appointment.Id, request.ReferenceCode, $"{patient.FirstName} {patient.LastName}", patient.EmailAddress), cancellationToken);

            await _equipmentService.MarkAsUnAvailable(equipmentAvailable); // mark item as unavailable item from the cached list

            return(Unit.Value);
        }
        private void AppointmentBooked(AppointmentBookedEvent @event)
        {
            _appointmentRepository.Save(@event.Source);

            //todo: still a problem here.
            //Some logic has slipped into here on how to raise a command to make a booking.
            var makeBookingCommand = new MakeBooking
            {
                Id = @event.Source.Id.Value,
                EmployeeId = @event.Source.ConsultantId,
                Start = @event.Source.Date + @event.Source.StartTime,
                End = @event.Source.Date + @event.Source.EndTime,
                BookingTypeId = Constants.SalesAppointmentBookingTypeId
            };

            _bus.Send(makeBookingCommand);
        }
Exemplo n.º 4
0
 private void Apply(AppointmentBookedEvent aggregateEvent)
 {
     bookedAppointment = aggregateEvent;
 }