private bool DeleteItem() { bool success = false; try { GroupType item = new GroupType(ItemID); if (item.Delete()) { success = true; ItemID = 0; } else { // display message that item is im use } } catch (Exception ex) { SPA.Error.WriteError(ex); if (ShowDebug) { lblErrorMessage.Text = ex.ToString(); } } return(success); }
public void DeleteGroupType_WithGroup() { DatabaseFixtures dbFixtures = new DatabaseFixtures(); using (ClientTransaction.CreateRootTransaction().EnterNonDiscardingScope()) { Tenant tenant = dbFixtures.CreateAndCommitOrganizationalStructureWithTwoTenants(ClientTransaction.Current); Group group = Group.FindByTenant(tenant.GetHandle()).Where(g => g.Name == "parentGroup0").Single(); GroupType groupType = group.GroupType; groupType.Delete(); } }
public void DeleteGroupType_WithGroupTypePosition() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { GroupType groupType = testHelper.CreateGroupType("GroupType"); Position position = testHelper.CreatePosition("Position"); GroupTypePosition concretePosition = testHelper.CreateGroupTypePosition(groupType, position); groupType.Delete(); Assert.That(concretePosition.State, Is.EqualTo(StateType.Invalid)); } }
public void DeleteGroupType_WithAccessControlEntry() { DatabaseFixtures dbFixtures = new DatabaseFixtures(); AccessControlTestHelper testHelper = new AccessControlTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { dbFixtures.CreateEmptyDomain(); GroupType groupType = testHelper.CreateGroupType("GroupType"); AccessControlEntry ace = testHelper.CreateAceWithBranchOfOwningGroup(groupType); ClientTransaction.Current.Commit(); groupType.Delete(); ClientTransaction.Current.Commit(); Assert.That(ace.State, Is.EqualTo(StateType.Invalid)); } }