public bool addNewExerciseGoal(int weight, double distance, int time, int reps, string userName, string exerciseName) { bool rc = false; using (var context = new Layer2Container()) { try { ExerciseGoal newExerciseGoal = new ExerciseGoal(); Exercise exercise = context.Exercises.Where(s => s.name == exerciseName).FirstOrDefault(); LimitBreaker user = context.LimitBreakers.Where(s => s.username == userName).FirstOrDefault(); newExerciseGoal.LimitBreaker = user; newExerciseGoal.Exercise = exercise; newExerciseGoal.weight = weight; newExerciseGoal.distance = distance; newExerciseGoal.time = time; newExerciseGoal.reps = reps; context.ExerciseGoals.AddObject(newExerciseGoal); context.SaveChanges(); rc = true; } catch (Exception ex) { Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace); } } return rc; }
/// <summary> /// Fills in UserProfile Class information. /// </summary> private void readProfileInfo() { this._startOfWeek = Convert.ToDateTime(_xmlFile.SelectSingleNode(@"User/StartOfWeek").InnerText); this._firstName = _xmlFile.SelectSingleNode(@"User/FirstName").InnerText.Trim(); this._lastName = _xmlFile.SelectSingleNode(@"User/LastName").InnerText.Trim(); this._username = _xmlFile.SelectSingleNode(@"User/Username").InnerText.Trim(); this._age = Int32.Parse(_xmlFile.SelectSingleNode(@"User/Age").InnerText.Trim()); this._height = Int32.Parse(_xmlFile.SelectSingleNode(@"User/Height").InnerText.Trim()); this._weight = Int32.Parse(_xmlFile.SelectSingleNode(@"User/Weight").InnerText.Trim()); this._exerciseLevel = (ExerciseLevel)Int32.Parse(_xmlFile.SelectSingleNode(@"User/ExerciseLevel").InnerText.Trim()); if (_xmlFile.SelectSingleNode(@"User/ExerciseGoal").InnerText.Trim() == "Weight_Loss") { this._exerciseGoal = ExerciseGoal.Weight_Loss; } else if (_xmlFile.SelectSingleNode(@"User/ExerciseGoal").InnerText.Trim() == "Strength_Gain") { this._exerciseGoal = ExerciseGoal.Strength; } else { this._exerciseGoal = ExerciseGoal.Tone; } if (_xmlFile.SelectSingleNode(@"User/Plan").InnerText.Trim() == "True") { this._planCreated = true; } else { this._planCreated = false; } }
public bool achieveGoal(ExerciseGoal eg, int reps, int time, int weight, double distance) { bool achieved = false; if (reps >= eg.reps && time >= eg.time && weight >= eg.weight && distance >= eg.distance) { using (var context = new Layer2Container()) { ExerciseGoal saveGoal = context.ExerciseGoals.Where(s => s.id == eg.id).FirstOrDefault(); saveGoal.achieved = true; context.SaveChanges(); achieved = true; } } return achieved; }
public static WorkOutGoal FormatWorkOutGoal(string name, ExerciseGoal exercise_1, ExerciseGoal exercise_2, ExerciseGoal exercise_3) { return(new WorkOutGoal { WorkOutName = name, Exercise_1 = exercise_1, Exercise_2 = exercise_2, Exercise_3 = exercise_3 }); }