public ActionResult Create(User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
// // GET: /User/Create public ActionResult Create() { var model = new MvcWeb1.Models.User { UserName = @User.Identity.Name, DateUpdated = System.DateTime.Now }; if (db.Users.Where(c => c.UserName.Equals(@User.Identity.Name)).Count() > 0 ) { // Yoy can have only one identity @ViewBag.oneidentity = "You can have only one identity"; return RedirectToAction("Index"); } return View(model); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(user); }