/// <summary>
        /// remove the currently selected distribution list in the grid after confirming with the user that's what they wish to do.
        /// </summary>
        private void buttonRemoveItem_Click(object sender, EventArgs e)
        {
            if (gridLists.SelectedRows.Count < 1)
            {
                MessageBox.Show("You must first select a distribution list to delete");
                return;
            }

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

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

            DisableFormControls();

            //remove the call handler
            WebCallResult res = DistributionList.DeleteDistributionList(GlobalItems.CurrentConnectionServer, strObjectID);

            EnableFormControls();

            if (res.Success)
            {
                MessageBox.Show("Distribution List removed");
                Logger.Log(string.Format("Distribution list [{0}] objectId={1} removed.", strDisplayName, strObjectID));

                //rebuild the grid - if we were traversing a list of lists before, be sure to reset the current page to 0 here because we
                //need to rebuild the list without the DL we just deleted in it.
                _currentPage = 0;
                UpdateDataDisplay();
            }
            else
            {
                MessageBox.Show("Failure removing distribution list:" + res.ErrorText);
                Logger.Log(string.Format("Failed to remove distribution list with display name={0} and objectId={1}.  Error={2}", strDisplayName, strObjectID, res.ToString()));
            }
        }
Esempio n. 2
0
        public void DeleteDistributionList_NullConnectionServer_Failure()
        {
            WebCallResult res = DistributionList.DeleteDistributionList(null, "aaa");

            Assert.IsFalse(res.Success, "DeleteDistributionList failed to catch null ConnectionServerRest object");
        }