Пример #1
0
 public WorkoutItem(mpObject data)
 {
     uuid       = ((mpValue)data.getChild("uuid")).data.asString();
     ex         = Exercise.getByName(((mpValue)((mpObject)data.getChild("exercise")).getChild("name")).data.asString());
     difficulty = ((mpValue)data.getChild("difficulty")).data.asInt();
     sets       = new List <WorkoutSet>();
     oneRepMax  = ((mpValue)data.getChild("onerepmax")).data.asDouble();
     foreach (mpObject set in ((mpArray)data.getChild("sets")))
     {
         sets.Add(new WorkoutSet(set));
     }
 }
Пример #2
0
        private void LoadWorkoutsAfter(DateTime start)
        {
            QueryResult days = db.query("SELECT * FROM workoutdays WHERE associateduser='******' AND workoutdate>='" + Util.DateStringFormat(start) + "';");

            for (int i = 0; i < days.Rows; i++)
            {
                this.oldDays.Add(new WorkoutSession {
                    workoutItems   = new List <WorkoutItem> {
                    },
                    primaryGroup   = days.GetField("primarygroup", i).asString(),
                    secondaryGroup = days.GetField("secondarygroup", i).asString(),
                    date           = days.GetField("workoutdate", i).asDate(),
                    uuid           = days.GetField("uuid", i).asString()
                });
            }

            foreach (WorkoutSession d in oldDays)
            {
                QueryResult items = db.query("SELECT * FROM workoutitems WHERE associatedday ='" + d.uuid + "';");

                for (int i = 0; i < items.Rows; i++)
                {
                    Exercise exercise     = null;
                    string   uuid         = items.GetField("uuid", i).asString();
                    string   exercisename = items.GetField("exercisename", i).asString();

                    exercise = Exercise.getByName(exercisename);

                    QueryResult       setQuery     = db.query("SELECT * FROM workoutsets WHERE associateditem ='" + uuid + "';");
                    List <WorkoutSet> exerciseSets = new List <WorkoutSet>();
                    for (int j = 0; j < setQuery.Rows; j++)
                    {
                        exerciseSets.Add(new WorkoutSet {
                            uuid          = setQuery.GetField("uuid", j).asString(),
                            percent1RM    = setQuery.GetField("percent1rm", j).asInt(),
                            reps          = setQuery.GetField("reps", j).asInt(),
                            restTime      = TimeSpan.FromSeconds((float)setQuery.GetField("resttime", j).asDouble()),
                            repsCompleted = setQuery.GetField("feedbackreps", j).asInt()
                        });
                    }

                    d.workoutItems.Add(new WorkoutItem {
                        uuid       = uuid,
                        ex         = exercise,
                        sets       = exerciseSets,
                        difficulty = items.GetField("difficulty", i).asInt()
                    });
                }
            }
        }