예제 #1
0
        //Gets all workoutsession for a user
        public List <WorkoutSessionVM> GetAllWorkoutSessions(string userID)
        {
            List <WorkoutSessionVM> listOfWorkoutToReturn = new List <WorkoutSessionVM>();

            listOfWorkoutToReturn = WorkoutSession
                                    .Where(i => i.UserId == userID)
                                    .Select(w => new WorkoutSessionVM
            {
                Date            = w.Date,
                Distance        = w.Distance,
                Duration        = w.Duration,
                SessionName     = w.SessionName,
                SessionUserNote = w.SessionUserNote,
                Type            = w.Type,
                Exercises       =
                    w.Exercise.Select(
                        z => new ExerciseVM
                {
                    Name = z.ExerciseName,
                    Sets = z.Set.Select(
                        q => new SetVM {
                        Reps = q.Reps, UserComment = q.UserNote, Weight = Convert.ToInt32(q.UsedWeight)
                    }).ToList()
                }).ToList()
            })
                                    .OrderBy(c => c.Date)
                                    .ToList();
            return(listOfWorkoutToReturn);
        }
예제 #2
0
        public List <CalendarVM> GetCalendar(string userID)
        {
            var calandarList = WorkoutSession
                               .Where(i => i.UserId == userID)
                               .Select(c => new CalendarVM()
            {
                NameOfWorkoutSession = c.SessionName,
                TypeOfWorkoutSession = c.Type,
                Date = c.Date
            })
                               .OrderBy(c => c.Date)
                               .ToList();

            return(calandarList);
        }
예제 #3
0
        private StatisicsVM GetTotalDistanceDone(string userID)
        {
            var totalDistanceStat = WorkoutSession
                                    .Where(t => t.UserId == userID && t.Type == "Cardio")
                                    .Select(d => d.Distance)
                                    .Sum();

            StatisicsVM statToReturn = new StatisicsVM();

            statToReturn.TypeOfWorkoutSession = "Cardio";

            statToReturn.Stats = new TotalCardioDistansStat()
            {
                Distans = Convert.ToDouble(totalDistanceStat)
            };

            return(statToReturn);
        }
예제 #4
0
        private StatisicsVM GetTotalLiftetWeight(string userID)
        {
            var workOutSessions = WorkoutSession
                                  .Where(c => c.UserId == userID && c.Type == "Strength")
                                  .Select(x => x.Exercise
                                          .Select(y => y.Set.Sum(z => z.Reps * z.UsedWeight)))
                                  .Select(w => w.Sum())
                                  .Sum();

            StatisicsVM statToReturn = new StatisicsVM();

            statToReturn.TypeOfWorkoutSession = "Strength";

            statToReturn.Stats = new TotalStrengthStats()
            {
                TotalWeightLifted = workOutSessions
            };

            return(statToReturn);
        }
예제 #5
0
        private StatisicsVM GetCardioVsStr(string userID)
        {
            int [] countArray = new int [3];

            var countStrength = WorkoutSession
                                .Where(b => b.UserId == userID && b.Type == "Strength").Count();

            countArray[0] = countStrength;

            var countCardio = WorkoutSession
                              .Where(b => b.UserId == userID && b.Type == "Cardio").Count();

            countArray[1] = countCardio;


            var countOther = WorkoutSession
                             .Where(b => b.UserId == userID && b.Type == "Other").Count();

            countArray[2] = countOther;


            string [] namesArray = new string[3] {
                "Strength", "Cardio", "Other"
            };

            StatisicsVM statToReturn = new StatisicsVM();

            statToReturn.TypeOfWorkoutSession = "General";

            var data = new PieChartStat();

            data.Data          = countArray;
            data.Names         = namesArray;
            statToReturn.Stats = data;

            return(statToReturn);
        }