ChangePassword Method for Entity Framework MVC3 Razor Custom Member Provider C# Using LINQ
public override bool ChangePassword(string username, string oldPassword, string newPassword) { try { byte[] hashedNewPassword = HashPassword(newPassword.Trim()); byte[] hashedOldPassword = HashPassword(oldPassword.Trim()); using (var context = new SSSEntities()) { UserProfile u = context.UserProfiles .SingleOrDefault(up => up.UserName == username && up.UserPassword == hashedOldPassword); if (u != null) { u.UserPassword = hashedNewPassword; context.SaveChanges(); return true; } else return false; } } catch (InvalidOperationException ex) { throw ex; } catch (ArgumentException) { throw; } }
[SIGNATURE]