Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 4
0
 private async Task GetSelectedExerciseLoadout()
 {
     try
     {
         CurrentLoadout = await MasterModel.DAL.GetSelectedExerciseLoadoutAsync();
     }
     catch (Exception ex)
     {
         await DisplayAlert("Error", ex.Message, "OK");
     }
 }
Ejemplo n.º 5
0
        private ExerciseLoadout SetTypesComparableFalse(ExerciseLoadout exSession)
        {
            foreach (var exercise in exSession.Exercises)
            {
                foreach (var type in exercise.Types)
                {
                    type.IsComparable = false;
                }
            }

            return(exSession);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 public async Task SaveSelectedExerciseLoadoutAsync(ExerciseLoadout eLoadout)
 {
     await fb.Child("Users").Child(auth.User.LocalId).Child("SelectedExerciseLoadout").PutAsync(eLoadout);
 }
Ejemplo n.º 11
0
 public AddExercisesToLoadout()
 {
     InitializeComponent();
     SavedExercises = new List <Exercise>();
     tempELoadout   = new ExerciseLoadout();
 }
Ejemplo n.º 12
0
 public ExercisePage()
 {
     InitializeComponent();
     CurrentLoadout = new ExerciseLoadout();
 }
Ejemplo n.º 13
0
 public async Task SaveExerciseLoadoutAsync(ExerciseLoadout exLoadout, string key)
 {
     await fb.Child("Users").Child(auth.User.LocalId).Child("ExerciseLoadouts").Child(key).PutAsync(exLoadout);
 }
Ejemplo n.º 14
0
 public NewExerciseLoadout()
 {
     InitializeComponent();
     ELoadout = new ExerciseLoadout();
 }
Ejemplo n.º 15
0
 public async Task SaveNewTempLoadoutExerciseAsync(ExerciseLoadout exLoadout)
 {
     await fb.Child("Users").Child(auth.User.LocalId).Child("TempExerciseLoadout").PutAsync(exLoadout);
 }
Ejemplo n.º 16
0
 public async Task SaveNewExerciseLoadoutAsync(ExerciseLoadout exLoadout)
 {
     await fb.Child("Users").Child(auth.User.LocalId).Child("ExerciseLoadouts").PostAsync(exLoadout);
 }
Ejemplo n.º 17
0
 public NewSession()
 {
     InitializeComponent();
     SelectedLoadout = new ExerciseLoadout();
     loadoutReceived = false;
 }
Ejemplo n.º 18
0
 public async Task SaveNewExerciseSessionLogAsync(ExerciseLoadout loadout)
 {
     await fb.Child("Users").Child(auth.User.LocalId).Child("ExerciseSessions").PostAsync(loadout);
 }
Ejemplo n.º 19
0
 public WeeklyComparisons(ExerciseLoadout _exSession)
 {
     exSession = _exSession;
 }