Exemplo n.º 1
0
        //remove the currently selected user in the grid.  If there is no user selected in the grid (i.e. it's empty) then warn the
        //user and exit.
        private void buttonRemoveItem_Click(object sender, EventArgs e)
        {
            if (gridUsers.SelectedRows.Count < 1)
            {
                MessageBox.Show("You must first select a user to delete");
                return;
            }

            //the objectID and alias values will always be in the result set.
            string strObjectID = gridUsers.SelectedRows[0].Cells["ObjectId"].Value.ToString();
            string strAlias    = gridUsers.SelectedRows[0].Cells["Alias"].Value.ToString();

            //verify with the user before deleting
            if (MessageBox.Show("Are you sure you want to delete the user:"******"?", "DELETE Confirmation",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                //the user changed their minds, bail out
                return;
            }

            DisableFormControls();

            //remove the user
            WebCallResult res = UserBase.DeleteUser(GlobalItems.CurrentConnectionServer, strObjectID);

            EnableFormControls();

            if (res.Success)
            {
                MessageBox.Show("User removed");
                Logger.Log(string.Format("User with alias={0} and objectId={1} removed.", strAlias, strObjectID));

                //rebuild the grid - if we were traversing a list of users before, be sure to reset the current page to 0 here because we
                //need to rebuild the list without the guy we just deleted in it.
                _currentPage = 0;
                UpdateDataDisplay();
            }
            else
            {
                MessageBox.Show("Failure removing user: "******"Failed to remove user with alias={0} and objectId={1}.  Error={2}", strAlias, strObjectID, res.ToString()));
            }
        }
Exemplo n.º 2
0
        public void StaticCallFailure_DeleteUser()
        {
            var res = UserBase.DeleteUser(_connectionServer, "ObjectId");

            Assert.IsFalse(res.Success, "Invalid ObjectId should fail");
        }
Exemplo n.º 3
0
        public void DeleteUser_NullConnectionServer_Failure()
        {
            var res = UserBase.DeleteUser(null, "ObjectId");

            Assert.IsFalse(res.Success, "Null ConnectionServerRest object should fail");
        }
Exemplo n.º 4
0
        public void DeleteUser_EmptyObjectId_Failure()
        {
            var res = UserBase.DeleteUser(_mockServer, "");

            Assert.IsFalse(res.Success, "Empty ObjectId should fail");
        }