public ActionResult AssignmentDataBase(ConsumptionAssignmentViewModel vm)
        {
            int id = (int)Session["User"];

            if (!ModelState.IsValid)
            {
                vm.Consumptions = _context.Consumptions.Include(x => x.User).ToList().FindAll(x => x.User.Id.Equals(id)); //db.GetConsumptions((int)Session["User"]);
                vm.Foods        = _context.Foods.ToList();                                                                //db.GetFoods();
                return(View("Assignment", vm));
            }

            _context.CalorieViewModels.Add(new CalorieViewModel
            {
                ConsumedGramms = vm.Gramm,
                Consumption    = _context.Consumptions.SingleOrDefault(x => x.Id.Equals(vm.ConsumptionId)),
                Food           = _context.Foods.SingleOrDefault(x => x.Id.Equals(vm.FoodId))
            });
            _context.SaveChanges();

            return(RedirectToAction("ShowConsumptions"));

            //if (db.AssignConsumption(vm))
            //{
            //    ViewBag.Error = null;
            //    return RedirectToAction("ShowConsumptions");
            //}
            //else
            //{
            //    ViewBag.Error = "Adatbázis hiba történt!";
            //    return RedirectToAction("ShowConsumptions");
            //}
        }
        public ActionResult Assignment()
        {
            int id = (int)Session["User"];
            ConsumptionAssignmentViewModel viewModel = new ConsumptionAssignmentViewModel
            {
                Foods        = _context.Foods.ToList(),                                                                //db.GetFoods(),
                Consumptions = _context.Consumptions.Include(x => x.User).ToList().FindAll(x => x.User.Id.Equals(id)), //db.GetConsumptions((int)Session["User"]),
                Gramm        = 0
            };

            if (viewModel.Foods == null || viewModel.Consumptions == null)
            {
                return(HttpNotFound());
            }
            else
            {
                return(View(viewModel));
            }
        }