public void UnBlockAllUsers(List <int> unCheckedUserIds) { try { dc.Configuration.ValidateOnSaveEnabled = false; if (unCheckedUserIds.Count > 0) { foreach (var item in unCheckedUserIds) { var resBlockAllUsers = (from user in dc.Users where user.UserId == item select user).FirstOrDefault(); if (resBlockAllUsers != null) { resBlockAllUsers.IsBlockByAdmin = false; resBlockAllUsers.ModifyDate = DateTime.Now; dc.Entry(resBlockAllUsers).State = EntityState.Modified; Save(); } } } } catch (Exception) { throw; } }
public bool ChangePassword(string currentPassword, string password, string confirmPassword, int userId) { try { bool IsSuccess = false; mVCDemoEntities.Configuration.ValidateOnSaveEnabled = false; var checkPassword = (from o in mVCDemoEntities.Users where o.UserId == userId select o).FirstOrDefault(); if (checkPassword != null) { if (BCrypt.Net.BCrypt.Verify(currentPassword, checkPassword.Password)) { checkPassword.Password = BCrypt.Net.BCrypt.HashPassword(password, BCrypt.Net.BCrypt.GenerateSalt()); checkPassword.ConfirmPassword = BCrypt.Net.BCrypt.HashPassword(confirmPassword, BCrypt.Net.BCrypt.GenerateSalt()); checkPassword.ModifyDate = DateTime.Now; mVCDemoEntities.Entry(checkPassword).State = EntityState.Modified; Save(); IsSuccess = true; } } return(IsSuccess); } catch (Exception) { throw; } }