public ActionResult Edit(User user) { try { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } } catch(DataException) { ModelState.AddModelError("","Unable to save any changes. Try again."); } return View(user); }
public ActionResult Create(User user) { try { if (ModelState.IsValid) { user.Id = Guid.NewGuid(); db.Users.Add(user); db.SaveChanges(); return RedirectToAction("Index"); } } catch(DataException) { ModelState.AddModelError("","Unable to save any changes made. Try again."); } return View(user); }
public JsonResult FacebookLogin(User model) { Session["uid"] = model.Id; Session["accessToken"] = model.accessToken; return Json(new { success = true }); }