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

            db.passes_through.Remove(passes_through);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        // GET: /PassesThrough/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            passes_through passes_through = db.passes_through.Find(id);

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

            if (passes_through == null)
            {
                return(HttpNotFound());
            }
            ViewBag.location_id = new SelectList(db.locations, "location_id", "location_name", passes_through.location_id);
            ViewBag.route_id    = new SelectList(db.routes, "route_id", "source", passes_through.route_id);
            return(View(passes_through));
        }
コード例 #4
0
 public ActionResult Create([Bind(Include = "passes_through_id,route_id,location_id,order_no,time_to_reach")] passes_through passes_through)
 {
     if (ModelState.IsValid)
     {
         db.passes_through.Add(passes_through);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.location_id = new SelectList(db.locations, "location_id", "location_name", passes_through.location_id);
     // ViewBag.route_id = new SelectList(db.routes, "route_id", "source", passes_through.route_id);
     ViewBag.route_id = from r in db.routes.ToList()
                        select new
     {
         id          = r.route_id,
         about_route = r.source + " - " + r.destination
     };
     return(View(passes_through));
 }
コード例 #5
0
        public ActionResult Edit([Bind(Include = "passes_through_id,route_id,location_id,order_no,time_to_reach")] passes_through passes_through)
        {
            if (ModelState.IsValid)
            {
                db.Entry(passes_through).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            /*  ViewBag.location_id = new SelectList(db.locations, "location_id", "location_name", passes_through.location_id);
             * ViewBag.route_id = new SelectList(db.routes, "route_id", "source", passes_through.route_id);*/
            var sad = db.routes
                      .Select(s => new
            {
                Description = string.Format("{0}-- £{1}", s.source, s.destination)
            })
                      .ToList();

            ViewBag.location_id = new SelectList(db.locations, "location_id", "location_name");
            ViewBag.route_id    = new SelectList(sad, "route_id", "Description");
            return(View(passes_through));
        }