public ActionResult Create([Bind(Include = "ID,城市,编号,电话,保证金,完成度")] Citytel citytel) { if (ModelState.IsValid) { if (!string.IsNullOrEmpty(citytel.城市) && !string.IsNullOrWhiteSpace(citytel.城市)) { citytel.城市 = citytel.城市.Trim(); } if (!string.IsNullOrEmpty(citytel.编号) && !string.IsNullOrWhiteSpace(citytel.编号)) { citytel.编号 = citytel.编号.Trim(); } if (!string.IsNullOrEmpty(citytel.电话) && !string.IsNullOrWhiteSpace(citytel.电话)) { citytel.电话 = citytel.电话.Trim(); } if (string.IsNullOrEmpty(citytel.保证金.ToString().Trim()) && string.IsNullOrWhiteSpace(citytel.保证金.ToString().Trim())) { citytel.保证金 = Convert.ToInt64(0.0); } citytel.完成度 = "2"; db.Citytels.Add(citytel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(citytel)); }
public ActionResult DeleteConfirmed(long id) { Citytel citytel = db.Citytels.Find(id); db.Citytels.Remove(citytel); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Setting/Sites/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Citytel citytel = db.Citytels.Find(id); if (citytel == null) { return(HttpNotFound()); } return(View(citytel)); }