From d99bc0039697002831ec7183695472ffbb86c040 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Fri, 9 Oct 2020 15:26:26 +0200 Subject: [PATCH] minor updates --- .gitignore | 3 +-- zero.Core/Api/BackofficeApi.cs | 13 +---------- .../RavenDocumentStoreExtensions.cs | 22 ++++++++++++++++++- zero.Debug/zero.Debug.csproj | 2 +- .../App/components/buttons/add-button.vue | 7 +++++- zero.Web.UI/App/components/buttons/button.vue | 8 +++++++ zero.Web.UI/Sass/Modules/_button.scss | 20 +++++++++++++++++ zero.sln | 21 +++++++++++++++++- 8 files changed, 78 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 4da838ae..c1b13a25 100644 --- a/.gitignore +++ b/.gitignore @@ -270,5 +270,4 @@ Temp/ **/Assets/setup.* **/Assets/*.js deps/*.dll -zero.Commerce/ -Hofbauer.To.Zero/ \ No newline at end of file +commerce/ \ No newline at end of file diff --git a/zero.Core/Api/BackofficeApi.cs b/zero.Core/Api/BackofficeApi.cs index 7c2aaa3c..17e2d5d4 100644 --- a/zero.Core/Api/BackofficeApi.cs +++ b/zero.Core/Api/BackofficeApi.cs @@ -281,18 +281,7 @@ namespace zero.Core.Api /// public async Task> Purge(string querySuffix = null, Parameters parameters = null) { - var collectionName = Raven.Conventions.FindCollectionName(typeof(T)); - - var operationQuery = new DeleteByQueryOperation(new IndexQuery() - { - Query = $"from {collectionName} c {querySuffix ?? String.Empty}", - QueryParameters = parameters - }); - - Operation operation = await Raven.Operations.SendAsync(operationQuery); - - await operation.WaitForCompletionAsync(TimeSpan.FromSeconds(30)); - + await Raven.PurgeAsync(querySuffix, parameters); return EntityResult.Success(); } } diff --git a/zero.Core/Extensions/RavenDocumentStoreExtensions.cs b/zero.Core/Extensions/RavenDocumentStoreExtensions.cs index 58cdfb4d..f0b1fa84 100644 --- a/zero.Core/Extensions/RavenDocumentStoreExtensions.cs +++ b/zero.Core/Extensions/RavenDocumentStoreExtensions.cs @@ -1,6 +1,9 @@ -using Raven.Client.Documents; +using Raven.Client; +using Raven.Client.Documents; using Raven.Client.Documents.Conventions; +using Raven.Client.Documents.Operations; using Raven.Client.Documents.Operations.CompareExchange; +using Raven.Client.Documents.Queries; using Raven.Client.Json.Serialization.NewtonsoftJson; using System; using System.Linq; @@ -143,5 +146,22 @@ namespace zero.Core.Extensions CompareExchangeResult result = await store.Operations.SendAsync(operation).ConfigureAwait(false); return result.Successful; } + + + /// + public static async Task PurgeAsync(this IDocumentStore store, string querySuffix = null, Parameters parameters = null) + { + var collectionName = store.Conventions.FindCollectionName(typeof(T)); + + var operationQuery = new DeleteByQueryOperation(new IndexQuery() + { + Query = $"from {collectionName} c {querySuffix ?? String.Empty}", + QueryParameters = parameters + }); + + Operation operation = await store.Operations.SendAsync(operationQuery); + + await operation.WaitForCompletionAsync(TimeSpan.FromSeconds(30)); + } } } diff --git a/zero.Debug/zero.Debug.csproj b/zero.Debug/zero.Debug.csproj index 4f66016f..c265bdad 100644 --- a/zero.Debug/zero.Debug.csproj +++ b/zero.Debug/zero.Debug.csproj @@ -5,7 +5,7 @@ - + diff --git a/zero.Web.UI/App/components/buttons/add-button.vue b/zero.Web.UI/App/components/buttons/add-button.vue index 3c4a3cd5..e06b4eaf 100644 --- a/zero.Web.UI/App/components/buttons/add-button.vue +++ b/zero.Web.UI/App/components/buttons/add-button.vue @@ -1,6 +1,7 @@