Beispiel #1
0
        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));
            }
        }
Beispiel #2
0
        public ActionResult PostNewMeal(MealType newMealType, int[] arrFoodItemIDs, int intPassedUserID, int intPassedCurrentDayID)
        {
            List <FoodItem> lstContents = FoodItemDAL.GetFoodItemsByIDs(arrFoodItemIDs);
            Meal            newMeal     = Meal.of(newMealType, lstContents);

            bool success = MealDAL.AddMeal(newMeal, intPassedUserID, intPassedCurrentDayID);

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #3
0
        public ActionResult DeleteMeal(Meal meal, int intDayID, int intUserID)
        {
            FoodVM model = new FoodVM()
            {
                LstMealsForDay = MealDAL.GetMealsByDayAndUser(intDayID, intUserID).Where(m => m != meal)
            };

            return(View("Food", model));
        }
Beispiel #4
0
        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));
            }
        }
Beispiel #5
0
 public MealController(IConfiguration _configuration)
 {
     mealDAL = new MealDAL(_configuration);
 }