private async void ExecuteResolveNotification() { switch (SelectedNotification) { case SurgeryRequestNotification notification: await _calendarEntryService.CreateSurgery(notification.SurgeryRequest.StartDate, notification.SurgeryRequest.EndDate, notification.SurgeryRequest.ProposedDoctor, notification.SurgeryRequest.Patient, notification.SurgeryRequest.Room, notification.SurgeryRequest.IsUrgent); break; case AppointmentRequestNotification notification: await _calendarEntryService.CreateAppointment(notification.AppointmentRequest.StartDate, notification.AppointmentRequest.EndDate, notification.AppointmentRequest.ProposedDoctor, notification.AppointmentRequest.Patient, notification.AppointmentRequest.Room); break; } SelectedNotification.Status = NotificationStatus.Resolved; await _notificationService.Update(SelectedNotification); NotificationIsUnresolved = false; await LoadNotifications(); }
private async void ExecuteScheduleAppointment() { await Task.Run(async() => { RoomAlreadyInUse = InvalidTimeFrame = false; var appointmentStart = AppointmentStartDate + AppointmentStartTime?.TimeOfDay; var appointmentEnd = AppointmentEndDate + AppointmentEndTime?.TimeOfDay; CalendarEntry created = null; if (appointmentEnd <= appointmentStart || appointmentEnd == null || appointmentStart == null) { InvalidTimeFrame = true; } // Trying to save some RAM else if ((await _calendarEntryService.GetAllByRoomAndTimeFrame(SelectedRoom, appointmentStart.Value, appointmentEnd.Value)).ToList().Count != 0) { //var res = await _calendarEntryService.GetAllByRoomAndTimeFrame(SelectedRoom, appointmentStart.Value, appointmentEnd.Value); RoomAlreadyInUse = true; } else { switch (SelectedAppointmentType) { case RoomType.CheckUp: if (ScheduleAppointmentAtSpecialist) { await _calendarEntryService.CreateAppointmentRequest(appointmentStart.Value, appointmentEnd.Value, SelectedPatient, Doctor, SelectedSpecialist, DateTime.Now, SelectedRoom); MaterialDesignMessageQueue.Enqueue("All managers have been notified of this appointment."); } else { created = await _calendarEntryService.CreateAppointment(appointmentStart.Value, appointmentEnd.Value, Doctor, SelectedPatient, SelectedRoom); } Clean(); break; case RoomType.Surgery: if (ScheduleAppointmentAtSpecialist) { await _calendarEntryService.CreateSurgeryRequest(appointmentStart.Value, appointmentEnd.Value, SelectedPatient, Doctor, SelectedSpecialist, IsUrgent, DateTime.Now, SelectedRoom); MaterialDesignMessageQueue.Enqueue("All managers have been notified of this surgery."); } else { created = await _calendarEntryService.CreateSurgery(appointmentStart.Value, appointmentEnd.Value, Doctor, SelectedPatient, SelectedRoom, IsUrgent); if (IsUrgent) { MaterialDesignMessageQueue.Enqueue("All managers have been notified of this surgery"); } } Clean(); break; } } if (created != null) { Application.Current.Dispatcher.Invoke(() => Calendar.AddEvent(created)); } }); }