Beispiel #1
0
        public CommandResult <Delete <TEntity> > Delete <TEntity>(TEntity entity) where TEntity : Entity
        {
            var entityService = GetEntityService <TEntity>();

            if (!entityService.Validate(entity))
            {
                return new CommandResult <Delete <TEntity> >(null)
                       {
                           IsSuccess = false
                       }
            }
            ;

            entityService.Create(entity);
            var command = new Delete <TEntity>(entity);

            Eventer.Raise <PersistenceEvent>(new Deleted <TEntity>(entity));
            Persister.Delete(entity);

            var commandResult = new CommandResult <Delete <TEntity> >(command)
            {
                IsSuccess = true
            };

            return(commandResult);
        }
 /// <summary></summary>
 public override void Execute()
 {
     if (Persister.HasCache)
     {
         lck = Persister.Cache.Lock(Id, version);
     }
     Persister.Delete(Id, version, Instance, Session);
     Session.PostDelete(Instance);
 }
Beispiel #3
0
        public void CanDeleteSaga()
        {
            var mySagaDataId = Guid.NewGuid();
            var mySagaData   = new SimpleSagaData
            {
                Id         = mySagaDataId,
                SomeString = "whoolala"
            };

            Persister.Insert(mySagaData, new[] { "SomeString" });
            Persister.Delete(mySagaData);

            var sagaData = Persister.Find <SimpleSagaData>("Id", mySagaDataId);

            sagaData.ShouldBe(null);
        }
Beispiel #4
0
        public void ConcurrentDeleteAndUpdateThrowsOnDelete()
        {
            var indexBySomeString = new[] { "Id" };
            var id             = Guid.NewGuid();
            var simpleSagaData = new SimpleSagaData {
                Id = id
            };

            Persister.Insert(simpleSagaData, indexBySomeString);
            var sagaData1 = Persister.Find <SimpleSagaData>("Id", id);

            EnterAFakeMessageContext();
            var sagaData2 = Persister.Find <SimpleSagaData>("Id", id);

            sagaData2.SomeString = "Some new value";
            Persister.Update(sagaData2, indexBySomeString);
            ReturnToOriginalMessageContext();

            Assert.Throws <OptimisticLockingException>(() => Persister.Delete(sagaData1));
        }