public bool Save()
        {
            bool result = true;
            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("landlord");

            User Landlorduser = new User();
            if (LandlordId == null)
            {

                Landlorduser.UserId = Guid.NewGuid();
                Landlorduser.PersonalEmail = Email.Text.Trim();
                Landlorduser.FirstName = FirstName.Text.Trim();
                Landlorduser.MiddleName = MiddleName.Text.Trim();
                Landlorduser.LastName = LastName.Text.Trim();
                Landlorduser.BestContactNumber = MobileArea.Text.Trim() + Mobile1.Text.Trim() + Mobile2.Text.Trim();//Mobile.Text.Trim();
                Landlorduser.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser = true;
                Landlorduser.RoleId = aspnet_Roles_.RoleId;

                if (Landlorduser.Save())
                {
                    landload.user = Landlorduser;
                    landload.LandlordId = Landlorduser.UserId.HasValue ? Landlorduser.UserId.Value : Landlorduser.UserId.Value;
                    LandlordId = landload.LandlordId;//setting value of property
                    landload.LandlordName = Landlorduser.FirstName + " " + Landlorduser.MiddleName + " " + Landlorduser.LastName;

                    landload.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    result = landload.Save();

                    string strMsgContent = message(Landlorduser.UserId.Value,Landlorduser);

                    string strMsgTitle = RHP.Common.Enums.SystemConfig.SITEURL + " is Requesting you to join with Us.";

                     int rtn = SendEmail(Landlorduser.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }
                }

                LandlordId = Landlorduser.UserId;
            }
            else
            {

                // Landload already registerd
            }
            return result;
        }
        protected void btnStep4_Click(object sender, EventArgs e)
        {
            //Save rest of the user details and save.
            Guid userId = Guid.Parse(hdnUserId.Value.Trim());
            user = User.Select(userId);//Load user details to the object, else other user details will get empty
            user.FirstName = txtFirstName.Text.Trim();
            user.LastName = txtLastName.Text.Trim();
            DateTime dob;
            if (DateTime.TryParse(txtDateofBirth.Text.Trim(), out dob))
            {
                user.DateOfBirth = dob;
            }
            user.ReferralCode = ReferralCode.Text.Trim();
            user.Save();
            FormsAuthentication.SetAuthCookie(user.PersonalEmail, false);

            //Page redirect to student profile.
            registrationWizard.ActiveStepIndex = (int)EnumWizardStepIndexes.Step5;
        }
        public bool SaveNewstudent()
        {
            bool result = true;

            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("student");

            User user_ = new User();

            user_.PersonalEmail = Email.Text.Trim();
            user_.FirstName = FirstName.Text.Trim();
            user_.MiddleName = MiddleName.Text.Trim();
            user_.LastName = LastName.Text.Trim();
            user_.BestContactNumber = MobileArea.Text.Trim() + Mobile1.Text.Trim() + Mobile2.Text.Trim();

                user_.UserId = Guid.NewGuid();
                user_.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                user_.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                user_.IsPartialUser = true;
                user_.HouseId = Guid.Parse(hdHouseId.Value);
                user_.RoleId = aspnet_Roles_.RoleId;

                if (result = user_.Save())
                {
                    Save_Student_House(user_);

                    string strMsgContent = message(user_.UserId.Value, user_);

                    string strMsgTitle = "www.ratemystudenthome.com is Requesting you to join with Us.";

                    int rtn = SendEmail(user_.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }
                }

            if (result)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile.aspx';}", true);
            }
            return result;
        }
        public bool SaveLandload()
        {
            bool result = true;
            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            Landlord landload = new Landlord();

            aspnet_Roles_ = aspnet_Roles.Select("landlord");

            User Landlorduser = new User();
            if (hdLandloadId.Value != null && hdLandloadId.Value != string.Empty)
            {

                Landlorduser.UserId = Guid.Parse(hdLandloadId.Value);
                Landlorduser.PersonalEmail = LandloadEmail.Text.Trim();
                Landlorduser.FirstName = LandloadFirstName.Text.Trim();
                Landlorduser.MiddleName = LandloadMiddleName.Text.Trim();
                Landlorduser.LastName = LandloadLastName.Text.Trim();
                Landlorduser.BestContactNumber = LandloadMobileArea.Text.Trim() + LandloadMobile1.Text.Trim() + LandloadMobile2.Text.Trim();//Mobile.Text.Trim();
                Landlorduser.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser = true;
                Landlorduser.RoleId = aspnet_Roles_.RoleId;
                Landlorduser.UpdatedDate = DateTime.Now;

                if (Landlorduser.Save())
                {
                    landload.user = Landlorduser;
                    landload.LandlordId = Landlorduser.UserId.HasValue ? Landlorduser.UserId.Value : Landlorduser.UserId.Value;
                    landload.LandlordName = Landlorduser.FirstName + " " + Landlorduser.MiddleName + " " + Landlorduser.LastName;

                    landload.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    result = landload.Save();

                    string strMsgContent = Landloadmessage(Landlorduser.UserId.Value, Landlorduser);

                    string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + " is Requesting you to join with Us.";

                    int rtn = LandloadSendEmail(Landlorduser.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile_Update_Current_House.aspx';}", true);

                }

            }
            else
            {
                LandloadLabelmessage.Text = "Landlord Details cannot saved.Please try again!";
                // no  Landload id
            }
            return result;
        }
        public bool Save()
        {
            bool result = true;

            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("student");

            User user_ = new User();

            user_ = RHP.UserManagement.User.Select(Guid.Parse(hdUserID.Value));

                user_.PersonalEmail = Email.Text.Trim();
                user_.FirstName = FirstName.Text.Trim();
                user_.MiddleName = MiddleName.Text.Trim();
                user_.LastName = LastName.Text.Trim();
                user_.BestContactNumber = MobileArea.Text.Trim() + Mobile1.Text.Trim() + Mobile2.Text.Trim();

                user_.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                user_.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());

                if (result = user_.Save())
                {

                    string strMsgContent = message(user_.UserId.Value, user_);

                    string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + " is Requesting you to join with Us.";

                    int rtn = SendEmail(user_.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }
                }

            if (result)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile.aspx';}", true);
            }
            return result;
        }
        public bool Save()
        {
            bool result = true;

            aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

            aspnet_Roles_ = aspnet_Roles.Select("student");

            User user_ = new User();
            foreach (GridViewRow row in GridviewRoommatelist.Rows)
            {
                user_.PersonalEmail = string.IsNullOrEmpty(row.Cells[1].Text.Trim()) ? string.Empty : row.Cells[1].Text.Trim();
                user_.FirstName = string.IsNullOrEmpty(row.Cells[2].Text.Trim()) ? string.Empty : row.Cells[2].Text.Trim();
                user_.MiddleName = string.IsNullOrEmpty(row.Cells[3].Text.Trim()) ? string.Empty : row.Cells[3].Text.Trim();
                user_.MiddleName = user_.MiddleName.Replace(" ", "");
                user_.LastName = string.IsNullOrEmpty(row.Cells[4].Text.Trim()) ? string.Empty : row.Cells[4].Text.Trim();
                user_.BestContactNumber = string.IsNullOrEmpty(row.Cells[5].Text.Trim()) ? string.Empty : row.Cells[5].Text.Trim();

                user_.UserId = Guid.NewGuid();
                user_.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                user_.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                user_.IsPartialUser = true;
                user_.HouseId = HouseId.Value;
                user_.RoleId = aspnet_Roles_.RoleId;

                if (result = user_.Save())
                {
                    Save_Student_House(user_);

                    string strMsgContent = message(user_.UserId.Value, user_);

                    string strMsgTitle =  SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + "  is Requesting you to join with Us.";

                    int rtn = SendEmail(user_.PersonalEmail, strMsgTitle, strMsgContent);

                    if (rtn == 1)
                    {
                    }

                }
            }

            if (result)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile.aspx';}", true);
            }
            return result;
        }
示例#7
0
        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;
            }
        }
        protected void btnStep4_Click(object sender, EventArgs e)
        {
            //Save rest of the user details and save.
            Guid userId = Guid.Parse(hdnUserId.Value.Trim());
            user = User.Select(userId);//Load user details to the object, else other user details will get empty
            user.FirstName = txtFirstName.Text.Trim();
            user.LastName = txtLastName.Text.Trim();
            DateTime dob;
            if (DateTime.TryParse(txtDateofBirth.Text.Trim(), out dob))
            {
                user.DateOfBirth = dob;
            }
            user.ReferralCode = ReferralCode.Text.Trim();
            user.Save();
            FormsAuthentication.SetAuthCookie(user.PersonalEmail, false);

            //Page redirect to landlord profile.
            Response.Redirect("Land_load_Profile.aspx", false);
        }
        public Guid SaveLandload(int baseHouseId)
        {
            Guid landlordId;

            List<BaseHouse> dormHouses = BaseHouseDAO.SelectAllByHouseTypeId(HouseTypeId);
            CurrentHouse = dormHouses.Find(bh => bh.BaseHouseId == baseHouseId);
            if (CurrentHouse.LandlordId.HasValue)
            {
                landlordId = CurrentHouse.LandlordId.Value;
            }
            else
            {
                aspnet_Roles aspnet_Roles_ = new aspnet_Roles();
                Landlord landload = new Landlord();
                aspnet_Roles_ = aspnet_Roles.Select("landlord");

                User Landlorduser = new User();

                Landlorduser.UserId = Guid.NewGuid();
                landlordId = Landlorduser.UserId.Value;

                Landlorduser.PersonalEmail = CurrentHouse.ManagerEmail;
                Landlorduser.FirstName = CurrentHouse.PropertyManagementCompanyName;
                Landlorduser.BestContactNumber = CurrentHouse.PhoneNumber;
                Landlorduser.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                Landlorduser.IsPartialUser = true;
                Landlorduser.RoleId = aspnet_Roles_.RoleId;
                Landlorduser.UpdatedDate = DateTime.Now;

                if (Landlorduser.Save())
                {
                    landload.user = Landlorduser;
                    landload.LandlordId = Landlorduser.UserId.Value;
                    landload.LandlordName = Landlorduser.FirstName;
                    landload.IsDeleted = false;
                    landload.LandlordTypeId = (int)Enums.LandlordType.CorporateLandlord;
                    landload.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    landload.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());

                    if (landload.Save())
                    {
                        //Todo: Update the basehouse table with the new LandlordId
                        CurrentHouse.LandlordId = landlordId;
                        CurrentHouse.CreatedBy = Membership.GetUser().UserName;
                        CurrentHouse.UpdatedBy = Membership.GetUser().UserName;
                        if (CurrentHouse.Save())
                        {
                            //Base House is updated with new landlord id
                        }
                    }
                }
            }
            return landlordId;
        }