示例#1
0
        // retrieve workout sets
        public async Task OnGet()
        {
            WorkoutSets = await _db.WorkoutSets.ToListAsync();

            Workouts = await _db.Workout.ToListAsync();

            WorkoutSetsDisplay = new List <WorkoutSetsDisplay>();
            //Workouts = await _db.Workout.ToListAsync();
            // we need to also get the page count for each
            // pull into a new data holder that can handle that?

            int count = 0;

            foreach (var wrk in WorkoutSets)
            {
                count = Workouts.Where(x => x.WorkoutSets.Id == wrk.Id).Count();

                if (count > 0)
                {
                    WorkoutSetsDisplay.Add(new WorkoutSetsDisplay(wrk.Id, wrk.Name, count));
                }
                else
                {
                    WorkoutSetsDisplay.Add(new WorkoutSetsDisplay(wrk.Id, wrk.Name, 0));
                }
            }
        }
示例#2
0
        private string GetCurrentWeight(Exercise exercise)
        {
            var lastWorkout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).LastOrDefault();

            if (lastWorkout == null)
            {
                return(string.Empty);
            }

            return($"{WeightMetricToImperialConverter.GetWeight(lastWorkout.Weight)} {L10n.GetWeightUnit()}");
        }
示例#3
0
        private string GetStarted(Exercise exercise)
        {
            var workout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).FirstOrDefault();

            if (workout == null)
            {
                return(string.Empty);
            }

            return
                ($"{workout.Created:d}, {workout.Reps} Reps {WeightMetricToImperialConverter.GetWeight(workout.Weight)} {L10n.GetWeightUnit()}");
        }
示例#4
0
        private string GetLastTargetWorkout(Exercise exercise)
        {
            var workout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).LastOrDefault();

            if (workout == null)
            {
                return(string.Empty);
            }

            if ((workout.TargetReps > 0) && (workout.TargetWeight > 0))
            {
                return
                    ($"{workout.TargetReps} Reps {WeightMetricToImperialConverter.GetWeight(workout.TargetWeight)} {L10n.GetWeightUnit()}");
            }
            return(string.Empty);
        }
示例#5
0
        private string GetWeightIncreases(Exercise exercise)
        {
            var weights = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId)
                          .GroupBy(x => x.Weight).Select(x => x.First().Weight).ToList();

            weights.Sort();

            if (weights.Count == 0)
            {
                return("0");
            }

            var convertedWeights = new List <string> ();

            foreach (var weight in weights)
            {
                convertedWeights.Add($"{WeightMetricToImperialConverter.GetWeight(weight)} {L10n.GetWeightUnit()}");
            }
            return($"{weights.Count} ({string.Join(", ", convertedWeights)})");
        }
示例#6
0
        public void ChangeBodyPart(object param)
        {
            BodyPart = (string)param;

            if (BodyPart == "All")
            {
                ChosenWorkouts   = Workouts;
                IndexPagecount   = ChosenWorkouts.Count - 1;
                CurrentPageIndex = 0;
            }

            else
            {
                ChosenWorkouts   = Workouts.Where(p => p.Category == BodyPart).ToList();
                IndexPagecount   = ChosenWorkouts.Count - 1;
                CurrentPageIndex = 0;
            }

            Workout = ChosenWorkouts[CurrentPageIndex];
        }
示例#7
0
        private string GetSuccesiveDays(Exercise exercise)
        {
            var lastWorkout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).LastOrDefault();

            if (lastWorkout == null)
            {
                return(string.Empty);
            }

            var currentWeight = lastWorkout.Weight;
            var workouts      = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderByDescending(x => x.Created);
            var count         = 0;

            foreach (var workout in workouts)
            {
                count++;
                if (workout.Weight != currentWeight)
                {
                    break;
                }
            }
            return(count.ToString());
        }
示例#8
0
        private string GetTotalWeight(Exercise exercise)
        {
            var total = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).Sum(x => x.Weight);

            return($"{WeightMetricToImperialConverter.GetWeight(total)} {L10n.GetWeightUnit()}");
        }
示例#9
0
 private string GetTotalReps(Exercise exercise)
 {
     return(Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).Sum(x => x.Reps).ToString());
 }
示例#10
0
 private string GetTrophiesLost(Exercise exercise)
 {
     return(Workouts.Where(x => x.ExerciseId == exercise.ExerciseId && x.Trophies < 0).Sum(x => x.Trophies).ToString());
 }
示例#11
0
        private string GetDaysSinceLastWorkout(Exercise exercise)
        {
            var lastWorkout = Workouts.Where(x => x.ExerciseId == exercise.ExerciseId).OrderBy(x => x.Created).LastOrDefault();

            return(lastWorkout == null ? string.Empty : Math.Truncate((DateTime.Now - lastWorkout.Created).TotalDays).ToString());
        }