Ejemplo n.º 1
0
        public ActionResult About()
        {
            string          currentUserId;
            ApplicationUser currentUser;

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                currentUserId = User.Identity.GetUserId();
                currentUser   = db.Users.FirstOrDefault(x => x.Id == currentUserId);
            }
            // List<UsersFruits>[] fruitsBreakfast = _usersFruitsRepository.GetUserFruitsMeals(currentUserId);
            AboutViewModel aboutViewModel = new AboutViewModel();

            aboutViewModel.NutritionBreakfast = _usersFruitsRepository.CountCaloriesBreakfast(currentUserId).ToList();
            aboutViewModel.NutritionLunch     = _usersFruitsRepository.CountCaloriesLunch(currentUserId).ToList();
            aboutViewModel.NutritionDinner    = _usersFruitsRepository.CountCaloriesDinner(currentUserId).ToList();
            aboutViewModel.NutritionSnacks    = _usersFruitsRepository.CountCaloriesSnacks(currentUserId).ToList();
            aboutViewModel.NutritionBurn      = _usersBurnsRepository.CountCalories(currentUserId).ToList();
            aboutViewModel.UserId             = currentUserId;

            BurnsUserBurnsViewModel BurnsUserBurns = new BurnsUserBurnsViewModel();

            BurnsUserBurns.UserId     = currentUserId;
            BurnsUserBurns.Burns      = _burnsRepository.GetBurn();
            BurnsUserBurns.UsersBurns = _usersburnsRepository.GetUserBurns(currentUserId);

            Together together         = new Together();
            var      fruitsUserFruits = new FruitsUserFruitsViewModel();

            fruitsUserFruits.UserId = currentUserId;
            fruitsUserFruits.Fruits = _fruitsRepository.GetFruit();
            fruitsUserFruits.UsersFruitsBreakfast = _usersFruitsRepository.GetUserFruitsMeals(currentUserId)[0];
            fruitsUserFruits.UsersFruitsLunch     = _usersFruitsRepository.GetUserFruitsMeals(currentUserId)[1];
            fruitsUserFruits.UsersFruitsDinner    = _usersFruitsRepository.GetUserFruitsMeals(currentUserId)[2];
            fruitsUserFruits.UsersFruitsSnacks    = _usersFruitsRepository.GetUserFruitsMeals(currentUserId)[3];
            fruitsUserFruits.UsersFruitsAll       = _usersFruitsRepository.GetUserFruitsMeals(currentUserId)[4];
            together.AboutViewModel            = aboutViewModel;
            together.FruitsUserFruitsViewModel = fruitsUserFruits;
            together.BurnsUserBurnsViewModel   = BurnsUserBurns;
            return(View(together));
        }
 public IHttpActionResult Get()
 {
     return(Ok(_fruitRepository.GetFruit()));
 }
Ejemplo n.º 3
0
        public ActionResult Index()
        {
            var fruits = _fruitsRepository.GetFruit();

            return(View(fruits));
        }