// Fetch the Healthworker. private async Task FetchHealthworker() { // Send token with Http request apiRequestHelper.SetTokenHeader(); // Send a GET request to the API. string apiResponse = await apiRequestHelper.GetRequest(Constants.healthWorkerUrl + "/" + App.Current.Properties["healthworker_id"]); if (apiResponse != null) { // Convert the API response into a JSON object. dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); // Create a new object from the appointments. healthworker = new Healthworker { Id = (string)App.Current.Properties["healthworker_id"], Firstname = convertedJson.firstname, Lastname = convertedJson.lastname, Email = convertedJson.email, Birthday = convertedJson.birthday, Gender = convertedJson.gender, Phonenumber = convertedJson.phoneNumber }; } else { DisplayAlert("Error", "Sorry, something went wrong. Please try again later.", "Okay"); } // Update the page items. BindingContext = healthworker; }
// Fetch all the questions and make a list of it. private async Task FetchQuestions() { // Send token with Http request apiRequestHelper.SetTokenHeader(); // Send a GET request to the API. string apiResponse = await apiRequestHelper.GetRequest(Constants.questionsUrl); if (apiResponse != null) { // Convert the API response into a JSON object. allQuestions = new List <Question>(); dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); // Loop through all the appointments in the JSON object and create appointment objects. foreach (var question in convertedJson) { allQuestions.Add(new Question { Id = (int)question.id, QuestionString = (string)question.question }); } // Show the first question. ShowQuestionOrComplete(); } else { DisplayAlert("Error", "Sorry, something went wrong. Please try again later.", "Okay"); } }
// Fetch all the questionnaires and make a list of it. private async Task FetchQuestionnaires() { // Send JWT Token With HTTPheader apiRequestHelper.SetTokenHeader(); // Send a GET request to the API. String apiResponse = await apiRequestHelper.GetRequest(Constants.questionnaireUrl); if (apiResponse != null) { // Convert the API response into a JSON object. allQuestionnaires = new ObservableCollection <QuestionnaireViewModel>(); dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); // Loop through all the appointments in the JSON object and create appointment objects. foreach (var questionnaire in convertedJson) { if (questionnaire.client_id == (string)App.Current.Properties["id"]) { allQuestionnaires.Add(new QuestionnaireViewModel { Id = (int)questionnaire.id, Time = (DateTime)questionnaire.time, Redflag = (bool)questionnaire.redflag }); } } } else { DisplayAlert("Error", "Sorry, something went wrong. Please try again later.", "Okay"); } QuestionnaireList.ItemsSource = allQuestionnaires; }
async Task SaveUserId() { apiRequestHelper = new APIRequestHelper(); string email = App.Current.Properties["email"] as string; // Set JWT token in header apiRequestHelper.SetTokenHeader(); // Do getRequest string apiResponse = await apiRequestHelper.GetRequest(Constants.getCurrentUserUrl + "/" + email); dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); App.Current.Properties["id"] = (string)convertedJson.id; App.Current.Properties["healthworker_id"] = (string)convertedJson.healthWorker_Id; }
// Fetch all the appointments and make a list of it. private async Task FetchAppointments() { // Send token with Http request apiRequestHelper.SetTokenHeader(); // Send a GET request to the API. String apiResponse = await apiRequestHelper.GetRequest(Constants.appointmentsUrl); if (apiResponse != null) { // Convert the API response into a JSON object. allAppointments = new ObservableCollection <Appointment>(); dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); // Loop through all the appointments in the JSON object and create appointment objects. foreach (var appointment in convertedJson) { if (appointment.client.id == (string)App.Current.Properties["id"]) { allAppointments.Add(new Appointment { Id = (int)appointment.id, Time = (DateTime)appointment.time, Status = new AppointmentStatus { Id = (int)appointment.status.id, Name = (string)appointment.status.name }, Bench = new Bench { Id = (int)appointment.bench.id, Streetname = (string)appointment.bench.streetname, Housenumber = (string)appointment.bench.housenumber, Province = (string)appointment.bench.province, District = (string)appointment.bench.district }, Client = new Client { Id = (string)appointment.client.id, Email = (string)appointment.client.email, FirstName = (string)appointment.client.firstname, LastName = (string)appointment.client.lastname, BirthDay = (DateTime)appointment.client.birthDay, District = (string)appointment.client.district, Gender = (string)appointment.client.gender, HouseNumber = (string)appointment.client.houseNumber, Province = (string)appointment.client.province, StreetName = (string)appointment.client.streetName }, Healthworker = new Healthworker { Id = (string)appointment.healthworker.id, Firstname = (string)appointment.healthworker.firstname, Lastname = (string)appointment.healthworker.lastname, Birthday = (DateTime)appointment.healthworker.birthday, Gender = (string)appointment.healthworker.gender, Email = (string)appointment.healthworker.email } }); } } } else { DisplayAlert("Error", "Sorry, something went wrong. Please try again later.", "Okay"); } // Group and update the list. GroupAppointments(); AppointmentsList.ItemsSource = groupedAppointments; }
// Fetch the Questionnaire. private async Task FetchQuestionnaire() { // Send token with Http request apiRequestHelper.SetTokenHeader(); // Send a GET request to the API. string apiResponse = await apiRequestHelper.GetRequest(Constants.questionnaireUrl + "/" + questionnaireId); if (apiResponse != null) { // Convert the API response into a JSON object. dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); // Save all the answers. List <AnswerGetViewModel> answers = new List <AnswerGetViewModel>(); dynamic answersJson = convertedJson.answers; foreach (var answer in answersJson) { answers.Add(new AnswerGetViewModel { QuestionId = (int)answer.questionId, Question = (string)answer.question, Answer = (string)answer.answer }); } // Create a new object from the questionnaire. questionnaire = new QuestionnaireGetViewModel { Time = (DateTime)convertedJson.time, Client_id = (string)convertedJson.client_id, Redflag = (bool)convertedJson.redflag, Answers = answers }; } else { DisplayAlert("Error", "Sorry, something went wrong. Please try again later.", "Okay"); } // Update the view. UpdateView(); }
// Fetch the appointment. private async Task FetchAppointment() { // Send token with Http request apiRequestHelper.SetTokenHeader(); // Send a GET request to the API. string apiResponse = await apiRequestHelper.GetRequest(Constants.appointmentsUrl + "/" + appointmentId); if (apiResponse != null) { // Convert the API response into a JSON object. dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); // Create a new object from the appointments. appointment = new Appointment { Id = (int)convertedJson.id, Time = (DateTime)convertedJson.time, Status = new AppointmentStatus { Id = (int)convertedJson.status.id, Name = (string)convertedJson.status.name }, Bench = new Bench { Id = (int)convertedJson.bench.id, Streetname = (string)convertedJson.bench.streetname, Housenumber = (string)convertedJson.bench.housenumber, Province = (string)convertedJson.bench.province, District = (string)convertedJson.bench.district }, Client = new Client { Id = (string)convertedJson.client.id, Email = (string)convertedJson.client.email, FirstName = (string)convertedJson.client.firstname, LastName = (string)convertedJson.client.lastname, District = (string)convertedJson.client.district, Gender = (string)convertedJson.client.gender, HouseNumber = (string)convertedJson.client.houseNumber, Province = (string)convertedJson.client.province, StreetName = (string)convertedJson.client.streetName }, Healthworker = new Healthworker { Id = (string)convertedJson.healthworker.id, Firstname = (string)convertedJson.healthworker.firstname, Lastname = (string)convertedJson.healthworker.lastname, Birthday = (DateTime)convertedJson.healthworker.birthday, Gender = (string)convertedJson.healthworker.gender, Email = (string)convertedJson.healthworker.email } }; } else { DisplayAlert("Error", "Sorry, something went wrong. Please try again later.", "Okay"); } // Update the page items. BindingContext = appointment; UpdateButtons(); }
//Fetch the current user public async Task GetCurrentUser() { string email = App.Current.Properties["email"] as string; var token = App.Current.Properties["token"] as string; Debug.WriteLine("Credentials from memory!!!: " + email + " " + token); apiRequestHelper.SetTokenHeader(); string apiResponse = await apiRequestHelper.GetRequest(Constants.getCurrentUserUrl + "/" + email); Debug.WriteLine("API RESPONSE IST JETZT HIER!" + apiResponse); if (apiResponse != null) { dynamic convertedJson = JsonConvert.DeserializeObject(apiResponse); user = new Client { Email = (string)convertedJson.email, FirstName = (string)convertedJson.firstName, LastName = (string)convertedJson.lastName, Gender = (string)convertedJson.gender, BirthDay = (DateTime)convertedJson.birthDay, StreetName = (string)convertedJson.streetName, District = (string)convertedJson.district, Province = (string)convertedJson.province, HouseNumber = (string)convertedJson.houseNumber, }; } else { DisplayAlert("Error", "Sorry, something went wrong. Please try again later.", "Okay"); } Debug.WriteLine("USER DATA IST JETZT HIERRR!" + user); BindingContext = user; UpdateButtons(); }