public ActionResult DeleteConfirmed(int id) { Freeway Freeway = db.Freeways.Single(r => r.FreewayID == id); db.Freeways.DeleteOnSubmit(Freeway); db.SubmitChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { Freeway freeway = await db.Freeways.FindAsync(id); db.Freeways.Remove(freeway); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// // GET: /AdminArea/Freeways/Edit/5 public ActionResult Edit(int id) { Freeway Freeway = db.Freeways.Single(r => r.FreewayID == id); if (Freeway == null) { return(HttpNotFound()); } return(View(Freeway)); }
public async Task <ActionResult> Edit([Bind(Include = "FreewayID,FreewayName")] Freeway freeway) { if (ModelState.IsValid) { db.Entry(freeway).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(freeway)); }
public async Task <ActionResult> Create([Bind(Include = "FreewayID,FreewayName")] Freeway freeway) { if (ModelState.IsValid) { db.Freeways.Add(freeway); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(freeway)); }
public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Freeway freeway = await db.Freeways.FindAsync(id); if (freeway == null) { return(HttpNotFound()); } return(View(freeway)); }
public ActionResult Create(Freeway Freeway) { if (ModelState.IsValid) { if (db.Freeways.Any(p => p.FreewayID == Freeway.FreewayID) == false) { //if Freeway does not exist yet db.Freeways.InsertOnSubmit(Freeway); db.SubmitChanges(); } return(RedirectToAction("Index")); } return(View(Freeway)); }
public ActionResult Edit(Freeway Freeway) { try { if (ModelState.IsValid) { db.Freeways.Attach(Freeway); db.Refresh(RefreshMode.KeepCurrentValues, Freeway); db.SubmitChanges(); return(RedirectToAction("Index")); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(View(Freeway)); }
public static void createStreet(StreetType type_of_street) { int[] street_data = StreetHelper.pickStreet(type_of_street); // Pedestrian Pathway if (type_of_street == StreetType.PedestrianPathway) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = PedestrianPathWay.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Pedestrian Pathway else if (type_of_street == StreetType.DirtRoad) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = DirtRoad.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // TwoLaneStreet else if (type_of_street == StreetType.TwoLaneStreet) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = TwoLaneStreet.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // FourLaneStreet else if (type_of_street == StreetType.FourLaneStreet) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = FourLaneStreet.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Avenue else if (type_of_street == StreetType.Avenue) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = Avenue.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // DenseAvenue else if (type_of_street == StreetType.DenseAvenue) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = DenseAvenue.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // AvenuePlusTrain else if (type_of_street == StreetType.AvenuePlusTrain) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = AvenuePlusTrain.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // ParkWay else if (type_of_street == StreetType.ParkWay) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = ParkWay.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Freeway else if (type_of_street == StreetType.Freeway) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = Freeway.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // Ramp else if (type_of_street == StreetType.Ramp) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = Ramp.CreateComponent(street_obj, (StreetDirection)street_data[1]); } // PreBuilt else if (type_of_street == StreetType.PreBuilt) { prefab = Resources.Load(StreetUtils.getStreetPath(street_data[0])) as GameObject; street_obj = GameObject.Instantiate(prefab) as GameObject; new_street = PreBuilt.CreateComponent(street_obj, (StreetDirection)street_data[1]); } else { throw new NoSuchTypeException("Street Type not found"); } }