コード例 #1
0
        public override void Delete(TEntity entity)
        {
            ActionFilterExecuter.ExecuteDeletionAuditFilter <TEntity, string>(entity);

            EntityChangeEventHelper.TriggerEntityDeletingEvent(entity);

            if (entity is ISoftDelete)
            {
                Session.Bucket.Upsert(new Document <TEntity>
                {
                    Content = entity,
                    Id      = $"{typeof(TEntity).Name}:{entity.Id}"
                }).EnsureSuccess();
            }
            else
            {
                Session.Bucket.Remove(new Document <TEntity>
                {
                    Content = entity,
                    Id      = $"{typeof(TEntity).Name}:{entity.Id}"
                }).EnsureSuccess();
            }

            EntityChangeEventHelper.TriggerEntityDeletedEventOnUowCompleted(entity);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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 override void Delete(TEntity entity)
        {
            ActionFilterExecuter.ExecuteDeletionAuditFilter <TEntity, string>(entity);

            if (entity is ISoftDelete)
            {
                Session.Bucket.Upsert(new Document <TEntity>
                {
                    Content = entity,
                    Id      = $"{typeof(TEntity).Name}:{entity.Id}"
                }).EnsureSuccess();
            }
            else
            {
                Session.Bucket.Remove(new Document <TEntity>
                {
                    Content = entity,
                    Id      = $"{typeof(TEntity).Name}:{entity.Id}"
                }).EnsureSuccess();
            }
        }