Esempio n. 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
                );
        }
        private void DoCreateAppointment()
        {
            var therapyPlace = medicalPractice.GetTherapyPlaceById(firstFittingTimeSlot.Item1.TherapyPlaceId);

            var duration = new Duration((uint)(DurationHours * 3600 + DurationMinutes * 60));

            var newAppointmentViewModel = appointmentViewModelBuilder.Build(new Appointment(SelectedPatient,
                                                                                            Description,
                                                                                            therapyPlace,
                                                                                            creationDate,
                                                                                            firstFittingTimeSlot.Item2.Begin,
                                                                                            firstFittingTimeSlot.Item2.Begin + duration,
                                                                                            Guid.NewGuid(),
                                                                                            selectedLabel),
                                                                            new AggregateIdentifier(creationDate, medicalPractice.Id, medicalPractice.Version),
                                                                            errorCallback);

            newAppointmentViewModel.SwitchToEditMode.Execute(true);
            CloseWindow();
        }