Skip to content

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.

Admin - minor changes

support177d68b1fb0d
diff --git a/src/Web/Grand.Web.Admin/Controllers/BrandController.cs b/src/Web/Grand.Web.Admin/Controllers/BrandController.cs
index 19707773d..c8c105fe8 100644
--- a/src/Web/Grand.Web.Admin/Controllers/BrandController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/BrandController.cs
@@ -25,6 +25,7 @@ namespace Grand.Web.Admin.Controllers
public partial class BrandController : BaseAdminController
{
#region Fields
+
private readonly IBrandViewModelService _brandViewModelService;
private readonly IBrandService _brandService;
private readonly IWorkContext _workContext;
@@ -32,9 +33,8 @@ namespace Grand.Web.Admin.Controllers
private readonly ILanguageService _languageService;
private readonly ITranslationService _translationService;
private readonly IGroupService _groupService;
- private readonly IExportManager<Brand> _exportManager;
- private readonly IImportManager<BrandDto> _importManager;
private readonly IPictureViewModelService _pictureViewModelService;
+
#endregion
#region Constructors
@@ -47,8 +47,6 @@ namespace Grand.Web.Admin.Controllers
ILanguageService languageService,
ITranslationService translationService,
IGroupService groupService,
- IExportManager<Brand> exportManager,
- IImportManager<BrandDto> importManager,
IPictureViewModelService pictureViewModelService)
{
_brandViewModelService = brandViewModelService;
@@ -58,8 +56,6 @@ namespace Grand.Web.Admin.Controllers
_languageService = languageService;
_translationService = translationService;
_groupService = groupService;
- _exportManager = exportManager;
- _importManager = importManager;
_pictureViewModelService = pictureViewModelService;
}
@@ -336,11 +332,11 @@ namespace Grand.Web.Admin.Controllers
#region Export / Import
[PermissionAuthorizeAction(PermissionActionName.Export)]
- public async Task<IActionResult> ExportXlsx()
+ public async Task<IActionResult> ExportXlsx([FromServices] IExportManager<Brand> exportManager)
{
try
{
- var bytes = _exportManager.Export(await _brandService.GetAllBrands(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));
+ var bytes = exportManager.Export(await _brandService.GetAllBrands(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));
return File(bytes, "text/xls", "brands.xlsx");
}
catch (Exception exc)
@@ -352,7 +348,7 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Import)]
[HttpPost]
- public async Task<IActionResult> ImportFromXlsx(IFormFile importexcelfile, [FromServices] IWorkContext workContext)
+ public async Task<IActionResult> ImportFromXlsx(IFormFile importexcelfile, [FromServices] IWorkContext workContext, [FromServices] IImportManager<BrandDto> importManager)
{
//a vendor and staff cannot import collections
if (workContext.CurrentVendor != null || await _groupService.IsStaff(_workContext.CurrentCustomer))
@@ -362,7 +358,7 @@ namespace Grand.Web.Admin.Controllers
{
if (importexcelfile != null && importexcelfile.Length > 0)
{
- await _importManager.Import(importexcelfile.OpenReadStream());
+ await importManager.Import(importexcelfile.OpenReadStream());
}
else
{
diff --git a/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs b/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs
index abb32a034..949b17c03 100644
--- a/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/CategoryController.cs
@@ -28,8 +28,6 @@ namespace Grand.Web.Admin.Controllers
private readonly ICategoryViewModelService _categoryViewModelService;
private readonly ILanguageService _languageService;
private readonly ITranslationService _translationService;
- private readonly IExportManager<Category> _exportManager;
- private readonly IImportManager<CategoryDto> _importManager;
private readonly IWorkContext _workContext;
private readonly IGroupService _groupService;
private readonly IPictureViewModelService _pictureViewModelService;
@@ -42,8 +40,6 @@ namespace Grand.Web.Admin.Controllers
ICategoryViewModelService categoryViewModelService,
ILanguageService languageService,
ITranslationService translationService,
- IExportManager<Category> exportManager,
- IImportManager<CategoryDto> importManager,
IWorkContext workContext,
IGroupService groupService,
IPictureViewModelService pictureViewModelService)
@@ -52,10 +48,8 @@ namespace Grand.Web.Admin.Controllers
_categoryViewModelService = categoryViewModelService;
_languageService = languageService;
_translationService = translationService;
- _exportManager = exportManager;
_workContext = workContext;
_groupService = groupService;
- _importManager = importManager;
_pictureViewModelService = pictureViewModelService;
}
@@ -297,11 +291,11 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Export)]
- public async Task<IActionResult> ExportXlsx()
+ public async Task<IActionResult> ExportXlsx([FromServices] IExportManager<Category> exportManager)
{
try
{
- var bytes = _exportManager.Export(await _categoryService.GetAllCategories(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));
+ var bytes = exportManager.Export(await _categoryService.GetAllCategories(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));
return File(bytes, "text/xls", "categories.xlsx");
}
catch (Exception exc)
@@ -313,7 +307,7 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Import)]
[HttpPost]
- public async Task<IActionResult> ImportFromXlsx(IFormFile importexcelfile)
+ public async Task<IActionResult> ImportFromXlsx(IFormFile importexcelfile, [FromServices] IImportManager<CategoryDto> importManager)
{
//a vendor and staff cannot import categories
if (_workContext.CurrentVendor != null || await _groupService.IsStaff(_workContext.CurrentCustomer))
@@ -323,7 +317,7 @@ namespace Grand.Web.Admin.Controllers
{
if (importexcelfile != null && importexcelfile.Length > 0)
{
- await _importManager.Import(importexcelfile.OpenReadStream());
+ await importManager.Import(importexcelfile.OpenReadStream());
}
else
{
diff --git a/src/Web/Grand.Web.Admin/Controllers/CollectionController.cs b/src/Web/Grand.Web.Admin/Controllers/CollectionController.cs
index 8a81dd5e3..fcad9a1e8 100644
--- a/src/Web/Grand.Web.Admin/Controllers/CollectionController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/CollectionController.cs
@@ -33,8 +33,6 @@ namespace Grand.Web.Admin.Controllers
private readonly ILanguageService _languageService;
private readonly ITranslationService _translationService;
private readonly IGroupService _groupService;
- private readonly IExportManager<Collection> _exportManager;
- private readonly IImportManager<CollectionDto> _importManager;
private readonly IPictureViewModelService _pictureViewModelService;
#endregion
@@ -49,8 +47,6 @@ namespace Grand.Web.Admin.Controllers
ILanguageService languageService,
ITranslationService translationService,
IGroupService groupService,
- IExportManager<Collection> exportManager,
- IImportManager<CollectionDto> importManager,
IPictureViewModelService pictureViewModelService)
{
_collectionViewModelService = collectionViewModelService;
@@ -60,8 +56,6 @@ namespace Grand.Web.Admin.Controllers
_languageService = languageService;
_translationService = translationService;
_groupService = groupService;
- _exportManager = exportManager;
- _importManager = importManager;
_pictureViewModelService = pictureViewModelService;
}
@@ -338,11 +332,11 @@ namespace Grand.Web.Admin.Controllers
#region Export / Import
[PermissionAuthorizeAction(PermissionActionName.Export)]
- public async Task<IActionResult> ExportXlsx()
+ public async Task<IActionResult> ExportXlsx([FromServices] IExportManager<Collection> exportManager)
{
try
{
- var bytes = _exportManager.Export(await _collectionService.GetAllCollections(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));
+ var bytes = exportManager.Export(await _collectionService.GetAllCollections(showHidden: true, storeId: _workContext.CurrentCustomer.StaffStoreId));
return File(bytes, "text/xls", "collections.xlsx");
}
catch (Exception exc)
@@ -354,7 +348,7 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Import)]
[HttpPost]
- public async Task<IActionResult> ImportFromXlsx(IFormFile importexcelfile, [FromServices] IWorkContext workContext)
+ public async Task<IActionResult> ImportFromXlsx(IFormFile importexcelfile, [FromServices] IWorkContext workContext, [FromServices] IImportManager<CollectionDto> importManager)
{
//a vendor and staff cannot import collections
if (workContext.CurrentVendor != null || await _groupService.IsStaff(_workContext.CurrentCustomer))
@@ -364,7 +358,7 @@ namespace Grand.Web.Admin.Controllers
{
if (importexcelfile != null && importexcelfile.Length > 0)
{
- await _importManager.Import(importexcelfile.OpenReadStream());
+ await importManager.Import(importexcelfile.OpenReadStream());
}
else
{
diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs
index dcd4eff06..a0f325875 100644
--- a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs
@@ -45,8 +45,6 @@ namespace Grand.Web.Admin.Controllers
private readonly IGroupService _groupService;
private readonly ILanguageService _languageService;
private readonly ITranslationService _translationService;
- private readonly IExportManager<Product> _exportManager;
- private readonly IImportManager<ProductDto> _importManager;
private readonly IStoreService _storeService;
private readonly IProductReservationService _productReservationService;
private readonly IAuctionService _auctionService;
@@ -67,8 +65,6 @@ namespace Grand.Web.Admin.Controllers
IGroupService groupService,
ILanguageService languageService,
ITranslationService translationService,
- IExportManager<Product> exportManager,
- IImportManager<ProductDto> importManager,
IStoreService storeService,
IProductReservationService productReservationService,
IAuctionService auctionService,
@@ -84,8 +80,6 @@ namespace Grand.Web.Admin.Controllers
_groupService = groupService;
_languageService = languageService;
_translationService = translationService;
- _exportManager = exportManager;
- _importManager = importManager;
_storeService = storeService;
_productReservationService = productReservationService;
_auctionService = auctionService;
@@ -1570,12 +1564,12 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Export)]
[HttpPost]
- public async Task<IActionResult> ExportExcelAll(ProductListModel model)
+ public async Task<IActionResult> ExportExcelAll(ProductListModel model, [FromServices] IExportManager<Product> exportManager)
{
var products = await _productViewModelService.PrepareProducts(model);
try
{
- byte[] bytes = _exportManager.Export(products);
+ byte[] bytes = exportManager.Export(products);
return File(bytes, "text/xls", "products.xlsx");
}
catch (Exception exc)
@@ -1587,7 +1581,7 @@ namespace Grand.Web.Admin.Controllers
[PermissionAuthorizeAction(PermissionActionName.Export)]
[HttpPost]
- public async Task<IActionResult> ExportExcelSelected(string selectedIds)
+ public async Task<IActionResult> ExportExcelSelected(string selectedIds, [FromServices] IExportManager<Product> exportManager)
{
var products = new List<Product>();
if (selectedIds != null)
@@ -1604,13 +1598,13 @@ namespace Grand.Web.Admin.Controllers
products = products.Where(p => p.VendorId == _workContext.CurrentVendor.Id).ToList();
}
- byte[] bytes = _exportManager.Export(products);
+ byte[] bytes = exportManager.Export(products);
return File(bytes, "text/xls", "products.xlsx");
}
[PermissionAuthorizeAction(PermissionActionName.Import)]
[HttpPost]
- public async Task<IActionResult> ImportExcel(IFormFile importexcelfile)
+ public async Task<IActionResult> ImportExcel(IFormFile importexcelfile, [FromServices] IImportManager<ProductDto> importManager)
{
//a vendor ans staff cannot import products
if (_workContext.CurrentVendor != null || await _groupService.IsStaff(_workContext.CurrentCustomer))
@@ -1620,7 +1614,7 @@ namespace Grand.Web.Admin.Controllers
{
if (importexcelfile != null && importexcelfile.Length > 0)
{
- await _importManager.Import(importexcelfile.OpenReadStream());
+ await importManager.Import(importexcelfile.OpenReadStream());
}
else
{