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 ActionResult AddWorkout() { if (HomeController.USER_NUMBER == -1) { return(RedirectToAction("NewUser", "Home")); } else { User user = UserDAL.GetUser(HomeController.USER_NUMBER); Day currentDay = DayDAL.GetDayByUserAndDay(user.intUserID); AddWorkoutVM model = new AddWorkoutVM { user = user, currentDayForUser = currentDay, intPassedCurrentDayID = currentDay.intDayID, intPassedUserID = user.intUserID }; model._results_vm.possibleExercises = new List <ExerciseType>(); bool hasAny = model._results_vm.possibleExercises.Any(); return(View(model)); } }
public ActionResult Index() { var mvcName = typeof(Controller).Assembly.GetName(); var isMono = Type.GetType("Mono.Runtime") != null; if (USER_NUMBER == -1) { return(RedirectToAction("NewUser")); } else { Day currentDayForUser = DayDAL.GetDayByUserAndDay(USER_NUMBER); User user = UserDAL.GetUser(USER_NUMBER); USER_NUMBER = user.intUserID; DAY_NUMBER = currentDayForUser.intDayID; HomeVM model = new HomeVM { user = user, intCalsLeft = currentDayForUser.intCalsLeft, intExMinsLeft = currentDayForUser.intExMinsLeft, mostRecentMeals = MealDAL.GetMealsByDayAndUser(currentDayForUser.intDayID, user.intUserID).Take(NUM_PREVIEWS).ToList(), mostRecentWorkouts = WorkoutRoutineDAL.GetWorkoutsByDayAndUser(currentDayForUser.intDayID, user.intUserID).Take(NUM_PREVIEWS).ToList() }; return(View(model)); } }
public ActionResult WorkoutHome() { if (HomeController.USER_NUMBER == -1) { return(RedirectToAction("NewUser", "Home")); } else { User user = UserDAL.GetUser(HomeController.USER_NUMBER); Day day = DayDAL.GetDayByUserAndDay(user.intUserID); WorkoutHomeVM model = new WorkoutHomeVM() { user = user, LstWorkoutRoutines = WorkoutRoutineDAL.GetWorkoutsByDayAndUser(day.intDayID, user.intUserID) }; return(View(model)); } }
public ActionResult FoodHome() { if (HomeController.USER_NUMBER == -1) { return(RedirectToAction("NewUser", "Home")); } else { User user = UserDAL.GetUser(HomeController.USER_NUMBER); Day day = DayDAL.GetDayByUserAndDay(user.intUserID); FoodVM model = new FoodVM() { user = user, LstMealsForDay = MealDAL.GetMealsByDayAndUser(day.intDayID, user.intUserID) }; return(View("FoodHome", model)); } }
public ActionResult AddMeal() { if (HomeController.USER_NUMBER == -1) { return(RedirectToAction("NewUser", "Home")); } else { User user = UserDAL.GetUser(HomeController.USER_NUMBER); Day currentDay = DayDAL.GetDayByUserAndDay(user.intUserID); AddMealVM model = new AddMealVM { user = user, currentDayForUser = currentDay, possibleFoodItems = FoodItemDAL.GetAllFoodItems(), intPassedCurrentDayID = currentDay.intDayID, intPassedUserID = user.intUserID }; return(View(model)); } }