private static User GetUserFromDR(NpgsqlDataReader dr) { int intUserID = Convert.ToInt32(dr["intUserID"]); string strUsername = dr["strUsername"].ToString(); int intWeight = Convert.ToInt32(dr["intWeight"]); int intHeightInInches = Convert.ToInt32(dr["intHeightInInches"]); string strExerciseLevel = dr["exerciseLevel"].ToString(); ExerciseLevel exerciseLevel = ExerciseLevel.LowIntensity; switch (strExerciseLevel) { case "low": exerciseLevel = ExerciseLevel.LowIntensity; break; case "med": exerciseLevel = ExerciseLevel.MediumIntensity; break; case "high": exerciseLevel = ExerciseLevel.HighIntensity; break; } //ExerciseLevel exerciseLevel = (ExerciseLevel)Enum.Parse(typeof(ExerciseLevel), strExerciseLevel, true); int intAllotedCalories = Convert.ToInt32(dr["intAllotedCalories"]); int intAllotedExerciseMinutes = Convert.ToInt32(dr["intAllotedExerciseMinutes"]); List <Day> lstHistory = DayDAL.GetDaysByUser(intUserID).ToList(); User user = User.of(intUserID, strUsername, intWeight, intHeightInInches, exerciseLevel, intAllotedCalories, intAllotedExerciseMinutes, lstHistory); return(user); }
public double CalculateDailyCaloricIntake(double bmr, ExerciseLevel exerciseLevel) { double activityModifier = 0.0; switch (exerciseLevel) { case ExerciseLevel.Sedentary: activityModifier = bmr * 0.2; break; case ExerciseLevel.LightlyActive: activityModifier = bmr * 0.375; break; case ExerciseLevel.ModeratelyActive: activityModifier = bmr * 0.55; break; case ExerciseLevel.VeryActive: activityModifier = bmr * 0.725; break; case ExerciseLevel.ExtraActive: activityModifier = bmr * 0.9; break; default: throw new ArgumentException("invalid exercise level provided.", "exerciseLevel"); } return(bmr + activityModifier); }
/// <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; } }
private int CalculateCalories(int intWeight, int intHeightInInches, int intAge, ExerciseLevel exerciseLevel) { double BMR = 655 + (4.3 * intWeight) + (4.7 * intHeightInInches) - (4.7 * intAge); switch (exerciseLevel) { case ExerciseLevel.LowIntensity: BMR *= 1.375; break; case ExerciseLevel.MediumIntensity: BMR *= 1.55; break; case ExerciseLevel.HighIntensity: BMR *= 1.725; break; } return((int)BMR); }
public static User of(int intUserID, string strUsername, int intWeight, int intHeightInInches, ExerciseLevel exerciseLevel, int intAllotedCalories, int intAllotedExerciseMinutes, List <Day> lstHistory) { return(new User(intUserID, strUsername, intWeight, intHeightInInches, exerciseLevel, intAllotedCalories, intAllotedExerciseMinutes, lstHistory)); }
private User(int intUserID, string strUsername, int intWeight, int intHeightInInches, ExerciseLevel exerciseLevel, int intAllotedCalories, int intAllotedExerciseMinutes, List <Day> lstHistory) { this.intUserID = intUserID; this.strUsername = strUsername; this.intWeight = intWeight; this.intHeightInInches = intHeightInInches; this.exerciseLevel = exerciseLevel; this.intAllotedCalories = intAllotedCalories; this.intAllotedExerciseMinutes = intAllotedExerciseMinutes; this.lstHistory = lstHistory; }