public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { using (var context = new DatabaseEntities2()) { context.User.AddObject( new User() { idUser = 1, loginUser = model.UserName, nameUser = model.UserName, passwordUser = model.Password } ); context.SaveChanges(); } return RedirectToAction("Index", "Home"); } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult ChangePassword(ChangePasswordModel model) { if (ModelState.IsValid) { using (var context = new DatabaseEntities2()) { var user = Aplication.GetUser(); if(user.passwordUser == model.OldPassword) { user.passwordUser = model.NewPassword; context.User.AddObject(user);// NÂO FUNCIONA context.SaveChanges(); return RedirectToAction("ChangePasswordSuccess"); } else ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); } } // If we got this far, something failed, redisplay form return View(model); }