protected override async void OnAppearing() { base.OnAppearing(); List <WorkoutList> ListOfWorkouts = new List <WorkoutList>(); //Get the records var workouts = await Models.Persistence.Workout.GetAllWorkoutRecordsInDescendingOrder(_connection); var workoutCount = workouts.Count; //Just grab all for now foreach (var w in workouts) { WorkoutList workoutFromSqlite = new WorkoutList(); workoutFromSqlite.Id = w.Id; //workoutFromSqlite.Completed = w.Completed; workoutFromSqlite.WorkoutDate = w.WorkoutDate; //.ToLocalTime(); workoutFromSqlite.Location = w.Location; workoutFromSqlite.Completed = w.Completed; workoutFromSqlite.UserGuid = w.UserGuid; if (w.Completed == true) { //workoutFromSqlite.CompletedString = "Completed"; workoutFromSqlite.CompletedString = "\u2714"; //workoutFromSqlite.CompletedColor = "Green"; } else { //workoutFromSqlite.CompletedString = "Not Completed"; workoutFromSqlite.CompletedString = "X"; //workoutFromSqlite.CompletedColor = "Red"; } // List <string> fullListOfStrings = await ExerciseName.GetListOfExerciseStrings(_connection, w); string musclegroups = ""; if (musclegroups == "" && fullListOfStrings.Count() == 0) { musclegroups = "None"; } else { foreach (var str in fullListOfStrings) { musclegroups += str + "/"; } } int muscleGroupLength = musclegroups.Length - 1; char muscleGroupLastChar = musclegroups[muscleGroupLength]; string muscleGroupFinal = ""; if (muscleGroupLastChar == '/') { //musclegroups.Remove(muscleGroupLength, 1); muscleGroupFinal = musclegroups.Remove(musclegroups.Length - 1); } workoutFromSqlite.MuscleGroups = muscleGroupFinal; ListOfWorkouts.Add(workoutFromSqlite); } workoutList.ItemsSource = ListOfWorkouts; }
protected override async void OnAppearing() { var users = await Models.Persistence.UsersCredentials.GetAllUsers(_connection); var user = users[0]; Guid g = user.UserGuid; string url = "https://myapi20180503015443.azurewebsites.net/api/OnlineProfile/GetProfile" + "?" + g; HttpClient client = new HttpClient(); var data = JsonConvert.SerializeObject(g); var content = new StringContent(data, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = JsonConvert.DeserializeObject <Models.Persistence.Profile>(response.Content.ReadAsStringAsync().Result); HandleLabel.Text = user.Handle; LocationLabel.Text = "Location: " + result.Location; NameLabel.Text = result.Name; BioLabel2.Text = result.Bio; AgeLabel.Text = "Age: " + result.Age.ToString(); //CREATE OBJECT FOR EDIT PROFILE PAGE p.Name = result.Name; p.Age = result.Age; p.Bio = result.Bio; p.Location = result.Location; p.UserGuid = g; //GET LIST OF WORKOUTS List <Models.WorkoutList> ListOfWorkouts = new List <Models.WorkoutList>(); //Get the records var workouts = await Models.Persistence.Workout.GetAllWorkoutRecordsInDescendingOrder(_connection); var workoutCount = workouts.Count; //Just grab all for now foreach (var w in workouts) { WorkoutList workoutFromSqlite = new WorkoutList(); workoutFromSqlite.Id = w.Id; //workoutFromSqlite.Completed = w.Completed; workoutFromSqlite.WorkoutDate = w.WorkoutDate; //.ToLocalTime(); workoutFromSqlite.Location = w.Location; workoutFromSqlite.Completed = w.Completed; workoutFromSqlite.UserGuid = w.UserGuid; if (w.Completed == true) { //workoutFromSqlite.CompletedString = "Completed"; workoutFromSqlite.CompletedString = "\u2714"; //workoutFromSqlite.CompletedColor = "Green"; } else { //workoutFromSqlite.CompletedString = "Not Completed"; workoutFromSqlite.CompletedString = "X"; //workoutFromSqlite.CompletedColor = "Red"; } // List <string> fullListOfStrings = await ExerciseName.GetListOfExerciseStrings(_connection, w); string musclegroups = ""; if (musclegroups == "" && fullListOfStrings.Count() == 0) { musclegroups = "None"; } else { foreach (var str in fullListOfStrings) { musclegroups += str + "/"; } } int muscleGroupLength = musclegroups.Length - 1; char muscleGroupLastChar = musclegroups[muscleGroupLength]; string muscleGroupFinal = ""; if (muscleGroupLastChar == '/') { //musclegroups.Remove(muscleGroupLength, 1); muscleGroupFinal = musclegroups.Remove(musclegroups.Length - 1); } workoutFromSqlite.MuscleGroups = muscleGroupFinal; ListOfWorkouts.Add(workoutFromSqlite); } profileList.ItemsSource = ListOfWorkouts; }