public void EnsureNotInvalid_Discarded() { var order = Order.NewObject(); order.Delete(); DomainObjectCheckUtility.EnsureNotInvalid(order, ClientTransaction.Current); }
public void Clear() { DomainObjectCheckUtility.EnsureNotDeleted(GetAssociatedEndPoint().GetDomainObjectReference(), GetAssociatedEndPoint().ClientTransaction); var combinedCommand = GetClearCommand(); combinedCommand.NotifyAndPerform(); }
public void EnsureNotDeleted_Deleted() { var relatedObject = DomainObjectIDs.OrderItem1.GetObject <OrderItem>(); relatedObject.Delete(); DomainObjectCheckUtility.EnsureNotDeleted(relatedObject, TestableClientTransaction); }
public void CheckIfRightTransaction_Works_ForRightSubTransaction() { var order = Order.NewObject(); var subTransaction = TestableClientTransaction.CreateSubTransaction(); DomainObjectCheckUtility.CheckIfRightTransaction(order, subTransaction); }
public void CheckIfRightTransaction_Fails() { var order = Order.NewObject(); using (ClientTransaction.CreateRootTransaction().EnterNonDiscardingScope()) { DomainObjectCheckUtility.CheckIfRightTransaction(order, ClientTransaction.Current); } }
public void Replace(int index, DomainObject value) { ArgumentUtility.CheckNotNull("value", value); CheckClientTransaction(value, "Cannot put DomainObject '{0}' into the collection of property '{1}' of DomainObject '{2}'."); DomainObjectCheckUtility.EnsureNotDeleted(value, GetAssociatedEndPoint().ClientTransaction); DomainObjectCheckUtility.EnsureNotDeleted(GetAssociatedEndPoint().GetDomainObjectReference(), GetAssociatedEndPoint().ClientTransaction); var replaceCommand = GetAssociatedEndPoint().CreateReplaceCommand(index, value); var bidirectionalModification = replaceCommand.ExpandToAllRelatedObjects(); bidirectionalModification.NotifyAndPerform(); GetAssociatedEndPoint().Touch(); }
public void Insert(int index, DomainObject domainObject) { ArgumentUtility.CheckNotNull("domainObject", domainObject); CheckClientTransaction(domainObject, "Cannot insert DomainObject '{0}' into collection of property '{1}' of DomainObject '{2}'."); DomainObjectCheckUtility.EnsureNotDeleted(domainObject, GetAssociatedEndPoint().ClientTransaction); DomainObjectCheckUtility.EnsureNotDeleted(GetAssociatedEndPoint().GetDomainObjectReference(), GetAssociatedEndPoint().ClientTransaction); var insertCommand = GetAssociatedEndPoint().CreateInsertCommand(domainObject, index); var bidirectionalModification = insertCommand.ExpandToAllRelatedObjects(); bidirectionalModification.NotifyAndPerform(); GetAssociatedEndPoint().Touch(); }
public bool Remove(DomainObject domainObject) { ArgumentUtility.CheckNotNull("domainObject", domainObject); CheckClientTransaction(domainObject, "Cannot remove DomainObject '{0}' from collection of property '{1}' of DomainObject '{2}'."); DomainObjectCheckUtility.EnsureNotDeleted(domainObject, GetAssociatedEndPoint().ClientTransaction); DomainObjectCheckUtility.EnsureNotDeleted(GetAssociatedEndPoint().GetDomainObjectReference(), GetAssociatedEndPoint().ClientTransaction); var containsObjectID = ContainsObjectID(domainObject.ID); if (containsObjectID) { CreateAndExecuteRemoveCommand(domainObject); } GetAssociatedEndPoint().Touch(); return(containsObjectID); }
public bool Remove(ObjectID objectID) { ArgumentUtility.CheckNotNull("objectID", objectID); DomainObjectCheckUtility.EnsureNotDeleted(GetAssociatedEndPoint().GetDomainObjectReference(), GetAssociatedEndPoint().ClientTransaction); var domainObject = GetObject(objectID); if (domainObject != null) { // we can rely on the fact that this object is not deleted, otherwise we wouldn't have got it Assertion.IsTrue(domainObject.TransactionContext[GetAssociatedEndPoint().ClientTransaction].State != StateType.Deleted); CreateAndExecuteRemoveCommand(domainObject); } GetAssociatedEndPoint().Touch(); return(domainObject != null); }
public IDataManagementCommand CreateDeleteCommand(DomainObject deletedObject) { ArgumentUtility.CheckNotNull("deletedObject", deletedObject); // This uses IsEnlisted rather than a RootTransaction check because the DomainObject reference is used inside the ClientTransaction, and we // explicitly want to allow only objects enlisted in the transaction. if (!_clientTransaction.IsEnlisted(deletedObject)) { throw CreateClientTransactionsDifferException( "Cannot delete DomainObject '{0}', because it belongs to a different ClientTransaction.", deletedObject.ID); } DomainObjectCheckUtility.EnsureNotInvalid(deletedObject, ClientTransaction); if (deletedObject.TransactionContext[_clientTransaction].State == StateType.Deleted) { return(new NopCommand()); } return(new DeleteCommand(_clientTransaction, deletedObject, _transactionEventSink)); }
public void CheckIfRightTransaction_Works_ForLeftSubTransaction() { var order = TestableClientTransaction.CreateSubTransaction().ExecuteInScope(() => Order.NewObject()); DomainObjectCheckUtility.CheckIfRightTransaction(order, TestableClientTransaction); }
public void CheckIfRightTransaction_Works_ForSameRootTransaction() { var order = Order.NewObject(); DomainObjectCheckUtility.CheckIfRightTransaction(order, ClientTransaction.Current); }