コード例 #1
0
        public ActionResult Create([Bind(Include = "ID,Name")] Genre Genre)
        {
            if (ModelState.IsValid)
            {
                db.Add <Genre>(Genre);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View("Create", Genre));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "ID,GenreID,Name")] Game Game)
        {
            if (ModelState.IsValid)
            {
                db.Add <Game>(Game);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.GenreID = new SelectList(db.Genres, "ID", "Name", Game.GenreID);
            return(View("Create", Game));
        }