public ActionResult Edit([Bind(Include = "ID,UserName,Tel,Address,Age,Sex")] UserMes user) { //if (ModelState.IsValid) //{ // db.Entry(user).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); //} //return View(user); try { var m = db.UserMess.Single(s => s.ID == user.ID); m.UserName = user.UserName; m.Tel = user.Tel; m.Sex = user.Sex; m.Address = user.Address; m.Age = user.Age; db.SaveChanges(); return(View("Edit", user)); } catch { return(View(user)); } }
public ActionResult DeleteConfirmed(int id) { UserMes user = db.UserMess.Find(id); db.UserMess.Remove(user); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserMes mes = db.UserMess.Find(id); if (mes == null) { return(HttpNotFound()); } return(View(mes)); }
// GET: Movies/Delete/5 public ActionResult Del(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserMes user = db.UserMess.Find(id); if (user == null) { return(HttpNotFound()); } return(View(user)); }
public ActionResult Register([Bind(Include = "ID,Email,PassWord,UserName,Tel,Address,Age,Sex")] UserMes user) { var num = db.UserMess.Where(s => s.Email == user.Email).Count(); if (num == 0) { if (ModelState.IsValid) { db.UserMess.Add(user); db.SaveChanges(); return(RedirectToAction("Index", "Login")); } } return(View()); }