public AppointmentFormViewModel (User selectedUser, AppointmentStatusDTO appointmentStatus) { SelectedUser = selectedUser; //get the Member Image if(SelectedUser.ImageURL == null || SelectedUser.ImageURL == ""){ MemberImage = "memberpic.png"; }else{ MemberImage = SelectedUser.ImageURL; } AppointmentQuestionList = new ObservableCollection<AppointmentQuestionDTO> (); QuestionGroupList = new ObservableCollection<AppointmentQuestionGroup>(); if (CrossConnectivity.Current.IsConnected) { Task.Run (async() => { IsProcessing = true; string token = await TokenManager.GetToken (); int section = appointmentStatus.SurveySectionID; var appointmentQuestionListAPI = await CoachServices.RequestAppointmentQuestions(token,SelectedUser.GymID,section,SelectedUser.ProfileID); AppointmentQuestionList = new ObservableCollection<AppointmentQuestionDTO> (appointmentQuestionListAPI); foreach(var rSumm in AppointmentQuestionList) { AppointmentQuestionGroup responseSummaryGroup = new AppointmentQuestionGroup(rSumm.QuestionOptions, rSumm.QuestionText, rSumm.Form, rSumm.ID, rSumm.QuestionType); Device.BeginInvokeOnMainThread(() => { QuestionGroupList.Add(responseSummaryGroup); }); } IsProcessing = false; }); } else { DependencyService.Get<ICustomDialog> ().Display ("This function requires a connection to a network. Please connect to a network.", "OK"); } }
private async void ExecuteNavigateCompleteCommand(AppointmentStatusDTO appointmentStatus) { if (IsBusy) { return; } IsBusy = true; if (appointmentStatus.HasForm == 1) { await Application.Current.MainPage.Navigation.PushAsync(new mpAppointmentForm(SelectedUser, appointmentStatus)); } else { var response = await CoachServices.PostCompleteAppointment(appointmentStatus.AppointmentID, SelectedUser.ProfileID); if (!response.Contains("200")) { DependencyService.Get<ICustomDialog>().Display("Oops. The appointment was not completed. Please try again", "OK"); } else { var page = Application.Current.MainPage.Navigation.NavigationStack.Last() as mpAppointmentsPage; page.ViewModel.LoadViewModel(); } } IsBusy = false; }
private async void ExecuteNavigateAvailabilityCommand(AppointmentStatusDTO appointmentStatus) { if (IsBusy) { return; } IsBusy = true; await Application.Current.MainPage.Navigation.PushAsync(new mpTrainerAvailabilityPage(SelectedUser, appointmentStatus.AppointmentTypeID)); IsBusy = false; }