public static void UpdateUser(UserInfo user, out string errorMessage, bool isTest = false) { try { errorMessage = ValidateUser(user); if (string.IsNullOrEmpty(errorMessage)) { IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); if (membershipTools.UpdateUserEmail(user.UserName, user.Email) == false) { errorMessage = "Error updating email."; } if (sprocCalls.UserInfoUpdate(user) == false) { errorMessage = "Error saving user information"; } } } catch (Exception ex) { DBCommands.RecordError(ex); errorMessage = ex.Message; } }
private static string InsertUser(UserInfo user, bool isTest) { string errorMessage = string.Empty; IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); if (membershipTools.CreateUser(user.UserName, user.Email, user.Password) == false || sprocCalls.UserInfoUpdate(user) == false) { errorMessage = "Error saving user information."; } return(errorMessage); }
public static void RecoverPassword(RecoverModel model, string location, out string errorMessage, bool isTest = false) { try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); errorMessage = string.Empty; UserInfo user = sprocCalls.UserInfoGetByUser(model.UserName); if (model.Email == user.Email) { string code = RandomCode(7); while (sprocCalls.UserInfoGetByCode(code) != null) { code = RandomCode(7); } user.GroupUsers = GetGroupsByUserName(model.UserName, sprocCalls); user.RecoverCode = RandomCode(7); if (sprocCalls.UserInfoUpdate(user) == false) { errorMessage = "Error recovering password."; } else if (SendRecoverEmail(user, location, isTest) == false) { errorMessage = "Error sending email."; } } else { errorMessage = (user != null) ? "Email and username is not valid." : "Error loading user"; } } catch (Exception ex) { DBCommands.RecordError(ex); errorMessage = ex.Message; } }