static void AddUser(string name) { using (var db = new GymTrackerContext()) { var newUser = new User() { UserName = name }; db.Users.Add(newUser); db.SaveChanges(); } }
static List <string> ReadMuscleGroups() { using (var db = new GymTrackerContext()) { List <string> allMusclegroups = new List <string>(); foreach (var user in db.MuscleGroups) { allMusclegroups.Add(user.MuscleGroupName); } return(allMusclegroups); } }
static List <string> ReadExercise() { using (var db = new GymTrackerContext()) { List <string> allExercises = new List <string>(); foreach (var user in db.Exercises) { allExercises.Add(user.ExerciseName); } return(allExercises); } }
static List <string> ReadUser() { using (var db = new GymTrackerContext()) { List <string> allUsers = new List <string>(); foreach (var user in db.Users) { allUsers.Add(user.UserName); } return(allUsers); } }
static void AddSession(int user, int exersice, string date) { using (var db = new GymTrackerContext()) { var newSession = new Session() { ExerciseId = exersice, }; db.Sessions.Add(newSession); db.SaveChanges(); } }
static void AddMuscleGroup(string name) { using (var db = new GymTrackerContext()) { var newMuscleGroup = new MuscleGroup() { MuscleGroupName = name }; db.MuscleGroups.Add(newMuscleGroup); db.SaveChanges(); } }
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(); } }
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(); } }
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); } }