示例#1
0
 static void AddExersice(string name, int muslegroupid)
 {
     using (var db = new GymTrackerContext())
     {
         var newExersice = new Exercise()
         {
             ExerciseName  = name,
             MuscleGroupId = muslegroupid
         };
         db.Exercises.Add(newExersice);
         db.SaveChanges();
     }
 }
示例#2
0
 static void AddSession(int user, int exersice, string date)
 {
     using (var db = new GymTrackerContext())
     {
         var newSession = new Session()
         {
             UserId      = user,
             ExerciseId  = exersice,
             SessionDate = date
         };
         db.Sessions.Add(newSession);
         db.SaveChanges();
     }
 }
示例#3
0
 static void AddSets(int sessionid, int setnumber, int numofreps, int weight)
 {
     using (var db = new GymTrackerContext())
     {
         var newSet = new Set()
         {
             SessionId    = sessionid,
             SetNumber    = setnumber,
             NumberofReps = numofreps,
             Weight       = weight
         };
         db.Sets.Add(newSet);
         db.SaveChanges();
     }
 }
示例#4
0
        static List <string> ReadExercise(int userid)
        {
            using (var db = new GymTrackerContext())
            {
                List <string> allExercises  = new List <string>();
                var           userExercises =
                    from s in db.Sessions
                    join e in db.Exercises on s.ExerciseId equals e.ExerciseId
                    where s.UserId == userid
                    select new { e.ExerciseName };

                foreach (var Exercises in userExercises)
                {
                    allExercises.Add(Exercises.ExerciseName);
                }
                return(allExercises);
            }
        }
示例#5
0
        static (List <string>, List <int>) SWOverview(int userid)
        {
            using (var db = new GymTrackerContext())
            {
                List <string> Dates       = new List <string>();
                List <int>    MuscleGroup = new List <int>();

                var allSessions =
                    from s in db.Sessions
                    join e in db.Exercises on s.ExerciseId equals e.ExerciseId
                    where s.UserId == userid
                    select new { s.SessionDate, e.MuscleGroupId };

                foreach (var item in allSessions)
                {
                    Dates.Add(item.SessionDate);
                    MuscleGroup.Add(item.MuscleGroupId);
                }

                return(Dates, MuscleGroup);
            }
        }