コード例 #1
0
        public ActionResult Create(Routine routine)
        {
            if (ModelState.IsValid)
            {
                db.Routines.Add(routine);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.UserId = new SelectList(db.Users, "UserId", "Email", routine.UserId);
            ViewBag.TypeId = new SelectList(db.Types, "TypeId", "Name", routine.TypeId);
            return View(routine);
        }
コード例 #2
0
 public ActionResult Edit(Routine routine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(routine).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.UserId = new SelectList(db.Users, "UserId", "Email", routine.UserId);
     ViewBag.TypeId = new SelectList(db.Types, "TypeId", "Name", routine.TypeId);
     return View(routine);
 }