public void SavePersonalAccountTest()
        {
            UserInfoManager target = new UserInfoManager(); // TODO: Initialize to an appropriate value
            UserRegistration _UserRegistration = new UserRegistration(); // TODO: Initialize to an appropriate value
            //object expected = null; // TODO: Initialize to an appropriate value
            //object actual;

            bool userNameExists = false;
            int UserId = -1;
            String DummyUser = "******";
            try
            {

                object[] objParam = { DummyUser };
                DataSet _objDataSet = GetDataSet("usp_AvailableUser", objParam);
                int count = _objDataSet.Tables[0].Rows.Count;
                if (count > 0)
                {
                    String UserName = _objDataSet.Tables[0].Rows[0][0].ToString();
                    if (UserName != "0")
                    {
                        userNameExists = true;

                        object[] objParam1 ={ DummyUser,
                                            "zSpeN+GdR0Ey9VrM9QyvUA==",
                                     null
                                   };
                        //DataSet _objDataSet = GetDataSet("usp_ValidateUser", objParam);
                        DataSet _objDataSet1 = GetDataSetWithoutCheckingIOVS("usp_ValidateWebsiteUser", objParam1);
                        // ds.Tables[0].
                        if (_objDataSet1.Tables[0].Rows.Count > 0)
                        {
                            UserId = (int)_objDataSet1.Tables[0].Rows[0]["UserId"];
                        }

                    }

                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                if (sqlEx.Number >= 50000)
                {
                    Errors objError = new Errors();
                    objError.ErrorMessage = sqlEx.Message;
                    //objUser.CustomError = objError;
                    userNameExists = false;
                }
            }
            /////////////////////////////////////////////////////////////////
            if (!userNameExists)
            {
                TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users();

                objUsers.CountryName = "India";
                objUsers.Email = "*****@*****.**";
                objUsers.FacebookUid = null;
                objUsers.FirstName = "tajinder";
                objUsers.LastName = "kaur";
                objUsers.Password = "******";
                objUsers.City = "Delhi";
                objUsers.UserName = DummyUser;
                objUsers.UserType = 2;
                objUsers.UserImage = null;
                objUsers.Country = null;
                objUsers.State = null;
                objUsers.AllowIncomingMsg = false;
                objUsers.VerificationCode = "";

                TributesPortal.BusinessEntities.UserBusiness objUserBusiness = new TributesPortal.BusinessEntities.UserBusiness();
                objUserBusiness.BusinessAddress = "optimus";
                objUserBusiness.BusinessType = 1;
                objUserBusiness.City = "Delhi";
                objUserBusiness.CompanyName = "optimus";
                objUserBusiness.Country = "India";
                objUserBusiness.Email = "*****@*****.**";
                objUserBusiness.Phone = "9911089140";
                objUserBusiness.Website = "www.yourtribute.com";
                objUserBusiness.ZipCode = "201301";

                _UserRegistration.Users = objUsers;
                _UserRegistration.UserBusiness = objUserBusiness;

                object UserId1 = target.SavePersonalAccount(_UserRegistration);
                UserId = (int)UserId1;
                //Assert.AreEqual(expected, actual);
                //Assert.Inconclusive("Verify the correctness of this test method.");
            }
            Assert.AreEqual(true, UserId > 0);
        }
Exemplo n.º 2
0
    protected void doFacebookSignup()
    {
        var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken);
        var me = (IDictionary<string, object>)fbwc.Get("me");
        string fbName = (string)me["first_name"] + " " + (string)me["last_name"];
        string UserName = fbName.ToLower().Replace(" ", "_").Replace("'", "");/*+
            "_"+_FacebookUid.ToString()*/

        string fql = "Select current_location,pic_square,email from user where uid = " + (string)me["id"];
        JsonArray me2 = (JsonArray)fbwc.Query(fql);
        var mm = (IDictionary<string, object>)me2[0];

        Nullable<int> state = null;
        Nullable<int> country = null;
        string _UserImage = "images/bg_ProfilePhoto.gif";

        if (!string.IsNullOrEmpty((string)mm["pic_square"]))
        {
            _UserImage = (string)mm["pic_square"]; // get user image
        }
        string city = "";
        JsonObject hl = (JsonObject)mm["current_location"];
        if ((string)hl[0] != null)
        {
            city = (string)hl[0];
            UserManager usrmngr = new UserManager();
            object[] param = { (string)hl[2],(string)hl[1] };
            if (usrmngr.GetstateIdByName(param) > 0)
            {
                state = usrmngr.GetstateIdByName(param);
            }
            if (usrmngr.GetCountryIdByName((string)hl[2]) > 0)
            {
                country = usrmngr.GetCountryIdByName((string)hl[2]);
            }

        }

        string password_ = string.Empty;
        string email_ = string.Empty;  //user.proxied_email;
        string result = (string)mm["email"];
        if (!string.IsNullOrEmpty(result))
        {
            email_ = result;
            password_ = RandomPassword.Generate(8, 10);
            password_ = TributePortalSecurity.Security.EncryptSymmetric(password_);

        }
        UserRegistration objUserReg = new UserRegistration();
        TributesPortal.BusinessEntities.Users objUsers =
            new TributesPortal.BusinessEntities.Users(
             UserName, password_,
             (string)me["first_name"], (string)me["last_name"], email_,
             "", false,
             city, state, country, 1, _FacebookUid);
        objUsers.UserImage = _UserImage;
        objUserReg.Users = objUsers;

        /*System.Decimal identity = (System.Decimal)*/
        UserInfoManager umgr = new UserInfoManager();
        umgr.SavePersonalAccount(objUserReg);

        if (objUserReg.CustomError != null)
        {
            messageText.Text=string.Format("<h2>Sorry, {0}.</h2>" +
                "<h3>Those Facebook credentials are already used in some other Your Tribute Account</h3>",
                fbName);
        }
        else
        {
            SessionValue _objSessionValue = new SessionValue(objUserReg.Users.UserId,
                                                             objUserReg.Users.UserName,
                                                             objUserReg.Users.FirstName,
                                                             objUserReg.Users.LastName,
                                                             objUserReg.Users.Email,
                                                             objUserReg.UserBusiness == null ? 1 : 2,
                                                             "Basic",
                                                             objUserReg.Users.IsUsernameVisiable);
            TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance;
            stateManager.Add("objSessionvalue", _objSessionValue, TributesPortal.Utilities.StateManager.State.Session);

            SaveSessionInDB();
            Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", Session.SessionID));
            Response.Cookies["ASP.NET_SessionId"].Domain = "." + WebConfig.TopLevelDomain;

            showDialog.Text = "false";
            refreshPage.Text = "true";
        }
    }
        public void SavePersonalAccountsignupTest()
        {
            UserInfoManager target = new UserInfoManager(); // TODO: Initialize to an appropriate value
            UserRegistration _UserRegistration = new UserRegistration(); // TODO: Initialize to an appropriate value

            int UserId = -1;
            string DummyEmail = "*****@*****.**";
            string pass = "******";
            /////////////////////////////////////////////////////////////////
            TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users();

            objUsers.Country = 404;
            objUsers.CreatedOn = System.DateTime.Now;
            objUsers.FacebookUid = null;
            objUsers.FirstName = "udham";
            objUsers.LastName = "attri";
            objUsers.Password = pass;
            objUsers.State = null;
            objUsers.UserImage = "images/bg_ProfilePhoto.gif";
            objUsers.UserName = DummyEmail;
            objUsers.UserType = 1;
            objUsers.VerificationCode = "";
            objUsers.Email = DummyEmail;
            objUsers.AllowIncomingMsg = false;
            objUsers.City = "";

            _UserRegistration.Users = objUsers;

            object UserId1 = target.SavePersonalAccount(_UserRegistration);
            UserId = (int)UserId1;

            Assert.AreEqual(true, UserId > 0);
        }