public IActionResult AddFoodIntakeDetails(DateTime date, int mealId)
        {
            var food  = new FoodIntakeDetailsModel();
            var model = foodIntakeList.Where(m => m.Date.Date == date.Date).FirstOrDefault();

            ViewBag.Date = Common.GetDayName(date);
            food.MealId  = mealId;
            switch (mealId)
            {
            case 1:
                food.Main    = model.Breakfast.Where(m => m.FoodTypeId == 1).FirstOrDefault();
                food.Side    = model.Breakfast.Where(m => m.FoodTypeId == 2).FirstOrDefault();
                ViewBag.Meal = "Breakfast";
                break;

            case 2:
                food.Main    = model.Lunch.Where(m => m.FoodTypeId == 1).FirstOrDefault();
                food.Side    = model.Lunch.Where(m => m.FoodTypeId == 2).FirstOrDefault();
                ViewBag.Meal = "Lunch";
                break;

            case 3:
                food.Main    = model.Dinner.Where(m => m.FoodTypeId == 1).FirstOrDefault();
                food.Side    = model.Dinner.Where(m => m.FoodTypeId == 2).FirstOrDefault();
                ViewBag.Meal = "Dinner";
                break;
            }
            return(View(food));
        }
        public IActionResult FoodIntakeDetails(DateTime date, int mealId)
        {
            var model = foodIntakeList.Where(m => m.Date.Date == date.Date).FirstOrDefault();

            ViewBag.Date         = Common.GetDayName(date);
            ViewBag.ProfileImage = HttpContext.Session.GetString("Photo");
            var food      = new FoodIntakeDetailsModel();
            var name      = HttpContext.Session.GetString("Name");
            var firstName = name.Substring(0, name.IndexOf(" "));

            food.MealId = mealId;
            switch (mealId)
            {
            case 1:
                food.Main    = model.Breakfast.Where(m => m.FoodTypeId == 1).FirstOrDefault();
                food.Side    = model.Breakfast.Where(m => m.FoodTypeId == 2).FirstOrDefault();
                food.Summary = string.Format("{0} eat well today as normal", firstName);
                ViewBag.Meal = "Breakfast";
                break;

            case 2:
                food.Main    = model.Lunch.Where(m => m.FoodTypeId == 1).FirstOrDefault();
                food.Side    = model.Lunch.Where(m => m.FoodTypeId == 2).FirstOrDefault();
                food.Summary = string.Format("{0} eat well today as normal", firstName);
                ViewBag.Meal = "Lunch";
                break;

            case 3:
                food.Main    = model.Dinner.Where(m => m.FoodTypeId == 1).FirstOrDefault();
                food.Side    = model.Dinner.Where(m => m.FoodTypeId == 2).FirstOrDefault();
                food.Summary = string.Format("{0} eat well today as normal", firstName);
                ViewBag.Meal = "Dinner";
                break;
            }

            ViewBag.MainCount  = food.Main.PercentageAmount;
            ViewBag.SideCount  = food.Side.PercentageAmount;
            ViewBag.TotalCount = (food.Main.PercentageAmount + food.Side.PercentageAmount) / 2;

            ViewBag.MainColour  = GetColourString((int)food.Main.PercentageAmount);
            ViewBag.SideColour  = GetColourString((int)food.Side.PercentageAmount);
            ViewBag.TotalColour = GetColourString((int)(food.Main.PercentageAmount + food.Side.PercentageAmount) / 2);

            return(View(food));
        }
        public IActionResult AddedFoodIntake(FoodIntakeDetailsModel model)
        {
            var foodIntake = foodIntakeList.Where(m => m.Date.Date == DateTime.Now.Date).FirstOrDefault();

            if (0 > model.Main.PercentageAmount && model.Main.PercentageAmount < 100)
            {
                ModelState.AddModelError("Main.PercentageAmount", "Please enter a number between 0 and 100");
            }
            if (0 > model.Side.PercentageAmount && model.Side.PercentageAmount < 100)
            {
                ModelState.AddModelError("Side.PercentageAmount", "Please enter a number between 0 and 100");
            }
            if (model.Main.PercentageAmount == null)
            {
                ModelState.AddModelError("Main.PercentageAmount", "Please enter a number between 0 and 100");
            }
            if (model.Side.PercentageAmount == null)
            {
                ModelState.AddModelError("Side.PercentageAmount", "Please enter a number between 0 and 100");
            }
            if (string.IsNullOrEmpty(model.Summary))
            {
                ModelState.AddModelError("Summary", "Please enter a summary");
            }

            if (!ModelState.IsValid)
            {
                return(View("AddFoodIntakeDetails", model));
            }

            switch (model.MealId)
            {
            case 1:
                foodIntake.Breakfast = new List <FoodModel>();
                foodIntake.Breakfast.Add(model.Main);
                foodIntake.Breakfast.Add(model.Side);
                break;

            case 2:
                foodIntake.Lunch = new List <FoodModel>();
                foodIntake.Lunch.Add(model.Main);
                foodIntake.Lunch.Add(model.Side);
                break;

            case 3:
                foodIntake.Dinner = new List <FoodModel>();
                foodIntake.Dinner.Add(model.Main);
                foodIntake.Dinner.Add(model.Side);
                break;
            }

            var user = HttpContext.Session.GetString("UserType");

            ViewBag.IsStaff = user.Equals("staff");

            ViewBag.IsSubmitted = false;
            ViewBag.DayCount    = 0;
            ViewBag.CurrentDay  = Helper.Common.GetDayName(DateTime.Now.Date);

            int breakfast = (int)(foodIntake.Breakfast[0].PercentageAmount + foodIntake.Breakfast[1].PercentageAmount) / 2;
            int lunch     = (int)(foodIntake.Lunch[0].PercentageAmount + foodIntake.Lunch[1].PercentageAmount) / 2;
            int dinner    = (int)(foodIntake.Dinner[0].PercentageAmount + foodIntake.Dinner[1].PercentageAmount) / 2;

            ViewBag.BreakfastCount = (foodIntake.Breakfast[0].PercentageAmount + foodIntake.Breakfast[1].PercentageAmount) / 2;
            ViewBag.LunchCount     = (foodIntake.Lunch[0].PercentageAmount + foodIntake.Lunch[1].PercentageAmount) / 2;
            ViewBag.DinnerCount    = (foodIntake.Dinner[0].PercentageAmount + foodIntake.Dinner[1].PercentageAmount) / 2;
            ViewBag.SnackCount     = 0;

            ViewBag.BreakfastColour = GetColourString(breakfast);
            ViewBag.LunchColour     = GetColourString(lunch);
            ViewBag.DinnerColour    = GetColourString(dinner);

            return(View("Food", foodIntake));
        }