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

            return(View(army));
        }
コード例 #2
0
        public ActionResult AddMore([Bind(Include = "Id,Name,Count,ArmyId")] WebUI.DBEntities.Type type, int number)
        {
            if (ModelState.IsValid)
            {
                for (int i = 0; i < number; i++)
                {
                    db.Types.Add(type);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.ArmyId = new SelectList(db.Armys, "Id", "Name", type.ArmyId);
            return(View(type));
        }