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 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()); }