public void UpdateUserTest()
        {
            var user      = UserMetier.GetUser("99");
            var sqlParams = new Dictionary <string, object>()
            {
                { "IdType", testUser.IdType },
                { "Nom", "Unit Test Nom Update" },
                { "Prenom", "Unit Test Nom Update" },
                { "DateRegister", DateTime.Now },
                { "Id", user.Id }
            };
            var id = UserMetier.UpdateUser(sqlParams);

            Assert.IsTrue(id == 1);
        }
Пример #2
0
        protected void btnValidate_Click(object sender, EventArgs e)
        {
            lblSuccessUpdate.Visible = lblErrorLogin.Visible = false;
            var curUser    = dispatcher.IdentificationService.GetLoggedUser();
            var updUser    = GetClonedUser(curUser);
            var sqlParams  = new Dictionary <string, object>(8);
            var typeCompte = !String.IsNullOrEmpty(ddlTypeCompte.SelectedValue) ? Convert.ToInt32(ddlTypeCompte.SelectedValue) : 0;

            if (!tbLogin.Text.Equals(curUser.Login))
            {
                var user = UserMetier.GetUser(tbLogin.Text);
                if (!user.IsEmpty())
                {
                    lblErrorLogin.Visible = true;
                    return;
                }
                sqlParams.Add("Login", tbLogin.Text);
                updUser.Login = tbLogin.Text;
            }
            if (!tbPass.Text.Equals(curUser.Pass))
            {
                sqlParams.Add("Pass", tbPass.Text);
                updUser.Pass = tbPass.Text;
                tbPass.Attributes["value"] = tbPass.Text;
            }
            if (typeCompte != curUser.IdType)
            {
                sqlParams.Add("IdType", typeCompte);
                updUser.IdType           = typeCompte;
                updUser.UserType.Id      = typeCompte;
                updUser.UserType.NameStr = ddlTypeCompte.SelectedItem.Text;
            }
            if (sqlParams.Count > 0)
            {
                sqlParams.Add("Id", curUser.Id);
            }
            int rows;

            if ((rows = UserMetier.UpdateUser(sqlParams)) > 0)
            {
                ReloadUserData(ref curUser, updUser);
                LoadUserInfo(curUser);
                UpdateMasterReference(curUser);
                lblSuccessUpdate.Visible = true;
            }
        }