/// <summary>
        /// This is step 2 not 3
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnStep3_Click(object sender, EventArgs e)
        {
            //Register the user here, add the user details to the membership tables
            user.Email = txtEmail.Text.Trim();
            user.PersonalEmail = txtEmail.Text.Trim();
            user.UserName = txtEmail.Text.Trim();
            user.Password = hdnPassword.Value;
            user.Question = txtQuestion.Text.Trim();
            user.Answer = txtAnswer.Text.Trim();

            aspnet_Roles aspnet_Roles = new aspnet_Roles();
            aspnet_Roles = aspnet_Roles.Select("student");

            user.RoleId = aspnet_Roles.RoleId;

            bool IsActivate = false;
            IsActivate = SystemConfig.GetValue(Enums.SystemConfig.IsEmailActivation).ToLower() == "true" ? false : true;

            object objCreateMembershipUser = new object();
            objCreateMembershipUser = user.AddMembershipUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, false, "student");

            bool boolMembershipUserCreated = false;
            bool.TryParse(objCreateMembershipUser.ToString(), out boolMembershipUserCreated);

            if (boolMembershipUserCreated)
            {
                Session[Constants.SESSION_LOGGED_USER] = user;

                MembershipUser newUser = Membership.GetUser(user.UserName);
                user.UserId = Guid.Parse(newUser.ProviderUserKey.ToString());
                hdnUserId.Value = user.UserId.ToString();
                user.AspnetUserId = Guid.Parse(newUser.ProviderUserKey.ToString());
                user.CreatedBy = Guid.Parse(newUser.ProviderUserKey.ToString());
                user.UpdatedBy = Guid.Parse(newUser.ProviderUserKey.ToString());
                user.UserName = txtEmail.Text.Trim();
                user.Save();

                if (!IsActivate)
                {
                    if (SendVerificationCodeEmail(newUser))
                    {

                    }
                }
            }
            else
            {
                lblError.Text = objCreateMembershipUser.ToString();
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('"
                    + Messages.Profile_Create_Unsuccess + " - " + objCreateMembershipUser.ToString() + "'); }", true);
            }

            //Move to next step in wizzard
            //Email activation can be dissabled from config in db
            if (IsActivate)
            {
                //Activate the user here
                ActivateUserAccount();
                registrationWizard.ActiveStepIndex = (int)EnumWizardStepIndexes.Step4;
            }
            else
            {
                registrationWizard.ActiveStepIndex = (int)EnumWizardStepIndexes.Step3;
            }
        }
        protected void CreateUserButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid == true)
            {
            ShowPartialUserEmailRequest.Visible = false;
            try
            {

                string AccessCode = Utility.GetQueryStringValueByKey(Request, "ActivationKey");

               if (AccessCode != string.Empty && AccessCode != null)
               {
                    user = User.Select(Guid.Parse(AccessCode));
               }

               bool PartialEmail = false;

              if (user.IsPartialUser == false)
              {
                    PartialEmail = checkPartialEmail();
              }

              if (PartialEmail == false)
              {
                        // need to validate partial email address

                        bool boolMembershipUserCreated = false;

                        user.Email = Email.Text.Trim();
                        user.PersonalEmail = Email.Text.Trim();
                        user.Password = Password.Text.Trim();
                        user.UserName = UserName.Text.Trim();
                        user.Question = Question.Text.Trim();
                        user.Answer = Answer.Text.Trim();

                        aspnet_Roles aspnet_Roles_ = new aspnet_Roles();
                        aspnet_Roles_ = aspnet_Roles.Select("student");

                        user.FirstName = FirstName.Text.Trim();
                        user.MiddleName = MiddleName.Text.Trim();
                        user.LastName = LastName.Text.Trim();
                        user.RoleId = aspnet_Roles_.RoleId;
                        user.ReferralCode = ReferralCode.Text.Trim();

                        object objCreateMembershipUser = new object();

                        bool IsActivate = false;

                        if (SystemConfig.GetValue(Enums.SystemConfig.IsEmailActivation).ToLower() == "true")
                        {
                            IsActivate = false;
                        }
                        else
                        {
                            IsActivate = true;
                        }

                        if (user.IsPartialUser)
                        {
                            objCreateMembershipUser = user.AddMembershipPartialUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, IsActivate, user.UserId.Value, "student");
                        }
                        else
                        {
                            objCreateMembershipUser = user.AddMembershipUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, IsActivate, "student");
                        }

                        bool.TryParse(objCreateMembershipUser.ToString(), out boolMembershipUserCreated);

                        if (boolMembershipUserCreated)
                        {
                            Session[Constants.SESSION_LOGGED_USER] = user;

                            MembershipUser newUser = Membership.GetUser(user.UserName);
                            user.UserId = Guid.Parse(newUser.ProviderUserKey.ToString());
                            user.AspnetUserId = Guid.Parse(newUser.ProviderUserKey.ToString());
                            user.CreatedBy = Guid.Parse(newUser.ProviderUserKey.ToString());
                            user.UpdatedBy = Guid.Parse(newUser.ProviderUserKey.ToString());
                            user.Save();

                            if (SystemConfig.GetValue(Enums.SystemConfig.IsEmailActivation).ToLower() == "true")
                            {
                                string strMsgContent = message((Guid)newUser.ProviderUserKey);
                                string strMsgTitle = SystemConfig.GetValue(RHP.Common.Enums.SystemConfig.SITEURL) + " - Action required for account activation.";

                                int rtn = SendEmail(user.Email, strMsgTitle, strMsgContent);

                                if (rtn == 1)
                                {
                                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Create_Account_Success + "'); window.location = '/Login.aspx?type=s'; }", true);
                                }
                                else
                                {
                                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Sending_Email_Error + "'); window.location = '/Login.aspx?type=s'; }", true);
                                }
                            }
                            else
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Create_Account_Success + "'); window.location = '/Login.aspx?type=s'; }", true);
                            }

                        }
                        else
                        {
                            lblError.Text = objCreateMembershipUser.ToString();
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Profile_Create_Unsuccess + " - " + objCreateMembershipUser.ToString() + "'); }", true);
                        }
                }
                else
                {

                        User user_check = new User();

                        if (user_check.IsPartialUserEmailExist(Email.Text.Trim().ToLower()))
                        {
                            ShowfullRegistration.Visible = false;
                            ShowPartialUserEmailRequest.Visible = true;
                            lblpartialuserEmail.Text = Email.Text.Trim();
                            lblpartialuserEmail2.Text = Email.Text.Trim();
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Profile_Create_Unsuccess + " - " + Messages.EmailAddressExist + "'); }", true);
                            ShowPartialUserEmailRequest.Visible = false;
                            ShowfullRegistration.Visible = true;
                        }
                }

            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Profile_Create_Unsuccess +  "'); }", true);

                throw ex;//new Exception("student Profile info : " + ex.ToString());
            }
            }
            else
            {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Validation_Fail + "'); }", true);
            }
        }
        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;
        }
Exemplo n.º 4
0
        //--------Role Names-----------
        //RoleName	LoweredRoleName
        // Admin	admin
        // Landlord	landlord
        // Student	student
        // SystemAdmin	systemadmin


        public static aspnet_Roles Select(string RoleName)
        {
            aspnet_Roles aspnet_Roles_ = Generic.GetByFieldValue <aspnet_Roles>("RoleName", RoleName);

            return(aspnet_Roles_);
        }
        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;
        }
        protected void EditUserButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid == true)
            {
                try
                {

                    if (HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        aspnet_Roles aspnet_Roles_ = new aspnet_Roles();

                        aspnet_Roles_ = aspnet_Roles.Select("student");

                        user.UserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                        user.AspnetUserId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                        user.FirstName = FirstName.Text.Trim();
                        user.MiddleName = MiddleName.Text.Trim();
                        user.DateOfBirth = DateTime.Parse(DOB.Text.Trim());
                        user.LastName = LastName.Text.Trim();
                        user.StreetAddress = Address.Text.Trim();
                        user.City = City.Text.Trim();
                        user.RoleId = aspnet_Roles_.RoleId;
                        user.PersonalEmail = Email.Text.Trim();

                        if (Drpstate.SelectedItem.Value.Trim() == "-1")
                        {
                            user.StateId = null;
                        }
                        else
                        {
                            user.StateId = int.Parse(Drpstate.SelectedItem.Value.Trim());
                        }

                        user.Zip = Zip.Text.Trim();
                        user.BestContactNumber = MobileArea.Text.Trim() + Mobile1.Text.Trim() + Mobile2.Text.Trim();
                       // user.DriversLicenseNumber = DriversLicense.Text.Trim();
                        user.Gender = DrpGender.SelectedItem.Value.ToString();
                        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;
                            lblError.Text = Messages.Save_Success;
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Student/Student_Profile.aspx';}", true);

                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true);
                        }

                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true);
                    }
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true);
                    throw ex;//new Exception("student Profile info : " + ex.ToString());
                }
            }
            else
            {

            }
        }
        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 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");

            foreach (GridViewRow row in GridviewRoommatelist.Rows)
            {
                user.PersonalEmail = row.Cells[1].Text;
                user.FirstName = row.Cells[2].Text;
                user.MiddleName = row.Cells[3].Text;
                user.LastName = row.Cells[4].Text;
                user.BestContactNumber = row.Cells[5].Text;

                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();

                    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 = '/Land_load/Land_load_Profile.aspx';}", true);
            }
            return result;
        }
Exemplo n.º 10
0
        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;
        }