From 0f7458254e346111e60870cfd089b1e792e55eb1 Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Wed, 11 Sep 2019 20:54:26 -0700 Subject: [PATCH] Retain store ids when filtering invoices --- .../Controllers/InvoiceController.UI.cs | 4 +++ .../Models/InvoicingModels/InvoicesModel.cs | 2 +- .../Views/Invoice/ListInvoices.cshtml | 26 ++++++++++++------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index a902ee263..e5ef213e8 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -398,11 +398,15 @@ namespace BTCPayServer.Controllers [BitpayAPIConstraint(false)] public async Task ListInvoices(string searchTerm = null, int skip = 0, int count = 50, int timezoneOffset = 0) { + var fs = new SearchString(searchTerm); + var storeIds = fs.GetFilterArray("storeid") != null ? fs.GetFilterArray("storeid") : new List().ToArray(); + var model = new InvoicesModel { SearchTerm = searchTerm, Skip = skip, Count = count, + StoreIds = storeIds, TimezoneOffset = timezoneOffset }; InvoiceQuery invoiceQuery = GetInvoiceQuery(searchTerm, timezoneOffset); diff --git a/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs b/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs index 26bcddfed..f516ec091 100644 --- a/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs +++ b/BTCPayServer/Models/InvoicingModels/InvoicesModel.cs @@ -13,8 +13,8 @@ namespace BTCPayServer.Models.InvoicingModels public int Total { get; set; } public string SearchTerm { get; set; } public int? TimezoneOffset { get; set; } - public List Invoices { get; set; } = new List(); + public string[] StoreIds { get; set; } } public class InvoiceModel diff --git a/BTCPayServer/Views/Invoice/ListInvoices.cshtml b/BTCPayServer/Views/Invoice/ListInvoices.cshtml index daabddd24..5dd86093f 100644 --- a/BTCPayServer/Views/Invoice/ListInvoices.cshtml +++ b/BTCPayServer/Views/Invoice/ListInvoices.cshtml @@ -73,17 +73,25 @@ + + @{ + var storeIds = String.Join( + "", + Model.StoreIds.Select(storeId => string.Format(",storeid:{0}", storeId)) + ); + } +