Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
GetProperties from ISchemaProperty change to async method / Export with ExportManager change to async method
support294c7c23123d
diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandSchemaProperty.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandSchemaProperty.csindex dd6447eea..1ba15baef 100644--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandSchemaProperty.cs+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/BrandSchemaProperty.cs@@ -14,7 +14,7 @@ namespace Grand.Business.Catalog.Services.ExportImport_pictureService = pictureService;}- public virtual PropertyByName<Brand>[] GetProperties()+ public virtual async Task<PropertyByName<Brand>[]> GetProperties(){var properties = new[]{@@ -34,7 +34,7 @@ namespace Grand.Business.Catalog.Services.ExportImportnew PropertyByName<Brand>("DisplayOrder", p => p.DisplayOrder),new PropertyByName<Brand>("ExternalId", p => p.ExternalId)};- return properties;+ return await Task.FromResult(properties);}protected virtual async Task<string> GetPictures(string pictureId)diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/CategorySchemaProperty.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/CategorySchemaProperty.csindex a47ace0f4..8c1364b21 100644--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/CategorySchemaProperty.cs+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/CategorySchemaProperty.cs@@ -14,7 +14,7 @@ namespace Grand.Business.Catalog.Services.ExportImport_pictureService = pictureService;}- public virtual PropertyByName<Category>[] GetProperties()+ public virtual async Task<PropertyByName<Category>[]> GetProperties(){var properties = new[]{@@ -40,7 +40,7 @@ namespace Grand.Business.Catalog.Services.ExportImportnew PropertyByName<Category>("Icon", p => p.Icon),new PropertyByName<Category>("DisplayOrder", p => p.DisplayOrder)};- return properties;+ return await Task.FromResult(properties);}protected virtual async Task<string> GetPictures(string pictureId){diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionSchemaProperty.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionSchemaProperty.csindex 16e443fda..08f52250f 100644--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionSchemaProperty.cs+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/CollectionSchemaProperty.cs@@ -14,7 +14,7 @@ namespace Grand.Business.Catalog.Services.ExportImport_pictureService = pictureService;}- public virtual PropertyByName<Collection>[] GetProperties()+ public virtual async Task<PropertyByName<Collection>[]> GetProperties(){var properties = new[]{@@ -34,7 +34,7 @@ namespace Grand.Business.Catalog.Services.ExportImportnew PropertyByName<Collection>("DisplayOrder", p => p.DisplayOrder),new PropertyByName<Collection>("ExternalId", p => p.ExternalId)};- return properties;+ return await Task.FromResult(properties);}protected virtual async Task<string> GetPictures(string pictureId)diff --git a/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductSchemaProperty.cs b/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductSchemaProperty.csindex dd1471a31..05d6cbd62 100644--- a/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductSchemaProperty.cs+++ b/src/Business/Grand.Business.Catalog/Services/ExportImport/ProductSchemaProperty.cs@@ -15,7 +15,7 @@ namespace Grand.Business.Catalog.Services.ExportImport_pictureService = pictureService;}- public virtual PropertyByName<Product>[] GetProperties()+ public virtual async Task<PropertyByName<Product>[]> GetProperties(){var properties = new[]{@@ -121,7 +121,7 @@ namespace Grand.Business.Catalog.Services.ExportImportnew PropertyByName<Product>("Picture2", p => GetPictures(p).Result[1]),new PropertyByName<Product>("Picture3", p => GetPictures(p).Result[2])};- return properties;+ return await Task.FromResult(properties);}private async Task<string[]> GetPictures(Product product)diff --git a/src/Business/Grand.Business.Checkout/Services/ExportImpot/OrderSchemaProperty.cs b/src/Business/Grand.Business.Checkout/Services/ExportImpot/OrderSchemaProperty.csindex 3c9423dba..6d03bff9b 100644--- a/src/Business/Grand.Business.Checkout/Services/ExportImpot/OrderSchemaProperty.cs+++ b/src/Business/Grand.Business.Checkout/Services/ExportImpot/OrderSchemaProperty.cs@@ -14,7 +14,7 @@ namespace Grand.Business.Checkout.Services.ExportImport_countryService = countryService;}- public virtual PropertyByName<Order>[] GetProperties()+ public virtual async Task<PropertyByName<Order>[]> GetProperties(){var properties = new[]{@@ -73,7 +73,7 @@ namespace Grand.Business.Checkout.Services.ExportImportnew PropertyByName<Order>("ShippingPhoneNumber",p=>p.ShippingAddress?.PhoneNumber),new PropertyByName<Order>("ShippingFaxNumber", p=>p.ShippingAddress?.FaxNumber)};- return properties;+ return await Task.FromResult(properties);}}}diff --git a/src/Business/Grand.Business.Common/Services/ExportImport/CountrySchemaProperty.cs b/src/Business/Grand.Business.Common/Services/ExportImport/CountrySchemaProperty.csindex 510641b8e..eb5ccc8c2 100644--- a/src/Business/Grand.Business.Common/Services/ExportImport/CountrySchemaProperty.cs+++ b/src/Business/Grand.Business.Common/Services/ExportImport/CountrySchemaProperty.cs@@ -5,7 +5,7 @@ namespace Grand.Business.Common.Services.ExportImport{public class CountrySchemaProperty : ISchemaProperty<CountryStates>{- public virtual PropertyByName<CountryStates>[] GetProperties()+ public virtual async Task<PropertyByName<CountryStates>[]> GetProperties(){var properties = new[]{@@ -15,7 +15,7 @@ namespace Grand.Business.Common.Services.ExportImportnew PropertyByName<CountryStates>("DisplayOrder", p => p.DisplayOrder),new PropertyByName<CountryStates>("Published", p => p.Published)};- return properties;+ return await Task.FromResult(properties);}}}diff --git a/src/Business/Grand.Business.Common/Services/ExportImport/ExportManager.cs b/src/Business/Grand.Business.Common/Services/ExportImport/ExportManager.csindex 24211052a..a07d3744e 100644--- a/src/Business/Grand.Business.Common/Services/ExportImport/ExportManager.cs+++ b/src/Business/Grand.Business.Common/Services/ExportImport/ExportManager.cs@@ -13,9 +13,9 @@ namespace Grand.Business.Common.Services.ExportImport_schemaProperty = schemaProperty;}- public virtual byte[] Export(IEnumerable<T> entity)+ public virtual async Task<byte[]> Export(IEnumerable<T> entity){- return _exportProvider.ExportToByte(_schemaProperty.GetProperties(), entity);+ return _exportProvider.ExportToByte(await _schemaProperty.GetProperties(), entity);}}}diff --git a/src/Business/Grand.Business.Core/Interfaces/ExportImport/IExportManager.cs b/src/Business/Grand.Business.Core/Interfaces/ExportImport/IExportManager.csindex 8f71c1e45..7d13ae2ef 100644--- a/src/Business/Grand.Business.Core/Interfaces/ExportImport/IExportManager.cs+++ b/src/Business/Grand.Business.Core/Interfaces/ExportImport/IExportManager.cs@@ -6,7 +6,7 @@/// Export list of entity to XLSX/// </summary>/// <param name="entity">list of entity</param>- byte[] Export(IEnumerable<T> entity);+ Task<byte[]> Export(IEnumerable<T> entity);}}diff --git a/src/Business/Grand.Business.Core/Interfaces/ExportImport/ISchemaProperty.cs b/src/Business/Grand.Business.Core/Interfaces/ExportImport/ISchemaProperty.csindex a82fe5673..56c53312f 100644--- a/src/Business/Grand.Business.Core/Interfaces/ExportImport/ISchemaProperty.cs+++ b/src/Business/Grand.Business.Core/Interfaces/ExportImport/ISchemaProperty.cs@@ -4,6 +4,6 @@ namespace Grand.Business.Core.Interfaces.ExportImport{public interface ISchemaProperty<T>{- PropertyByName<T>[] GetProperties();+ Task<PropertyByName<T>[]> GetProperties();}}diff --git a/src/Business/Grand.Business.Customers/Services/AddressSchemaProperty.cs b/src/Business/Grand.Business.Customers/Services/AddressSchemaProperty.csindex 039b6b37d..c6ec676f1 100644--- a/src/Business/Grand.Business.Customers/Services/AddressSchemaProperty.cs+++ b/src/Business/Grand.Business.Customers/Services/AddressSchemaProperty.cs@@ -14,7 +14,7 @@ namespace Grand.Business.Customers.Services_countryService = countryService;}- public virtual PropertyByName<Address>[] GetProperties()+ public virtual async Task<PropertyByName<Address>[]> GetProperties(){var properties = new[]{@@ -28,7 +28,7 @@ namespace Grand.Business.Customers.Servicesnew PropertyByName<Address>("City", p=>p.City),new PropertyByName<Address>("Country", p=> !string.IsNullOrEmpty(p.CountryId) ? _countryService.GetCountryById(p.CountryId).Result?.Name : "")};- return properties;+ return await Task.FromResult(properties);}}}diff --git a/src/Business/Grand.Business.Customers/Services/CustomerSchemaProperty.cs b/src/Business/Grand.Business.Customers/Services/CustomerSchemaProperty.csindex 83a4e9350..9340ea8f9 100644--- a/src/Business/Grand.Business.Customers/Services/CustomerSchemaProperty.cs+++ b/src/Business/Grand.Business.Customers/Services/CustomerSchemaProperty.cs@@ -7,7 +7,7 @@ namespace Grand.Business.Customers.Services{public class CustomerSchemaProperty : ISchemaProperty<Customer>{- public virtual PropertyByName<Customer>[] GetProperties()+ public virtual async Task<PropertyByName<Customer>[]> GetProperties(){var properties = new[]{@@ -38,7 +38,7 @@ namespace Grand.Business.Customers.Servicesnew PropertyByName<Customer>("VatNumber", p => p.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.VatNumber)),new PropertyByName<Customer>("VatNumberStatusId", p => p.GetUserFieldFromEntity<int>(SystemCustomerFieldNames.VatNumberStatusId))};- return properties;+ return await Task.FromResult(properties);}}}diff --git a/src/Web/Grand.Web.Admin/Controllers/BrandController.cs b/src/Web/Grand.Web.Admin/Controllers/BrandController.csindex c8c105fe8..616407c75 100644--- a/src/Web/Grand.Web.Admin/Controllers/BrandController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/BrandController.cs@@ -336,7 +336,7 @@ namespace Grand.Web.Admin.Controllers{try{- var bytes = exportManager.Export(await _brandService.GetAllBrands(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));+ var bytes = await exportManager.Export(await _brandService.GetAllBrands(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));return File(bytes, "text/xls", "brands.xlsx");}catch (Exception exc)diff --git a/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs b/src/Web/Grand.Web.Admin/Controllers/CategoryController.csindex 949b17c03..42917d63e 100644--- a/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs@@ -295,7 +295,7 @@ namespace Grand.Web.Admin.Controllers{try{- var bytes = exportManager.Export(await _categoryService.GetAllCategories(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));+ var bytes = await exportManager.Export(await _categoryService.GetAllCategories(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));return File(bytes, "text/xls", "categories.xlsx");}catch (Exception exc)diff --git a/src/Web/Grand.Web.Admin/Controllers/CollectionController.cs b/src/Web/Grand.Web.Admin/Controllers/CollectionController.csindex fcad9a1e8..a92328a9b 100644--- a/src/Web/Grand.Web.Admin/Controllers/CollectionController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CollectionController.cs@@ -336,7 +336,7 @@ namespace Grand.Web.Admin.Controllers{try{- var bytes = exportManager.Export(await _collectionService.GetAllCollections(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));+ var bytes = await exportManager.Export(await _collectionService.GetAllCollections(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));return File(bytes, "text/xls", "collections.xlsx");}catch (Exception exc)diff --git a/src/Web/Grand.Web.Admin/Controllers/CountryController.cs b/src/Web/Grand.Web.Admin/Controllers/CountryController.csindex 1b422439c..c9d5c2b9a 100644--- a/src/Web/Grand.Web.Admin/Controllers/CountryController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CountryController.cs@@ -350,7 +350,7 @@ namespace Grand.Web.Admin.ControllersPublished = s.Published};- var bytes = _exportManager.Export(query);+ var bytes = await _exportManager.Export(query);return File(bytes, "text/xls", "country.xlsx");}diff --git a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs b/src/Web/Grand.Web.Admin/Controllers/CustomerController.csindex 64d3fa05d..4a1d7c909 100644--- a/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CustomerController.cs@@ -1151,7 +1151,7 @@ namespace Grand.Web.Admin.Controllerstry{- byte[] bytes = _exportManager.Export(customers);+ byte[] bytes = await _exportManager.Export(customers);return File(bytes, "text/xls", "customers.xlsx");}catch (Exception exc)@@ -1175,7 +1175,7 @@ namespace Grand.Web.Admin.Controllerscustomers.AddRange(await _customerService.GetCustomersByIds(ids));}- byte[] bytes = _exportManager.Export(customers);+ byte[] bytes = await _exportManager.Export(customers);return File(bytes, "text/xls", "customers.xlsx");}diff --git a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs b/src/Web/Grand.Web.Admin/Controllers/OrderController.csindex add527395..e58fd979e 100644--- a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs@@ -199,7 +199,7 @@ namespace Grand.Web.Admin.Controllersvar orders = await _orderViewModelService.PrepareOrders(model);try{- byte[] bytes = _exportManager.Export(orders);+ byte[] bytes = await _exportManager.Export(orders);return File(bytes, "text/xls", "orders.xlsx");}catch (Exception exc)@@ -230,7 +230,7 @@ namespace Grand.Web.Admin.Controllers{orders = orders.Where(x => x.StoreId == _workContext.CurrentCustomer.StaffStoreId).ToList();}- byte[] bytes = _exportManager.Export(orders);+ byte[] bytes = await _exportManager.Export(orders);return File(bytes, "text/xls", "orders.xlsx");}diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductController.csindex 08b27c1db..5c20ea82a 100644--- a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs@@ -1563,7 +1563,7 @@ namespace Grand.Web.Admin.Controllersvar products = await _productViewModelService.PrepareProducts(model);try{- byte[] bytes = exportManager.Export(products);+ byte[] bytes = await exportManager.Export(products);return File(bytes, "text/xls", "products.xlsx");}catch (Exception exc)@@ -1592,7 +1592,7 @@ namespace Grand.Web.Admin.Controllersproducts = products.Where(p => p.VendorId == _workContext.CurrentVendor.Id).ToList();}- byte[] bytes = exportManager.Export(products);+ byte[] bytes = await exportManager.Export(products);return File(bytes, "text/xls", "products.xlsx");}diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomerDataHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomerDataHandler.csindex 4c6b59222..569ec47e7 100644--- a/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomerDataHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetCustomerDataHandler.cs@@ -36,9 +36,9 @@ namespace Grand.Web.Features.Handlers.CustomerscustomerId: request.Customer.Id);_exportProvider- .BuilderExportToByte(_customerSchemaProperty.GetProperties(), new List<Customer> { request.Customer })- .BuilderExportToByte(_addresSchemaProperty.GetProperties(), request.Customer.Addresses)- .BuilderExportToByte(_orderSchemaProperty.GetProperties(), orders);+ .BuilderExportToByte(await _customerSchemaProperty.GetProperties(), new List<Customer> { request.Customer })+ .BuilderExportToByte(await _addresSchemaProperty.GetProperties(), request.Customer.Addresses)+ .BuilderExportToByte(await _orderSchemaProperty.GetProperties(), orders);return _exportProvider.BuilderExportToByte();}