public bool checkPartialEmail() { bool isEmailEsixt = false; User user_check = new User(); if (user_check.IsUserEmailExist(Email.Text.Trim().ToLower())) { isEmailEsixt = true; } return isEmailEsixt; }
protected void ButtonVerify_Click(object sender, EventArgs e) { Labelmessage.Text = ""; if (Email.Text.Trim() != "") { User user_ = User.SelectUserByEmail("Email", Email.Text.Trim().ToLower(), "RoleName", "landlord"); if (user_ != null) { Labelmessage.Text = "landload verified for email : " + Email.Text.Trim().ToLower(); LandlordId = user_.UserId; //Pass the landlordId back to the main page PassID(user_.UserId.Value); // Email.Text = user_.PersonalEmail; FirstName.Text = user_.FirstName; MiddleName.Text = user_.MiddleName; LastName.Text = user_.LastName; MobileArea.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(0, 3); Mobile1.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(3, 3); Mobile2.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(6, 4); //Mobile.Text = user_.BestContactNumber; } else { FirstName.Text = ""; MiddleName.Text = ""; LastName.Text = ""; MobileArea.Text = ""; Mobile1.Text = ""; Mobile2.Text = ""; User user_check = new User(); if (user_check.IsUserEmailExist(Email.Text.Trim().ToLower())) { FirstName.Enabled = false; MiddleName.Enabled = false; LastName.Enabled = false; MobileArea.Enabled = false; Mobile1.Enabled = false; Mobile2.Enabled = false; if (user_check.IsPartialUserEmailExist(Email.Text.Trim().ToLower())) { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with Partial Account. Please enter another email."; //usp_UserSelectByRoleName user_check = User.SelectUserByEmail("RoleName", "landlord", "Email", Email.Text.Trim().ToLower()); if (user_check != null) { if (user_check.UserId.HasValue && user_check.IsPartialUser == true) { Labelmessage.Text = "landload verified for email : " + Email.Text.Trim().ToLower(); LandlordId = user_check.UserId; PassID(user_check.UserId.Value); Email.Text = user_check.PersonalEmail; FirstName.Text = string.IsNullOrEmpty(user_check.FirstName) ? string.Empty : user_check.FirstName; MiddleName.Text = string.IsNullOrEmpty(user_check.MiddleName) ? string.Empty : user_check.MiddleName; LastName.Text = string.IsNullOrEmpty(user_check.LastName) ? string.Empty : user_check.LastName; MobileArea.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(0, 3); Mobile1.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(3, 3); Mobile2.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(6, 4); } else { Labelmessage.Text = "can not find registered landload for email : " + Email.Text.Trim().ToLower() + ". Please enter details to continue.."; Email.Text = ""; FirstName.Enabled = true; MiddleName.Enabled = true; LastName.Enabled = true; MobileArea.Enabled = true; Mobile1.Enabled = true; Mobile2.Enabled = true; } } else { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with Student Account. Please enter another email."; } } else { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with Student Account. Please enter another email."; } } else { Labelmessage.Text = "can not find registered landload for email : " + Email.Text.Trim().ToLower() + ". Please enter details to continue.."; // Mobile.Text = ""; FirstName.Enabled = true; MiddleName.Enabled = true; LastName.Enabled = true; MobileArea.Enabled = true; Mobile1.Enabled = true; Mobile2.Enabled = true; } } } else { clear(); } }
protected void ButtonVerifyLandload_Click(object sender, EventArgs e) { LandloadLabelmessage.Text = ""; DissableEdit(); hideHouseDetails(); // hdLandloadId.Value = string.Empty; hdHouseId.Value = string.Empty; clearLandload(); DissableLandlord(); House_Search.Visible = false; DrpHouse.Visible = false; if (LandloadEmail.Text.Trim() != "") { User user_check = new User(); user_check = RHP.UserManagement.User.SelectUserByEmail("Email", LandloadEmail.Text.Trim().ToLower(), "RoleName", "landlord"); if (user_check != null) { LandloadLabelmessage.Text = "Landlord verified for email : " + LandloadEmail.Text.Trim().ToLower(); hdLandloadId.Value = user_check.UserId.Value.ToString(); LandloadEmail.Text = user_check.PersonalEmail; LandloadFirstName.Text = string.IsNullOrEmpty(user_check.FirstName) ? string.Empty : user_check.FirstName; LandloadMiddleName.Text = string.IsNullOrEmpty(user_check.MiddleName) ? string.Empty : user_check.MiddleName; LandloadLastName.Text = string.IsNullOrEmpty(user_check.LastName) ? string.Empty : user_check.LastName; LandloadMobileArea.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(0, 3); LandloadMobile1.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(3, 3); LandloadMobile2.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(6, 4); ButtonLandload.Visible = true; LoadInitialHouseData(); loadHouseDatadata(); } else { user_check = new User(); if (user_check.IsUserEmailExist(LandloadEmail.Text.Trim().ToLower())) { if (user_check.IsPartialUserEmailExist(LandloadEmail.Text.Trim().ToLower())) { user_check = new User(); user_check = RHP.UserManagement.User.SelectUserByEmail("RoleName", "landlord", "Email", LandloadEmail.Text.Trim().ToLower()); if (user_check != null) { if (user_check.UserId.HasValue && user_check.IsPartialUser == true) { LandloadLabelmessage.Text = "landlord verified for email : " + LandloadEmail.Text.Trim().ToLower(); hdLandloadId.Value = user_check.UserId.Value.ToString(); LandloadEmail.Text = user_check.PersonalEmail; LandloadFirstName.Text = string.IsNullOrEmpty(user_check.FirstName) ? string.Empty : user_check.FirstName; LandloadMiddleName.Text = string.IsNullOrEmpty(user_check.MiddleName) ? string.Empty : user_check.MiddleName; LandloadLastName.Text = string.IsNullOrEmpty(user_check.LastName) ? string.Empty : user_check.LastName; LandloadMobileArea.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(0, 3); LandloadMobile1.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(3, 3); LandloadMobile2.Text = string.IsNullOrEmpty(user_check.BestContactNumber) ? string.Empty : user_check.BestContactNumber.Substring(6, 4); ButtonLandload.Visible = true; LoadInitialHouseData(); loadHouseDatadata(); } else { LandloadLabelmessage.Text = "can not find registered landlord for email : " + LandloadEmail.Text.Trim().ToLower() + ". Please enter details to continue.."; ButtonLandload.Visible = true; LandloadEmail.Text = ""; EnableLandlord(); } } else { LandloadLabelmessage.Text = "Email Address : " + LandloadEmail.Text.Trim().ToLower() + ", is already Registed with Student Account. Please enter another email."; } } else { LandloadLabelmessage.Text = "Email Address : " + LandloadEmail.Text.Trim().ToLower() + ", is already Registed with Student Account. Please enter another email."; EnableLandlord(); } } else { ButtonLandload.Visible = true; EnableLandlord(); } } } }
protected void ButtonVerify_Click(object sender, EventArgs e) { Labelmessage.Text = ""; if (Email.Text.Trim() != "") { User user_ = RHP.UserManagement.User.SelectUserByEmail("Email", Email.Text.Trim().ToLower(), "RoleName", "student"); if (user_ != null) { if (user_.HouseId.HasValue) { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with a another House. Please enter another email."; } else { FirstName.Enabled = false; MiddleName.Enabled = false; LastName.Enabled = false; MobileArea.Enabled = false; Mobile1.Enabled = false; Mobile2.Enabled = false; if(hdroommatestatus.Value == "Add") { Labelmessage.Text = "student verified for email : " + Email.Text.Trim().ToLower(); FirstName.Text = string.IsNullOrEmpty(user_.FirstName) ? string.Empty : user_.FirstName; MiddleName.Text = string.IsNullOrEmpty(user_.MiddleName) ? string.Empty : user_.MiddleName; LastName.Text = string.IsNullOrEmpty(user_.LastName) ? string.Empty : user_.LastName; MobileArea.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(0, 3); Mobile1.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(3, 3); Mobile2.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(6, 4); } else if (hdroommatestatus.Value == "Edit") { if (validateemail()) { Labelmessage.Text = "landlord or Roommate allready registerd for email : " + Email.Text.Trim().ToLower() + ". Please enter new details to continue.."; } else { Labelmessage.Text = "Roommate verified for email : " + Email.Text.Trim().ToLower(); FirstName.Text = user_.FirstName; MiddleName.Text = user_.MiddleName; LastName.Text = user_.LastName; MobileArea.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(0, 3); Mobile1.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(3, 3); Mobile2.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(6, 4); } } } } else { FirstName.Text = ""; MiddleName.Text = ""; LastName.Text = ""; MobileArea.Text = ""; Mobile1.Text = ""; Mobile2.Text = ""; if (hdroommatestatus.Value == "Add") { User user_check = new User(); if (user_check.IsUserEmailExist(Email.Text.Trim().ToLower())) { FirstName.Enabled = false; MiddleName.Enabled = false; LastName.Enabled = false; MobileArea.Enabled = false; Mobile1.Enabled = false; Mobile2.Enabled = false; if (user_check.IsPartialUserEmailExist(Email.Text.Trim().ToLower())) { User userPartial = RHP.UserManagement.User.SelectByRoleName("RoleName", "student", "Email", Email.Text.Trim().ToLower()); if (userPartial != null) { if (userPartial.HouseId.HasValue) { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with a another House. Please enter another email."; } else { Labelmessage.Text = "student verified for email : " + Email.Text.Trim().ToLower(); // NewEmail.Text = string.IsNullOrEmpty(Email.Text.Trim().ToLower()) ? string.Empty : Email.Text.Trim().ToLower(); FirstName.Text = string.IsNullOrEmpty(userPartial.FirstName) ? string.Empty : userPartial.FirstName; MiddleName.Text = string.IsNullOrEmpty(userPartial.MiddleName) ? string.Empty : userPartial.MiddleName; LastName.Text = string.IsNullOrEmpty(userPartial.LastName) ? string.Empty : userPartial.LastName; MobileArea.Text = string.IsNullOrEmpty(userPartial.BestContactNumber) ? string.Empty : userPartial.BestContactNumber.Substring(0, 3); Mobile1.Text = string.IsNullOrEmpty(userPartial.BestContactNumber) ? string.Empty : userPartial.BestContactNumber.Substring(3, 3); Mobile2.Text = string.IsNullOrEmpty(userPartial.BestContactNumber) ? string.Empty : userPartial.BestContactNumber.Substring(6, 4); } } else { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with Partial Lanlord Account. Please enter another email."; } } else { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with another Account. Please enter another email."; } } else { Labelmessage.Text = "can not find registered Student for email : " + Email.Text.Trim().ToLower() + ". Please enter details to continue.."; //NewEmail.Text = string.IsNullOrEmpty(Email.Text.Trim().ToLower()) ? string.Empty : Email.Text.Trim().ToLower(); FirstName.Enabled = true; MiddleName.Enabled = true; LastName.Enabled = true; MobileArea.Enabled = true; Mobile1.Enabled = true; Mobile2.Enabled = true; } } else if (hdroommatestatus.Value == "Edit") { if (validateemail()) { FirstName.Enabled = false; MiddleName.Enabled = false; LastName.Enabled = false; MobileArea.Enabled = false; Mobile1.Enabled = false; Mobile2.Enabled = false; } else { Labelmessage.Text = "can not find registered Roommate for email : " + Email.Text.Trim().ToLower() + ". Please enter details to continue.."; FirstName.Enabled = true; MiddleName.Enabled = true; LastName.Enabled = true; MobileArea.Enabled = true; Mobile1.Enabled = true; Mobile2.Enabled = true; } } } } else { clear(); } }
public bool validateemail() { bool isexist = false; Labelmessage.Text = ""; if (Email.Text.Trim() != "") { User user_ = new User(); if (user_.IsUserEmailExist(Email.Text.Trim().ToLower())) { isexist = true; if (user_.IsPartialUserEmailExist(Email.Text.Trim().ToLower())) { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with Partial Account. Please enter another email."; } else { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with another Account. Please enter another email."; } // Labelmessage.Text = "landlord or student allready registerd for email : " + Email.Text.Trim().ToLower() + ". Please enter new details to continue.."; } else { isexist = false; // Labelmessage.Text = "student verified for email : " + Email.Text.Trim().ToLower(); } } else { isexist = false; } return isexist; }
protected void ButtonVerify_Click(object sender, EventArgs e) { Labelmessage.Text = ""; if (Email.Text.Trim() != "") { User user_ = User.SelectUserByEmail("Email", Email.Text.Trim().ToLower(), "RoleName", "student"); if (user_ != null) { Labelmessage.Text = "student verified for email : " + Email.Text.Trim().ToLower(); // Email.Text = user_.PersonalEmail; FirstName.Text = user_.FirstName; MiddleName.Text = user_.MiddleName; LastName.Text = user_.LastName; MobileArea.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(0, 3); Mobile1.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(3, 3); Mobile2.Text = string.IsNullOrEmpty(user_.BestContactNumber) ? string.Empty : user_.BestContactNumber.Substring(6, 4); //Mobile.Text = user_.BestContactNumber; } else { FirstName.Text = ""; MiddleName.Text = ""; LastName.Text = ""; MobileArea.Text = ""; Mobile1.Text = ""; Mobile2.Text = ""; User user_check = new User(); if (user_check.IsUserEmailExist(Email.Text.Trim().ToLower())) { FirstName.Enabled = false; MiddleName.Enabled = false; LastName.Enabled = false; MobileArea.Enabled = false; Mobile1.Enabled = false; Mobile2.Enabled = false; if (user_check.IsPartialUserEmailExist(Email.Text.Trim().ToLower())) { User userPartial = User.SelectByRoleName("RoleName", "student", "Email", Email.Text.Trim().ToLower()); if (userPartial != null) { Labelmessage.Text = "student verified for email : " + Email.Text.Trim().ToLower(); FirstName.Text = userPartial.FirstName; MiddleName.Text = userPartial.MiddleName; LastName.Text = userPartial.LastName; MobileArea.Text = string.IsNullOrEmpty(userPartial.BestContactNumber) ? string.Empty : userPartial.BestContactNumber.Substring(0, 3); Mobile1.Text = string.IsNullOrEmpty(userPartial.BestContactNumber) ? string.Empty : userPartial.BestContactNumber.Substring(3, 3); Mobile2.Text = string.IsNullOrEmpty(userPartial.BestContactNumber) ? string.Empty : userPartial.BestContactNumber.Substring(6, 4); } else { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with Partial Lanlord Account. Please enter another email."; } // Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with Partial Account. Please enter another email."; } else { Labelmessage.Text = "Email Address : " + Email.Text.Trim().ToLower() + ", is already Registed with another Account. Please enter another email."; } } else { Labelmessage.Text = "can not find registered landload for email : " + Email.Text.Trim().ToLower() + ". Please enter details to continue.."; FirstName.Enabled = true; MiddleName.Enabled = true; LastName.Enabled = true; MobileArea.Enabled = true; Mobile1.Enabled = true; Mobile2.Enabled = true; } } } else { clear(); } }
protected void Page_Load(object sender, EventArgs e) { string ReturnURL = string.Empty; string userRole = string.Empty; Uri currentDomainURL = new Uri(HttpContext.Current.Request.Url.AbsoluteUri); string value = Utility.GetQueryStringValueByKey(Request, "type"); if (!IsPostBack) { if (value == "s") { ReturnURL = "/Student/Student_Profile.aspx"; userRole = "student"; } else if (value == "l") { ReturnURL = "/Land_load/Land_load_Profile.aspx"; userRole = "landlord"; } else { ReturnURL = "~/"; } } try { IAuthorizationState authorization = facebookClient.ProcessUserAuthorization(); User user = new User(); RHP.StudentManagement.Student student = new RHP.StudentManagement.Student(); Landlord landload = new Landlord(); if (authorization == null) { SendEmail("FBReturn URL", string.Format("Return URL: {0}, App Id: {1}, App Secret: {2}", currentDomainURL.ToString(), facebookClient.ClientIdentifier.ToString(), facebookClient.ClientCredentialApplicator.ToString())); facebookClient.RequestUserAuthorization(scope: new[] { FBClient.Scopes.Email }, returnTo: currentDomainURL); } else// if (authorization.Scope.Count > 0) { string accessCode = string.Empty; if (authorization != null && authorization.AccessToken != null) { accessCode = Uri.EscapeDataString(authorization.AccessToken); } IOAuth2Graph oauth2Graph = facebookClient.GetGraph(authorization, new[] { FBGraph.Fields.Defaults, FBGraph.Fields.Email, FBGraph.Fields.Picture }); //Todo: Register the user here if not an existing member. user.FBid = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Id)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Id); user.FirstName = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.FirstName)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.FirstName); user.LastName = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.LastName)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.LastName); user.Email = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Email)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Email); user.PersonalEmail = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Email)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Email); user.FBAccessToken = string.IsNullOrEmpty(authorization.AccessToken) ? string.Empty : authorization.AccessToken; user.FBProfilePictureURL = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.AvatarUrl)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.AvatarUrl); user.Gender = string.IsNullOrEmpty(HttpUtility.HtmlEncode(oauth2Graph.Gender)) ? string.Empty : HttpUtility.HtmlEncode(oauth2Graph.Gender); user.IsFBUser = true; user.Password = user.FBid; user.UserName = user.FBid; user.Question = "Are you FB User ?"; user.Answer = "FB" + user.FBid; if (user.IsExistingFbUser(user.FBid)) { // authanticate fbuser get userneame and pwd // get user from fbid (username) // stringpassword = membership user.UserName = user.GetFBUsernameByFBId(user.FBid); if (user.AuthenticateUser()) { try { Session[Constants.SESSION_LOGGED_USER] = user; user.RedirectUserFromLogin(false); } catch (Exception ex) { user.LogOut(); } } else { user.LogOut(); } } else { if (user.IsUserEmailExist(user.Email)) { //Todo need to handle this part correctly. Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.EmailExist + "'); window.location = '/Login.aspx'; }", true); } else { bool boolMembershipUserCreated = false; object objCreateMembershipUser = new object(); user.UserId = Guid.NewGuid(); objCreateMembershipUser = user.AddMembershipPartialUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, true, user.UserId.Value, userRole); bool.TryParse(objCreateMembershipUser.ToString(), out boolMembershipUserCreated); if (boolMembershipUserCreated) { FormsAuthentication.SetAuthCookie(user.UserName, false); user.UpdatedBy = user.UserId.HasValue ? user.UserId.Value : Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); user.CreatedBy = user.UserId.HasValue ? user.UserId.Value : Guid.Parse(Membership.GetUser().ProviderUserKey.ToString()); if (user.Save()) { Session[Constants.SESSION_LOGGED_USER] = user; MembershipUser newUser = Membership.GetUser(user.UserName); user.RedirectUserFromLogin(true); } else { user.LogOut(); //Todo delete membership user from tables Response.Redirect("~/Login.aspx", false); } } else { user.LogOut(); Response.Redirect("~/Login.aspx", false); } } } } } catch (Exception ex) { string emailText = String.Format("Message:{0}, Source:{1}, StackTrace:{2}", ex.Message, ex.Source, ex.StackTrace); SendEmail("FB Exception", emailText); throw ex; } }