コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Townships townships = db.Townships.Find(id);

            db.Townships.Remove(townships);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "Id,TownshipName,DepartmentId")] Townships townships)
 {
     if (ModelState.IsValid)
     {
         db.Entry(townships).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentName", townships.DepartmentId);
     return(View(townships));
 }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Id,TownshipName,DepartmentId")] Townships townships)
        {
            if (ModelState.IsValid)
            {
                db.Townships.Add(townships);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentName", townships.DepartmentId);
            return(View(townships));
        }
コード例 #4
0
        // GET: Townships/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Townships townships = db.Townships.Find(id);

            if (townships == null)
            {
                return(HttpNotFound());
            }
            return(View(townships));
        }
コード例 #5
0
        // GET: Townships/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Townships townships = db.Townships.Find(id);

            if (townships == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentName", townships.DepartmentId);
            return(View(townships));
        }