public ActionResult Create(User user) { if (ModelState.IsValid) { db.User.Add(user); db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
// // GET: /User/ public ActionResult Index() { User user = new User(); user.CreateTime = DateTime.Now; user.Email = "*****@*****.**"; user.ID = 1; user.Password = "******"; user.Telephone = "1234565789"; user.UserName = "******"; List<User> list = new List<User>(); list.Add(user); ViewData.Model = list; return View(); // return View(db.User.ToList()); }