Exemple #1
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Value.Trim();
            string emailAdd = txtEmailAdd.Value.Trim();
            string password = txtSignUpPassword.Value;
            string confPassword = txtConfPassword.Value;
            WSInteger isExist = new WSInteger();
            isExist.IntegerValue = 0;

            string validateInput = UserSignUpInfo.validateSignUpInputData(userName, emailAdd, password, confPassword);
            User userInfo = new User();

            isExist = UserSignUpInfo.IsUserExist(userName);

            // Temprory testing condition
            if (isExist.IntegerValue == 1)
            {
                userNameErrMsg.Text = "Username Allready exist";
            }

            if (validateInput == string.Empty && isExist.IntegerValue == 0)
            {
                try
                {
                    userInfo = UserSignUpInfo.InsertSignUpData(userName, emailAdd, password);
                }
                catch (Exception ee)
                {

                }
            }
        }
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            string userName = txtSignInUserName.Value.Trim();
            string password = txtSignInPassword.Value;
            string validateInput = string.Empty;
            WSInteger IsUserExist = new WSInteger();

            validateInput = LoginDetail.validateSignInData(userName, password);

            if (validateInput == string.Empty)
            {
                try
                {
                    // Encrypt password
                    string encrptedPwd = CommonFunction.Encrypt(password);

                    //Call Authorized function for validate username and password
                    IsUserExist = LoginDetail.IsAuthorizedUser(userName, encrptedPwd);

                    if (IsUserExist.IntegerValue != 0)
                    {
                        // Set session ID
                        Session["UserID"] = IsUserExist;
                        Session["IsFB"] = 0;
                        Session["Isg+"] = 0;

                        Response.Redirect("Profile.aspx");
                    }
                }
                catch (Exception ex)
                {

                }
            }
        }
        /// <summary>
        /// Check whether user exist in db with username
        /// Note: Currently this function is not using to check one
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public static WSInteger IsUserExist(string userName)
        {
            WSInteger IsExist = new WSInteger();
            IsExist.IntegerValue = 0;

            try
            {
                using (PMUServiceClient client = new PMUServiceClient("WSHttpBinding_IPMUService"))
                {
                    PMUServiceResult result = new PMUServiceResult();
                    result = client.IsUserNameExist(userName);
                    IsExist = (WSInteger)result.Data;
                    if (result.Data == null && result.ErrorMessage.Length > 0)
                    {
                        IsExist.IntegerValue = 0;
                    }
                }
            }
            catch (FaultException<PMUServiceResult> Fex)
            {
                ErrorLogging.LogError(Fex.Detail.ErrorMessage, Fex.Detail.ErrorDetails, CommonFunction.GetCurrentRequestUrl());
            }
            return IsExist;
        }