示例#1
0
        public static void ThrowIfFailure(this IDocumentResult result)
        {
            if (result.Success)
            {
                return;
            }

            result.EnsureSuccess();
        }
        public override TEntity Update(TEntity entity)
        {
            ActionFilterExecuter.ExecuteModificationAuditFilter <TEntity, string>(entity);

            IDocumentResult <TEntity> result = Session.Bucket.Upsert(new Document <TEntity>
            {
                Content = entity,
                Id      = $"{typeof(TEntity).Name}:{entity.Id}"
            });

            result.EnsureSuccess();

            return(result.Content);
        }
        public override TEntity Insert(TEntity entity)
        {
            entity.Id = GuidGenerator.Create().ToString("N");
            ActionFilterExecuter.ExecuteCreationAuditFilter <TEntity, string>(entity);

            IDocumentResult <TEntity> result = Session.Bucket.Insert(new Document <TEntity>
            {
                Content = entity,
                Id      = $"{typeof(TEntity).Name}:{entity.Id}"
            });

            result.EnsureSuccess();

            return(result.Content);
        }
        public override TEntity Update(TEntity entity)
        {
            ActionFilterExecuter.ExecuteModificationAuditFilter<TEntity, string>(entity);

            EntityChangeEventHelper.PublishEntityUpdatingEvent(entity);

            IDocumentResult<TEntity> result = Session.Bucket.Upsert(new Document<TEntity>
            {
                Content = entity,
                Id = $"{typeof(TEntity).Name}:{entity.Id}"
            });

            result.EnsureSuccess();

            EntityChangeEventHelper.PublishEntityUpdatedEventOnUowCompleted(entity);

            return result.Content;
        }
        public override TEntity Insert(TEntity entity)
        {
            entity.Id = GuidGenerator.Create().ToString("N");
            ActionFilterExecuter.ExecuteCreationAuditFilter<TEntity, string>(entity);

            EntityChangeEventHelper.PublishEntityCreatingEvent(entity);

            IDocumentResult<TEntity> result = Session.Bucket.Insert(new Document<TEntity>
            {
                Content = entity,
                Id = $"{typeof(TEntity).Name}:{entity.Id}"
            });

            result.EnsureSuccess();

            EntityChangeEventHelper.PublishEntityCreatedEventOnUowCompleted(entity);

            return result.Content;
        }
示例#6
0
        public void DocumentResult_EnsureSuccess_Throws_ArguementNulException_When_Result_Is_Null()
        {
            IDocumentResult result = null;

            Assert.Throws <ArgumentNullException>(() => result.EnsureSuccess());
        }