private async void Button_Clicked(object sender, EventArgs e) //Button for testing weekly comparisons { var starttime = DateTime.Now; starttime = starttime.Subtract(TimeSpan.FromDays(7)); var endtime = DateTime.Now; endtime = endtime.Subtract(TimeSpan.FromDays(7)); //Log end time SelectedLoadout.StartTime = starttime; SelectedLoadout.EndTime = endtime; SelectedLoadout.DateString = $"{starttime.ToString("dd/MM/yyyy")}"; //Set summary string of exercise time range. SelectedLoadout.StartToEnd = $"{SelectedLoadout.StartTime.ToShortTimeString()} - {SelectedLoadout.EndTime.ToShortTimeString()}"; //Set weight strings for bindings SelectedLoadout = await SetWeightStrings(SelectedLoadout); WeeklyComparisons wComparison = new WeeklyComparisons(SelectedLoadout); var comparedLoadout = await wComparison.CompareLastWeeksSession(); if (comparedLoadout != null) { SelectedLoadout = comparedLoadout; } await MasterModel.DAL.SaveNewExerciseSessionLogAsync(SelectedLoadout); await Navigation.PopAsync(); }
protected override async void OnAppearing() { base.OnAppearing(); ELoadout = await MasterModel.DAL.GetTempExerciseLoadoutAsync(); BindingContext = null; BindingContext = this; }
protected override async void OnAppearing() { base.OnAppearing(); selectedLoadout = await MasterModel.DAL.GetExerciseLoadoutAsync(Key); SavedExercises = await MasterModel.DAL.GetSavedExercisesAsync(); SavedExercises = await RepController.PrepareRepSummariesAsync(SavedExercises); Refresh(); }
private async Task GetSelectedExerciseLoadout() { try { CurrentLoadout = await MasterModel.DAL.GetSelectedExerciseLoadoutAsync(); } catch (Exception ex) { await DisplayAlert("Error", ex.Message, "OK"); } }
private ExerciseLoadout SetTypesComparableFalse(ExerciseLoadout exSession) { foreach (var exercise in exSession.Exercises) { foreach (var type in exercise.Types) { type.IsComparable = false; } } return(exSession); }
private async Task <ExerciseLoadout> SetWeightStrings(ExerciseLoadout loadout) { foreach (var exercise in loadout.Exercises) { foreach (var type in exercise.Types) { foreach (var rep in type.Reps) { rep.WeightString = rep.Weight + "kg"; } } } return(loadout); }
public async Task <ExerciseLoadout> CompareLastWeeksSession() { try { string lastWeeksDate = exSession.StartTime.Subtract(TimeSpan.FromDays(7)).ToString("dd/MM/yyyy"); lastWeeksSession = await MasterModel.DAL.GetLastWeeksExerciseLoadoutAsync(lastWeeksDate); exSession = await SetDifferences(); } catch (Exception) { /* Do nothing */ } //Hide the compared values if no comparable data was found. if (lastWeeksSession == null) { exSession = SetTypesComparableFalse(exSession); } return(exSession); }
private async void LogSession_Clicked(object sender, EventArgs e) { //Log end time SelectedLoadout.EndTime = DateTime.Now; //Set summary string of exercise time range. SelectedLoadout.StartToEnd = $"{SelectedLoadout.StartTime.ToShortTimeString()} - {SelectedLoadout.EndTime.ToShortTimeString()}"; //Set weight strings for bindings SelectedLoadout = await SetWeightStrings(SelectedLoadout); WeeklyComparisons wComparison = new WeeklyComparisons(SelectedLoadout); var comparedLoadout = await wComparison.CompareLastWeeksSession(); SelectedLoadout = comparedLoadout; await MasterModel.DAL.SaveNewExerciseSessionLogAsync(SelectedLoadout); await Navigation.PopAsync(); }
protected override async void OnAppearing() { base.OnAppearing(); //Just grab the loadout once. if (loadoutReceived == false) { SelectedLoadout = await MasterModel.DAL.GetSelectedExerciseLoadoutAsync(); SelectedLoadout.StartTime = DateTime.Now; SelectedLoadout.DateString = SelectedLoadout.StartTime.ToString("dd/MM/yyyy"); loadoutReceived = true; } //Set correct indices. //Ended up having to do "band-aid" solution due to //time constraint. //It isn't set up correctly in the whole app/code structure. await UpdateIndices(); Refresh(); }
public async Task SaveSelectedExerciseLoadoutAsync(ExerciseLoadout eLoadout) { await fb.Child("Users").Child(auth.User.LocalId).Child("SelectedExerciseLoadout").PutAsync(eLoadout); }
public AddExercisesToLoadout() { InitializeComponent(); SavedExercises = new List <Exercise>(); tempELoadout = new ExerciseLoadout(); }
public ExercisePage() { InitializeComponent(); CurrentLoadout = new ExerciseLoadout(); }
public async Task SaveExerciseLoadoutAsync(ExerciseLoadout exLoadout, string key) { await fb.Child("Users").Child(auth.User.LocalId).Child("ExerciseLoadouts").Child(key).PutAsync(exLoadout); }
public NewExerciseLoadout() { InitializeComponent(); ELoadout = new ExerciseLoadout(); }
public async Task SaveNewTempLoadoutExerciseAsync(ExerciseLoadout exLoadout) { await fb.Child("Users").Child(auth.User.LocalId).Child("TempExerciseLoadout").PutAsync(exLoadout); }
public async Task SaveNewExerciseLoadoutAsync(ExerciseLoadout exLoadout) { await fb.Child("Users").Child(auth.User.LocalId).Child("ExerciseLoadouts").PostAsync(exLoadout); }
public NewSession() { InitializeComponent(); SelectedLoadout = new ExerciseLoadout(); loadoutReceived = false; }
public async Task SaveNewExerciseSessionLogAsync(ExerciseLoadout loadout) { await fb.Child("Users").Child(auth.User.LocalId).Child("ExerciseSessions").PostAsync(loadout); }
public WeeklyComparisons(ExerciseLoadout _exSession) { exSession = _exSession; }