/// <summary> /// valEmail_ServerValidate - Run this validation when the form is posted. /// </summary> /// <param name="source"></param> /// <param name="args"></param> protected void valEmail_ServerValidate(object source, ServerValidateEventArgs args) { AspNetViewsBLL ASPBLL = new AspNetViewsBLL(); vw_aspnet_MembershipUsers_DM aspUser = new vw_aspnet_MembershipUsers_DM(); aspUser = ASPBLL.ListUserByEmail(rTXTEmailAddress.Text.ToString()); args.IsValid = true; if (aspUser == null) { args.IsValid = false; } }
/// <summary> /// rBTNSubmit_Click - Find the user's information, then email the user their user name /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void rBTNSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { AspNetViewsBLL ASPBLL = new AspNetViewsBLL(); vw_aspnet_MembershipUsers_DM aspUser = new vw_aspnet_MembershipUsers_DM(); aspUser = ASPBLL.ListUserByEmail(rTXTEmailAddress.Text.ToString()); if (aspUser == null) { // user not found by email // already handled in server validate } else { string[,] MergeValues = new string[,] { { "{UserName}", aspUser.UserName } }; cMail.SendMessage("*****@*****.**", aspUser.Email, "Forgot Password", cMail.PopulateBody("~/Content/EmailTemplates/ForgotUserName.html", MergeValues)); } pnlRecover.Visible = false; pnlContinue.Visible = true; } }
public vw_aspnet_MembershipUsers_DM ListUserByEmail(string strEmail) { vw_aspnet_MembershipUsers_DM list = new vw_aspnet_MembershipUsers_DM(); try { using (AspNetProviderEntities context = new AspNetProviderEntities()) { list = (from result in context.vw_aspnet_MembershipUsers where result.Email == strEmail select new vw_aspnet_MembershipUsers_DM { ApplicationId = result.ApplicationId, Comment = result.Comment, CreateDate = result.CreateDate, Email = result.Email, FailedPasswordAnswerAttemptCount = result.FailedPasswordAnswerAttemptCount, FailedPasswordAnswerAttemptWindowStart = result.FailedPasswordAnswerAttemptWindowStart, FailedPasswordAttemptCount = result.FailedPasswordAttemptCount, FailedPasswordAttemptWindowStart = result.FailedPasswordAttemptWindowStart, IsAnonymous = result.IsAnonymous, IsApproved = result.IsApproved, IsLockedOut = result.IsLockedOut, UserId = result.UserId, UserName = result.UserName, LastActivityDate = result.LastActivityDate, LastLockoutDate = result.LastLockoutDate, LastLoginDate = result.LastLoginDate, LoweredEmail = result.LoweredEmail, LastPasswordChangedDate = result.LastPasswordChangedDate }).FirstOrDefault(); } // Guaranteed to close the Connection } catch (Exception ex) { throw (ex); } return list; }