public JsonResult UpdateUser(User user) { var foundUser = db.Users.Find(user.ID); bool bSuccess = false; if (user != null) { db.Users.Remove(user); bSuccess = (db.SaveChanges() == 1); } return Json(new { success = bSuccess }); }
public JsonResult RegisterUser(User user) { bool bSuccess = false; if (ModelState.IsValid) { db.Users.Add(user); if (db.SaveChanges() == 1) { User justAddedUser = db.Users.Where(u => u.LoginID == user.LoginID).FirstOrDefault(); if (justAddedUser != null) { bSuccess = true; UserUtils.CreateEncryptedUserCookie( justAddedUser.ID, false ); } else { bSuccess = false; } } } return Json(new { success = bSuccess }); }