コード例 #1
0
 public ActionResult Edit(Hobbies hobbies)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hobbies).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(hobbies);
 }
コード例 #2
0
        public ActionResult Create(Hobbies hobbies)
        {
            if (ModelState.IsValid)
            {
                db.Hobbies.Add(hobbies);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(hobbies);
        }