Example #1
0
        public ActionResult InputDetails(FoodInputViewModel foodItem)
        {
            var             userName = User.Identity.GetUserName();
            var             user     = _context.Users.Where(x => x.UserName == userName).First();
            FoodInputModels item     = new FoodInputModels();

            item.UserId    = user.Id;
            item.FoodName  = foodItem.FoodName;
            item.Calories  = foodItem.Calories;
            item.Fat       = foodItem.Fat;
            item.Carb      = foodItem.Carb;
            item.Protien   = foodItem.Protien;
            item.DateAdded = DateTime.Today;
            _context.FoodInput.Add(item);
            _context.SaveChanges();
            item.TableId = item.Id;
            _context.SaveChanges();

            return(RedirectToAction("Index", "CalorieCounter"));
        }
Example #2
0
        public ActionResult InputDetails()
        {
            FoodInputViewModel foodItem = new FoodInputViewModel();

            return(View(foodItem));
        }