Exemple #1
0
 public ActionResult CreateEaten(EatenViewModel eaten)
 {
     if (ModelState.IsValid)
     {
         eaten.profileId = GetUserId();
         eatenModel.AddEaten(eaten);
         return RedirectToAction("Index", "Eaten");
     }
     ViewBag.Foods = foodModel.Foods();
     return View(eaten);
 }
Exemple #2
0
        public void AddEaten(EatenViewModel eaten)
        {
            DateTime date = DateTime.Now;
            Eaten newEaten = new Eaten()
            {
                foodId = eaten.foodId,
                profileId = eaten.profileId,
                date = date
            };

            db.Eaten.Add(newEaten);
            db.SaveChanges();
        }