Habanero.Faces.Base.ConfirmingBusinessObjectDeletor.DeleteBusinessObject C# (CSharp) Method

DeleteBusinessObject() public method

Deletes the given business object
public DeleteBusinessObject ( IBusinessObject businessObject ) : void
businessObject IBusinessObject The business object to delete
return void
        public void DeleteBusinessObject(IBusinessObject businessObject)
        {
            string message;
            if (CustomConfirmationMessageDelegate != null)
            {
                message = CustomConfirmationMessageDelegate(businessObject);
            }
            else
            {
                message = string.Format("Are you certain you want to delete the object '{0}'", businessObject);
            }
            Confirmer.Confirm(message, delegate(bool confirmed)
                {
                    if (!confirmed) return;
                    var defaultBODeletor = new DefaultBODeletor();
                    try
                    {
                        defaultBODeletor.DeleteBusinessObject(businessObject);
                    }
                    catch (Exception ex)
                    {
                        GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error Deleting");
                    }
                });
        }
    }

Usage Example

        public void Test_DeleteBusinessObject_ConfirmedIsFalse_ShouldNotDeleteBO()
        {
            //---------------Set up test pack-------------------

            var confirmer = new ConfirmerFake(false);
            var boToDelete = MockRepository.GenerateStub<IBusinessObject>();
            var confirmingBusinessObjectDeletor = new ConfirmingBusinessObjectDeletor(confirmer);
            //---------------Assert Precondition----------------
            Assert.IsFalse(confirmer.WillBeConfirmed);
            //---------------Execute Test ----------------------
            confirmingBusinessObjectDeletor.DeleteBusinessObject(boToDelete);
            //---------------Test Result -----------------------
            boToDelete.AssertWasNotCalled(o => o.MarkForDelete());
        }
All Usage Examples Of Habanero.Faces.Base.ConfirmingBusinessObjectDeletor::DeleteBusinessObject