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
CustomerActivityService - remove IHttpContextAccessor
KrzysztofPajake41480aa5444
diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.csindex d0c8b4ebb..b0c4fc73b 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddBrandCommandHandler.cs@@ -6,6 +6,7 @@ using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Seo;using Grand.Domain.Seo;+using Grand.Infrastructure;using MediatR;using System;using System.Threading;@@ -20,6 +21,7 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ILanguageService _languageService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;private readonly SeoSettings _seoSettings;public AddBrandCommandHandler(@@ -28,6 +30,7 @@ namespace Grand.Api.Commands.Models.CatalogILanguageService languageService,ICustomerActivityService customerActivityService,ITranslationService translationService,+ IWorkContext workContext,SeoSettings seoSettings){_brandService = brandService;@@ -35,6 +38,7 @@ namespace Grand.Api.Commands.Models.Catalog_languageService = languageService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -50,7 +54,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _slugService.SaveSlug(brand, request.Model.SeName, "");//activity log- await _customerActivityService.InsertActivity("AddNewBrand", brand.Id, _translationService.GetResource("ActivityLog.AddNewBrand"), brand.Name);+ await _customerActivityService.InsertActivity("AddNewBrand", brand.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewBrand"), brand.Name);return brand.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.csindex 407670d36..128a9588e 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCategoryCommandHandler.cs@@ -6,6 +6,7 @@ using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Seo;using Grand.Domain.Seo;+using Grand.Infrastructure;using MediatR;using System;using System.Threading;@@ -20,6 +21,7 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ILanguageService _languageService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;private readonly SeoSettings _seoSettings;public AddCategoryCommandHandler(@@ -28,6 +30,7 @@ namespace Grand.Api.Commands.Models.CatalogILanguageService languageService,ICustomerActivityService customerActivityService,ITranslationService translationService,+ IWorkContext workContext,SeoSettings seoSettings){_categoryService = categoryService;@@ -35,6 +38,7 @@ namespace Grand.Api.Commands.Models.Catalog_languageService = languageService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -51,7 +55,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _slugService.SaveSlug(category, request.Model.SeName, "");//activity log- await _customerActivityService.InsertActivity("AddNewCategory", category.Id,+ await _customerActivityService.InsertActivity("AddNewCategory", category.Id, _workContext.CurrentCustomer, "",_translationService.GetResource("ActivityLog.AddNewCategory"), category.Name);return category.ToModel();diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.csindex ebb8e61be..c4c8f6884 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddCollectionCommandHandler.cs@@ -6,6 +6,7 @@ using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Seo;using Grand.Domain.Seo;+using Grand.Infrastructure;using MediatR;using System;using System.Threading;@@ -20,6 +21,7 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ILanguageService _languageService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;private readonly SeoSettings _seoSettings;public AddCollectionCommandHandler(@@ -28,6 +30,7 @@ namespace Grand.Api.Commands.Models.CatalogILanguageService languageService,ICustomerActivityService customerActivityService,ITranslationService translationService,+ IWorkContext workContext,SeoSettings seoSettings){_collectionService = collectionService;@@ -35,6 +38,7 @@ namespace Grand.Api.Commands.Models.Catalog_languageService = languageService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -50,7 +54,9 @@ namespace Grand.Api.Commands.Models.Catalogawait _slugService.SaveSlug(collection, request.Model.SeName, "");//activity log- await _customerActivityService.InsertActivity("AddNewCollection", collection.Id, _translationService.GetResource("ActivityLog.AddNewCollection"), collection.Name);+ await _customerActivityService.InsertActivity("AddNewCollection", collection.Id,+ _workContext.CurrentCustomer, "",+ _translationService.GetResource("ActivityLog.AddNewCollection"), collection.Name);return collection.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductAttributeCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductAttributeCommandHandler.csindex 02dff7006..4057999d1 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductAttributeCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductAttributeCommandHandler.cs@@ -4,6 +4,7 @@ using Grand.Api.Extensions;using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -15,15 +16,18 @@ namespace Grand.Api.Commands.Handlers.Catalogprivate readonly IProductAttributeService _productAttributeService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public AddProductAttributeCommandHandler(IProductAttributeService productAttributeService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_productAttributeService = productAttributeService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<ProductAttributeDto> Handle(AddProductAttributeCommand request, CancellationToken cancellationToken)@@ -34,7 +38,7 @@ namespace Grand.Api.Commands.Handlers.Catalog//activity logawait _customerActivityService.InsertActivity("AddNewProductAttribute",- productAttribute.Id, _translationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);+ productAttribute.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);return productAttribute.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.csindex daa7a265a..edf991001 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddProductCommandHandler.cs@@ -10,6 +10,7 @@ using System.Threading;using System.Threading.Tasks;using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Extensions;+using Grand.Infrastructure;namespace Grand.Api.Commands.Models.Catalog{@@ -20,6 +21,8 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly ILanguageService _languageService;+ private readonly IWorkContext _workContext;+private readonly SeoSettings _seoSettings;public AddProductCommandHandler(@@ -28,6 +31,7 @@ namespace Grand.Api.Commands.Models.CatalogICustomerActivityService customerActivityService,ITranslationService translationService,ILanguageService languageService,+ IWorkContext workContext,SeoSettings seoSettings){_productService = productService;@@ -35,6 +39,7 @@ namespace Grand.Api.Commands.Models.Catalog_customerActivityService = customerActivityService;_translationService = translationService;_languageService = languageService;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -52,7 +57,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _productService.UpdateProduct(product);//activity log- await _customerActivityService.InsertActivity("AddNewProduct", product.Id, _translationService.GetResource("ActivityLog.AddNewProduct"), product.Name);+ await _customerActivityService.InsertActivity("AddNewProduct", product.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewProduct"), product.Name);return product.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/AddSpecificationAttributeCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/AddSpecificationAttributeCommandHandler.csindex 3edce64b4..d7d4728ec 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/AddSpecificationAttributeCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/AddSpecificationAttributeCommandHandler.cs@@ -4,6 +4,7 @@ using Grand.Api.Extensions;using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -15,15 +16,18 @@ namespace Grand.Api.Commands.Handlers.Catalogprivate readonly ISpecificationAttributeService _specificationAttributeService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public AddSpecificationAttributeCommandHandler(ISpecificationAttributeService specificationAttributeService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_specificationAttributeService = specificationAttributeService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<SpecificationAttributeDto> Handle(AddSpecificationAttributeCommand request, CancellationToken cancellationToken)@@ -32,7 +36,7 @@ namespace Grand.Api.Commands.Handlers.Catalogawait _specificationAttributeService.InsertSpecificationAttribute(specificationAttribute);//activity log- await _customerActivityService.InsertActivity("AddNewSpecAttribute", specificationAttribute.Id, _translationService.GetResource("ActivityLog.AddNewSpecAttribute"), specificationAttribute.Name);+ await _customerActivityService.InsertActivity("AddNewSpecAttribute", specificationAttribute.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewSpecAttribute"), specificationAttribute.Name);return specificationAttribute.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteBrandCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteBrandCommandHandler.csindex 80c9d279b..a6a7ce40a 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteBrandCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteBrandCommandHandler.cs@@ -1,6 +1,7 @@using Grand.Business.Catalog.Interfaces.Brands;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -12,15 +13,18 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly IBrandService _brandService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteBrandCommandHandler(IBrandService brandService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_brandService = brandService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteBrandCommand request, CancellationToken cancellationToken)@@ -31,7 +35,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _brandService.DeleteBrand(brand);//activity log- await _customerActivityService.InsertActivity("DeleteBrand", brand.Id, _translationService.GetResource("ActivityLog.DeleteBrand"), brand.Name);+ await _customerActivityService.InsertActivity("DeleteBrand", brand.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.DeleteBrand"), brand.Name);}return true;}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCategoryCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCategoryCommandHandler.csindex ab449a5cb..a72ec242a 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCategoryCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCategoryCommandHandler.cs@@ -1,6 +1,7 @@using Grand.Business.Catalog.Interfaces.Categories;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -12,15 +13,18 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ICategoryService _categoryService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteCategoryCommandHandler(ICategoryService categoryService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_categoryService = categoryService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteCategoryCommand request, CancellationToken cancellationToken)@@ -31,7 +35,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _categoryService.DeleteCategory(category);//activity log- await _customerActivityService.InsertActivity("DeleteCategory", category.Id, _translationService.GetResource("ActivityLog.DeleteCategory"), category.Name);+ await _customerActivityService.InsertActivity("DeleteCategory", category.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.DeleteCategory"), category.Name);}return true;}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCollectionCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCollectionCommandHandler.csindex 9555ca452..3f6eba840 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCollectionCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteCollectionCommandHandler.cs@@ -1,6 +1,7 @@using Grand.Business.Catalog.Interfaces.Collections;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -12,15 +13,18 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ICollectionService _collectionService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteCollectionCommandHandler(ICollectionService collectionService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_collectionService = collectionService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteCollectionCommand request, CancellationToken cancellationToken)@@ -31,7 +35,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _collectionService.DeleteCollection(collection);//activity log- await _customerActivityService.InsertActivity("DeleteCollection", collection.Id, _translationService.GetResource("ActivityLog.DeleteCollection"), collection.Name);+ await _customerActivityService.InsertActivity("DeleteCollection", collection.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.DeleteCollection"), collection.Name);}return true;}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductAttributeCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductAttributeCommandHandler.csindex eb2775230..2c8df83fa 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductAttributeCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductAttributeCommandHandler.cs@@ -2,6 +2,7 @@using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -13,15 +14,18 @@ namespace Grand.Api.Commands.Handlers.Catalogprivate readonly IProductAttributeService _productAttributeService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteProductAttributeCommandHandler(IProductAttributeService productAttributeService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_productAttributeService = productAttributeService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteProductAttributeCommand request, CancellationToken cancellationToken)@@ -32,6 +36,7 @@ namespace Grand.Api.Commands.Handlers.Catalogawait _productAttributeService.DeleteProductAttribute(productAttribute);//activity logawait _customerActivityService.InsertActivity("DeleteProductAttribute", productAttribute.Id,+ _workContext.CurrentCustomer, "",_translationService.GetResource("ActivityLog.DeleteProductAttribute"), productAttribute.Name);}return true;diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductCommandHandler.csindex 4a9cebc9a..620f9a0ea 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteProductCommandHandler.cs@@ -1,6 +1,7 @@using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -12,15 +13,18 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly IProductService _productService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteProductCommandHandler(IProductService productService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_productService = productService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteProductCommand request, CancellationToken cancellationToken)@@ -31,7 +35,9 @@ namespace Grand.Api.Commands.Models.Catalogawait _productService.DeleteProduct(product);//activity log- await _customerActivityService.InsertActivity("DeleteProduct", product.Id, _translationService.GetResource("ActivityLog.DeleteProduct"), product.Name);+ await _customerActivityService.InsertActivity("DeleteProduct", product.Id,+ _workContext.CurrentCustomer, "",+ _translationService.GetResource("ActivityLog.DeleteProduct"), product.Name);}return true;}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteSpecificationAttributeCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteSpecificationAttributeCommandHandler.csindex b7d4438b4..c5831c80c 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteSpecificationAttributeCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/DeleteSpecificationAttributeCommandHandler.cs@@ -2,6 +2,7 @@using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -13,15 +14,18 @@ namespace Grand.Api.Commands.Handlers.Catalogprivate readonly ISpecificationAttributeService _specificationAttributeService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteSpecificationAttributeCommandHandler(ISpecificationAttributeService specificationAttributeService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_specificationAttributeService = specificationAttributeService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteSpecificationAttributeCommand request, CancellationToken cancellationToken)@@ -31,7 +35,9 @@ namespace Grand.Api.Commands.Handlers.Catalog{await _specificationAttributeService.DeleteSpecificationAttribute(specificationAttribute);//activity log- await _customerActivityService.InsertActivity("DeleteSpecAttribute", specificationAttribute.Id, _translationService.GetResource("ActivityLog.DeleteSpecAttribute"), specificationAttribute.Name);+ await _customerActivityService.InsertActivity("DeleteSpecAttribute", specificationAttribute.Id,+ _workContext.CurrentCustomer, "",+ _translationService.GetResource("ActivityLog.DeleteSpecAttribute"), specificationAttribute.Name);}return true;}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.csindex 967df3939..fcfa9e57f 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateBrandCommandHandler.cs@@ -7,6 +7,7 @@ using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Seo;using Grand.Business.Storage.Interfaces;using Grand.Domain.Seo;+using Grand.Infrastructure;using MediatR;using System;using System.Threading;@@ -22,6 +23,8 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly IPictureService _pictureService;+ private readonly IWorkContext _workContext;+private readonly SeoSettings _seoSettings;public UpdateBrandCommandHandler(@@ -31,6 +34,7 @@ namespace Grand.Api.Commands.Models.CatalogICustomerActivityService customerActivityService,ITranslationService translationService,IPictureService pictureService,+ IWorkContext workContext,SeoSettings seoSettings){_brandService = brandService;@@ -39,6 +43,7 @@ namespace Grand.Api.Commands.Models.Catalog_customerActivityService = customerActivityService;_translationService = translationService;_pictureService = pictureService;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -69,7 +74,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _pictureService.SetSeoFilename(picture, _pictureService.GetPictureSeName(brand.Name));}//activity log- await _customerActivityService.InsertActivity("EditBrand", brand.Id, _translationService.GetResource("ActivityLog.EditBrand"), brand.Name);+ await _customerActivityService.InsertActivity("EditBrand", brand.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditBrand"), brand.Name);return brand.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.csindex 88e48a067..18bc25f05 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCategoryCommandHandler.cs@@ -7,6 +7,7 @@ using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Seo;using Grand.Business.Storage.Interfaces;using Grand.Domain.Seo;+using Grand.Infrastructure;using MediatR;using System;using System.Threading;@@ -22,6 +23,8 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly IPictureService _pictureService;+ private readonly IWorkContext _workContext;+private readonly SeoSettings _seoSettings;public UpdateCategoryCommandHandler(@@ -31,6 +34,7 @@ namespace Grand.Api.Commands.Models.CatalogICustomerActivityService customerActivityService,ITranslationService translationService,IPictureService pictureService,+ IWorkContext workContext,SeoSettings seoSettings){_categoryService = categoryService;@@ -39,6 +43,7 @@ namespace Grand.Api.Commands.Models.Catalog_customerActivityService = customerActivityService;_translationService = translationService;_pictureService = pictureService;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -69,7 +74,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _pictureService.SetSeoFilename(picture, _pictureService.GetPictureSeName(category.Name));}//activity log- await _customerActivityService.InsertActivity("EditCategory", category.Id, _translationService.GetResource("ActivityLog.EditCategory"), category.Name);+ await _customerActivityService.InsertActivity("EditCategory", category.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditCategory"), category.Name);return category.ToModel();}}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.csindex b47cda75d..2475fa989 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateCollectionCommandHandler.cs@@ -7,6 +7,7 @@ using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Seo;using Grand.Business.Storage.Interfaces;using Grand.Domain.Seo;+using Grand.Infrastructure;using MediatR;using System;using System.Threading;@@ -22,6 +23,8 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly IPictureService _pictureService;+ private readonly IWorkContext _workContext;+private readonly SeoSettings _seoSettings;public UpdateCollectionCommandHandler(@@ -31,6 +34,7 @@ namespace Grand.Api.Commands.Models.CatalogICustomerActivityService customerActivityService,ITranslationService translationService,IPictureService pictureService,+ IWorkContext workContext,SeoSettings seoSettings){_collectionService = collectionService;@@ -39,6 +43,7 @@ namespace Grand.Api.Commands.Models.Catalog_customerActivityService = customerActivityService;_translationService = translationService;_pictureService = pictureService;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -69,7 +74,7 @@ namespace Grand.Api.Commands.Models.Catalogawait _pictureService.SetSeoFilename(picture, _pictureService.GetPictureSeName(collection.Name));}//activity log- await _customerActivityService.InsertActivity("EditCollection", collection.Id, _translationService.GetResource("ActivityLog.EditCollection"), collection.Name);+ await _customerActivityService.InsertActivity("EditCollection", collection.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditCollection"), collection.Name);return collection.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductAttributeCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductAttributeCommandHandler.csindex 88f1fecaf..096dcbe09 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductAttributeCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductAttributeCommandHandler.cs@@ -4,6 +4,7 @@ using Grand.Api.Extensions;using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -15,15 +16,18 @@ namespace Grand.Api.Commands.Handlers.Catalogprivate readonly IProductAttributeService _productAttributeService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public UpdateProductAttributeCommandHandler(IProductAttributeService productAttributeService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_productAttributeService = productAttributeService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<ProductAttributeDto> Handle(UpdateProductAttributeCommand request, CancellationToken cancellationToken)@@ -35,6 +39,7 @@ namespace Grand.Api.Commands.Handlers.Catalog//activity logawait _customerActivityService.InsertActivity("EditProductAttribute", productAttribute.Id,+ _workContext.CurrentCustomer, "",_translationService.GetResource("ActivityLog.EditProductAttribute"), productAttribute.Name);return productAttribute.ToModel();diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.csindex b7017b2b8..cf4517f98 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductCommandHandler.cs@@ -9,6 +9,7 @@ using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Seo;using Grand.Domain.Catalog;using Grand.Domain.Seo;+using Grand.Infrastructure;using MediatR;using System;using System.Threading;@@ -26,6 +27,8 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ILanguageService _languageService;private readonly IOutOfStockSubscriptionService _outOfStockSubscriptionService;private readonly IMediator _mediator;+ private readonly IWorkContext _workContext;+private readonly SeoSettings _seoSettings;public UpdateProductCommandHandler(@@ -37,6 +40,7 @@ namespace Grand.Api.Commands.Models.CatalogIOutOfStockSubscriptionService outOfStockSubscriptionService,IStockQuantityService stockQuantityService,IMediator mediator,+ IWorkContext workContext,SeoSettings seoSettings){_productService = productService;@@ -47,6 +51,7 @@ namespace Grand.Api.Commands.Models.Catalog_outOfStockSubscriptionService = outOfStockSubscriptionService;_stockQuantityService = stockQuantityService;_mediator = mediator;+ _workContext = workContext;_seoSettings = seoSettings;}@@ -76,7 +81,7 @@ namespace Grand.Api.Commands.Models.Catalog}//activity log- await _customerActivityService.InsertActivity("EditProduct", product.Id, _translationService.GetResource("ActivityLog.EditProduct"), product.Name);+ await _customerActivityService.InsertActivity("EditProduct", product.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditProduct"), product.Name);//raise eventif (!prevPublished && product.Published)diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductStockCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductStockCommandHandler.csindex ee31472ff..1084713bc 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductStockCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateProductStockCommandHandler.cs@@ -3,6 +3,7 @@ using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Domain.Catalog;+using Grand.Infrastructure;using MediatR;using System;using System.Collections.Generic;@@ -20,6 +21,7 @@ namespace Grand.Api.Commands.Models.Catalogprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly IOutOfStockSubscriptionService _outOfStockSubscriptionService;+ private readonly IWorkContext _workContext;public UpdateProductStockCommandHandler(IProductService productService,@@ -27,7 +29,8 @@ namespace Grand.Api.Commands.Models.CatalogIStockQuantityService stockQuantityService,ICustomerActivityService customerActivityService,ITranslationService translationService,- IOutOfStockSubscriptionService outOfStockSubscriptionService)+ IOutOfStockSubscriptionService outOfStockSubscriptionService,+ IWorkContext workContext){_productService = productService;_inventoryManageService = inventoryManageService;@@ -35,6 +38,7 @@ namespace Grand.Api.Commands.Models.Catalog_customerActivityService = customerActivityService;_translationService = translationService;_outOfStockSubscriptionService = outOfStockSubscriptionService;+ _workContext = workContext;}public async Task<bool> Handle(UpdateProductStockCommand request, CancellationToken cancellationToken)@@ -83,7 +87,7 @@ namespace Grand.Api.Commands.Models.Catalogawait OutOfStockNotifications(product, prevStockQuantity, prevMultiWarehouseStock);//activity log- await _customerActivityService.InsertActivity("EditProduct", product.Id, _translationService.GetResource("ActivityLog.EditProduct"), product.Name);+ await _customerActivityService.InsertActivity("EditProduct", product.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditProduct"), product.Name);}return true;diff --git a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateSpecificationAttributeCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateSpecificationAttributeCommandHandler.csindex d49b43aa8..3984818ee 100644--- a/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateSpecificationAttributeCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Catalog/UpdateSpecificationAttributeCommandHandler.cs@@ -4,6 +4,7 @@ using Grand.Api.Extensions;using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Linq;using System.Threading;@@ -16,15 +17,18 @@ namespace Grand.Api.Commands.Handlers.Catalogprivate readonly ISpecificationAttributeService _specificationAttributeService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public UpdateSpecificationAttributeCommandHandler(ISpecificationAttributeService specificationAttributeService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_specificationAttributeService = specificationAttributeService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<SpecificationAttributeDto> Handle(UpdateSpecificationAttributeCommand request, CancellationToken cancellationToken)@@ -42,7 +46,8 @@ namespace Grand.Api.Commands.Handlers.Catalog//activity logawait _customerActivityService.InsertActivity("EditSpecAttribute",- specificationAttribute.Id, _translationService.GetResource("ActivityLog.EditSpecAttribute"), specificationAttribute.Name);+ specificationAttribute.Id, _workContext.CurrentCustomer, "",+ _translationService.GetResource("ActivityLog.EditSpecAttribute"), specificationAttribute.Name);return specificationAttribute.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.csindex 1c090443f..6cd73fe97 100644--- a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerCommandHandler.cs@@ -6,6 +6,7 @@ using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Customers.Interfaces;using Grand.Domain.Customers;+using Grand.Infrastructure;using MediatR;using System;using System.Linq;@@ -21,19 +22,22 @@ namespace Grand.Api.Commands.Handlers.Customersprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly IUserFieldService _userFieldsService;+ private readonly IWorkContext _workContext;public AddCustomerCommandHandler(ICustomerService customerService,IGroupService groupService,ICustomerActivityService customerActivityService,ITranslationService translationService,- IUserFieldService userFieldsService)+ IUserFieldService userFieldsService,+ IWorkContext workContext){_customerService = customerService;_groupService = groupService;_customerActivityService = customerActivityService;_translationService = translationService;_userFieldsService = userFieldsService;+ _workContext = workContext;}public async Task<CustomerDto> Handle(AddCustomerCommand request, CancellationToken cancellationToken)@@ -49,7 +53,7 @@ namespace Grand.Api.Commands.Handlers.Customersawait SaveCustomerGroups(request.Model, customer);//activity log- await _customerActivityService.InsertActivity("AddNewCustomer", customer.Id, _translationService.GetResource("ActivityLog.AddNewCustomer"), customer.Id);+ await _customerActivityService.InsertActivity("AddNewCustomer", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewCustomer"), customer.Id);return customer.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerGroupCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerGroupCommandHandler.csindex 4358f3eeb..6781ff648 100644--- a/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerGroupCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Customers/AddCustomerGroupCommandHandler.cs@@ -3,6 +3,7 @@ using Grand.Api.Extensions;using Grand.Business.Common.Interfaces.Directory;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -14,15 +15,18 @@ namespace Grand.Api.Commands.Models.Customersprivate readonly IGroupService _groupService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public AddCustomerGroupCommandHandler(IGroupService groupService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_groupService = groupService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<CustomerGroupDto> Handle(AddCustomerGroupCommand request, CancellationToken cancellationToken)@@ -31,7 +35,7 @@ namespace Grand.Api.Commands.Models.Customersawait _groupService.InsertCustomerGroup(customergroup);//activity log- await _customerActivityService.InsertActivity("AddNewCustomerGroup", customergroup.Id, _translationService.GetResource("ActivityLog.AddNewCustomerGroup"), customergroup.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerGroup", customergroup.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewCustomerGroup"), customergroup.Name);return customergroup.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerCommandHandler.csindex a4d30c6f9..be04cc8a5 100644--- a/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerCommandHandler.cs@@ -2,6 +2,7 @@using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Customers.Interfaces;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -13,15 +14,18 @@ namespace Grand.Api.Commands.Handlers.Customersprivate readonly ICustomerService _customerService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteCustomerCommandHandler(ICustomerService customerService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_customerService = customerService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteCustomerCommand request, CancellationToken cancellationToken)@@ -31,7 +35,7 @@ namespace Grand.Api.Commands.Handlers.Customers{await _customerService.DeleteCustomer(customer);//activity log- await _customerActivityService.InsertActivity("DeleteCustomer", customer.Id, _translationService.GetResource("ActivityLog.DeleteCustomer"), customer.Id);+ await _customerActivityService.InsertActivity("DeleteCustomer", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.DeleteCustomer"), customer.Id);}return true;diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerGroupCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerGroupCommandHandler.csindex daafe013c..ac1761670 100644--- a/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerGroupCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Customers/DeleteCustomerGroupCommandHandler.cs@@ -1,6 +1,7 @@using Grand.Business.Common.Interfaces.Directory;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -12,15 +13,18 @@ namespace Grand.Api.Commands.Models.Customersprivate readonly IGroupService _groupService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public DeleteCustomerGroupCommandHandler(IGroupService groupService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_groupService = groupService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<bool> Handle(DeleteCustomerGroupCommand request, CancellationToken cancellationToken)@@ -31,7 +35,7 @@ namespace Grand.Api.Commands.Models.Customersawait _groupService.DeleteCustomerGroup(customerGroup);//activity log- await _customerActivityService.InsertActivity("DeleteCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.DeleteCustomerGroup"), customerGroup.Name);+ await _customerActivityService.InsertActivity("DeleteCustomerGroup", customerGroup.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.DeleteCustomerGroup"), customerGroup.Name);}return true;}diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerCommandHandler.csindex f271f497d..73f6f1c34 100644--- a/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerCommandHandler.cs@@ -6,6 +6,7 @@ using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Customers.Interfaces;using Grand.Domain.Customers;+using Grand.Infrastructure;using MediatR;using System.Linq;using System.Threading;@@ -20,19 +21,22 @@ namespace Grand.Api.Commands.Handlers.Customersprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly IUserFieldService _userFieldsService;+ private readonly IWorkContext _workContext;public UpdateCustomerCommandHandler(ICustomerService customerService,IGroupService groupService,ICustomerActivityService customerActivityService,ITranslationService translationService,- IUserFieldService userFieldsService)+ IUserFieldService userFieldsService,+ IWorkContext workContext){_customerService = customerService;_groupService = groupService;_customerActivityService = customerActivityService;_translationService = translationService;_userFieldsService = userFieldsService;+ _workContext = workContext;}public async Task<CustomerDto> Handle(UpdateCustomerCommand request, CancellationToken cancellationToken)@@ -44,7 +48,7 @@ namespace Grand.Api.Commands.Handlers.Customersawait SaveCustomerGroups(request.Model, customer);//activity log- await _customerActivityService.InsertActivity("EditCustomer", customer.Id, _translationService.GetResource("ActivityLog.EditCustomer"), customer.Id);+ await _customerActivityService.InsertActivity("EditCustomer", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditCustomer"), customer.Id);return customer.ToModel();}diff --git a/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerGroupCommandHandler.cs b/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerGroupCommandHandler.csindex 73d9a491a..b64f93edd 100644--- a/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerGroupCommandHandler.cs+++ b/src/API/Grand.Api/Commands/Handlers/Customers/UpdateCustomerGroupCommandHandler.cs@@ -3,6 +3,7 @@ using Grand.Api.Extensions;using Grand.Business.Common.Interfaces.Directory;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;+using Grand.Infrastructure;using MediatR;using System.Threading;using System.Threading.Tasks;@@ -14,15 +15,18 @@ namespace Grand.Api.Commands.Models.Customersprivate readonly IGroupService _groupService;private readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;public UpdateCustomerGroupCommandHandler(IGroupService groupService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext){_groupService = groupService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}public async Task<CustomerGroupDto> Handle(UpdateCustomerGroupCommand request, CancellationToken cancellationToken)@@ -32,7 +36,7 @@ namespace Grand.Api.Commands.Models.Customersawait _groupService.UpdateCustomerGroup(customerGroup);//activity log- await _customerActivityService.InsertActivity("EditCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.EditCustomerGroup"), customerGroup.Name);+ await _customerActivityService.InsertActivity("EditCustomerGroup", customerGroup.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditCustomerGroup"), customerGroup.Name);return customerGroup.ToModel();}diff --git a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.csindex 0c79b5010..4b3bcda60 100644--- a/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs+++ b/src/Business/Grand.Business.Checkout/Commands/Handlers/Orders/PlaceOrderCommandHandler.cs@@ -110,7 +110,6 @@ namespace Grand.Business.Checkout.Commands.Handlers.OrdersICurrencyService currencyService,IAffiliateService affiliateService,IMediator mediator,- IPdfService pdfService,IProductReservationService productReservationService,IAuctionService auctionService,ICountryService countryService,diff --git a/src/Business/Grand.Business.Common/Interfaces/Logging/ICustomerActivityService.cs b/src/Business/Grand.Business.Common/Interfaces/Logging/ICustomerActivityService.csindex 48cd9c7c9..103228156 100644--- a/src/Business/Grand.Business.Common/Interfaces/Logging/ICustomerActivityService.cs+++ b/src/Business/Grand.Business.Common/Interfaces/Logging/ICustomerActivityService.cs@@ -47,21 +47,14 @@ namespace Grand.Business.Common.Interfaces.Logging/// Inserts an activity log item/// </summary>/// <param name="systemKeyword">The system keyword</param>- /// <param name="comment">The activity comment</param>- /// <param name="commentParams">The activity comment parameters for string.Format() function.</param>- /// <returns>Activity log item</returns>- Task InsertActivity(string systemKeyword, string entityKeyId, string comment, params object[] commentParams);-- /// <summary>- /// Inserts an activity log item- /// </summary>- /// <param name="systemKeyword">The system keyword</param>- /// <param name="comment">The activity comment</param>+ /// <param name="entityKeyId">Entity key ident</param>/// <param name="customer">The customer</param>+ /// <param name="ipAddress">Ip address</param>+ /// <param name="comment">The activity comment</param>/// <param name="commentParams">The activity comment parameters for string.Format() function.</param>/// <returns>Activity log item</returns>Task<ActivityLog> InsertActivity(string systemKeyword, string entityKeyId,- string comment, Customer customer, params object[] commentParams);+ Customer customer, string ipAddress, string comment, params object[] commentParams);/// <summary>diff --git a/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.cs b/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.csindex 74c545fa1..db84a6ed5 100644--- a/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.cs+++ b/src/Business/Grand.Business.Common/Services/Logging/CustomerActivityService.cs@@ -3,11 +3,9 @@ using Grand.Domain;using Grand.Domain.Customers;using Grand.Domain.Data;using Grand.Domain.Logging;-using Grand.Infrastructure;using Grand.Infrastructure.Caching;using Grand.Infrastructure.Caching.Constants;using Grand.SharedKernel.Extensions;-using Microsoft.AspNetCore.Http;using System;using System.Collections.Generic;using System.Linq;@@ -28,9 +26,7 @@ namespace Grand.Business.Common.Services.Loggingprivate readonly ICacheBase _cacheBase;private readonly IRepository<ActivityLog> _activityLogRepository;private readonly IRepository<ActivityLogType> _activityLogTypeRepository;- private readonly IWorkContext _workContext;private readonly IActivityKeywordsProvider _activityKeywordsProvider;- private readonly IHttpContextAccessor _httpContextAccessor;#endregion@@ -43,16 +39,12 @@ namespace Grand.Business.Common.Services.LoggingICacheBase cacheBase,IRepository<ActivityLog> activityLogRepository,IRepository<ActivityLogType> activityLogTypeRepository,- IWorkContext workContext,- IActivityKeywordsProvider activityKeywordsProvider,- IHttpContextAccessor httpContextAccessor)+ IActivityKeywordsProvider activityKeywordsProvider){_cacheBase = cacheBase;_activityLogRepository = activityLogRepository;_activityLogTypeRepository = activityLogTypeRepository;- _workContext = workContext;_activityKeywordsProvider = activityKeywordsProvider;- _httpContextAccessor = httpContextAccessor;}#endregion@@ -143,25 +135,14 @@ namespace Grand.Business.Common.Services.Logging/// Inserts an activity log item/// </summary>/// <param name="systemKeyword">The system keyword</param>- /// <param name="comment">The activity comment</param>- /// <param name="commentParams">The activity comment parameters for string.Format() function.</param>- /// <returns>Activity log item</returns>- public virtual async Task InsertActivity(string systemKeyword, string entityKeyId,- string comment, params object[] commentParams)- {- await InsertActivity(systemKeyword, entityKeyId, comment, _workContext.CurrentCustomer, commentParams);- }-- /// <summary>- /// Inserts an activity log item- /// </summary>- /// <param name="systemKeyword">The system keyword</param>- /// <param name="comment">The activity comment</param>+ /// <param name="entityKeyId">Entity key ident</param>/// <param name="customer">The customer</param>+ /// <param name="ipAddress">Ip address</param>+ /// <param name="comment">The activity comment</param>/// <param name="commentParams">The activity comment parameters for string.Format() function.</param>/// <returns>Activity log item</returns>public virtual async Task<ActivityLog> InsertActivity(string systemKeyword, string entityKeyId,- string comment, Customer customer, params object[] commentParams)+ Customer customer, string ipAddress, string comment, params object[] commentParams){if (customer == null)return null;@@ -181,7 +162,7 @@ namespace Grand.Business.Common.Services.Loggingactivity.EntityKeyId = entityKeyId;activity.Comment = comment;activity.CreatedOnUtc = DateTime.UtcNow;- activity.IpAddress = _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString();+ activity.IpAddress = ipAddress;await _activityLogRepository.InsertAsync(activity);return activity;@@ -259,7 +240,7 @@ namespace Grand.Business.Common.Services.Loggingif (!String.IsNullOrEmpty(activityLogTypeId))query = query.Where(al => activityLogTypeId == al.ActivityLogTypeId);- var gquery = query.GroupBy(key=> new { key.ActivityLogTypeId, key.EntityKeyId })+ var gquery = query.GroupBy(key => new { key.ActivityLogTypeId, key.EntityKeyId }).Select(g => new ActivityStats {ActivityLogTypeId = g.Key.ActivityLogTypeId,EntityKeyId = g.Key.EntityKeyId,diff --git a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedInEventHandler.cs b/src/Business/Grand.Business.Marketing/Events/CustomerLoggedInEventHandler.csindex 23c577a86..ec3d3d4bd 100644--- a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedInEventHandler.cs+++ b/src/Business/Grand.Business.Marketing/Events/CustomerLoggedInEventHandler.cs@@ -23,7 +23,7 @@ namespace Grand.Business.Marketing.Eventspublic async Task Handle(CustomerLoggedInEvent notification, CancellationToken cancellationToken){//activity log- await _customerActivityService.InsertActivity("PublicStore.Login", "", _translationService.GetResource("ActivityLog.PublicStore.Login"), notification.Customer);+ await _customerActivityService.InsertActivity("PublicStore.Login", notification.Customer.Id, notification.Customer, "", _translationService.GetResource("ActivityLog.PublicStore.Login"));}}}diff --git a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedOutEventHandler.cs b/src/Business/Grand.Business.Marketing/Events/CustomerLoggedOutEventHandler.csindex 276fc38a3..31a391f3d 100644--- a/src/Business/Grand.Business.Marketing/Events/CustomerLoggedOutEventHandler.cs+++ b/src/Business/Grand.Business.Marketing/Events/CustomerLoggedOutEventHandler.cs@@ -23,7 +23,7 @@ namespace Grand.Business.Marketing.Eventspublic async Task Handle(CustomerLoggedOutEvent notification, CancellationToken cancellationToken){//activity log- await _customerActivityService.InsertActivity("PublicStore.Logout", "", _translationService.GetResource("ActivityLog.PublicStore.Logout"), notification.Customer);+ await _customerActivityService.InsertActivity("PublicStore.Logout", "", notification.Customer, "", _translationService.GetResource("ActivityLog.PublicStore.Logout"));}}}diff --git a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.csindex f698dedd5..29729b9cf 100644--- a/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Campaigns/CampaignService.cs@@ -360,7 +360,7 @@ namespace Grand.Business.Marketing.Services.Campaigns//activity logif (customer != null)- await _customerActivityService.InsertActivity("CustomerReminder.SendCampaign", campaign.Id, _translationService.GetResource("ActivityLog.SendCampaign"), customer, campaign.Name);+ await _customerActivityService.InsertActivity("CustomerReminder.SendCampaign", campaign.Id, customer, "", _translationService.GetResource("ActivityLog.SendCampaign"), campaign.Name);totalEmailsSent++;}diff --git a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.csindex 216f114b5..929747f88 100644--- a/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs+++ b/src/Business/Grand.Business.Marketing/Services/Customers/CustomerReminderService.cs@@ -134,7 +134,7 @@ namespace Grand.Business.Marketing.Services.Customersawait _queuedEmailService.InsertQueuedEmail(email);//activity log- await _customerActivityService.InsertActivity(string.Format("CustomerReminder.{0}", customerReminder.ReminderRuleId.ToString()), customer.Id, _translationService.GetResource(string.Format("ActivityLog.{0}", customerReminder.ReminderRuleId.ToString())), customer, customerReminder.Name);+ await _customerActivityService.InsertActivity(string.Format("CustomerReminder.{0}", customerReminder.ReminderRuleId.ToString()), customer.Id, customer, "", _translationService.GetResource(string.Format("ActivityLog.{0}", customerReminder.ReminderRuleId.ToString())), customerReminder.Name);return true;}@@ -207,7 +207,7 @@ namespace Grand.Business.Marketing.Services.Customersawait _queuedEmailService.InsertQueuedEmail(email);//activity log- await _customerActivityService.InsertActivity(string.Format("CustomerReminder.{0}", customerReminder.ReminderRuleId.ToString()), customer.Id, string.Format("ActivityLog.{0}", customerReminder.ReminderRuleId.ToString()), customer, customerReminder.Name);+ await _customerActivityService.InsertActivity(string.Format("CustomerReminder.{0}", customerReminder.ReminderRuleId.ToString()), customer.Id, customer, "", string.Format("ActivityLog.{0}", customerReminder.ReminderRuleId.ToString()), customerReminder.Name);return true;}diff --git a/src/Web/Grand.Web.Admin/Controllers/CheckoutAttributeController.cs b/src/Web/Grand.Web.Admin/Controllers/CheckoutAttributeController.csindex 26ac73f83..8f5032878 100644--- a/src/Web/Grand.Web.Admin/Controllers/CheckoutAttributeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CheckoutAttributeController.cs@@ -7,6 +7,7 @@ using Grand.Business.Common.Interfaces.Stores;using Grand.Business.Common.Services.Security;using Grand.Domain.Catalog;using Grand.Domain.Directory;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Orders;@@ -172,13 +173,15 @@ namespace Grand.Web.Admin.Controllers//delete[HttpPost][PermissionAuthorizeAction(PermissionActionName.Delete)]- public async Task<IActionResult> Delete(string id, [FromServices] ICustomerActivityService customerActivityService)+ public async Task<IActionResult> Delete(string id,+ [FromServices] IWorkContext workContext,+ [FromServices] ICustomerActivityService customerActivityService){var checkoutAttribute = await _checkoutAttributeService.GetCheckoutAttributeById(id);await _checkoutAttributeService.DeleteCheckoutAttribute(checkoutAttribute);//activity log- await customerActivityService.InsertActivity("DeleteCheckoutAttribute", checkoutAttribute.Id, _translationService.GetResource("ActivityLog.DeleteCheckoutAttribute"), checkoutAttribute.Name);+ await customerActivityService.InsertActivity("DeleteCheckoutAttribute", checkoutAttribute.Id, workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(), _translationService.GetResource("ActivityLog.DeleteCheckoutAttribute"), checkoutAttribute.Name);Success(_translationService.GetResource("Admin.Orders.CheckoutAttributes.Deleted"));return RedirectToAction("List");diff --git a/src/Web/Grand.Web.Admin/Controllers/ContactAttributeController.cs b/src/Web/Grand.Web.Admin/Controllers/ContactAttributeController.csindex d35e410f3..6e27ffcd7 100644--- a/src/Web/Grand.Web.Admin/Controllers/ContactAttributeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ContactAttributeController.cs@@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Mvc;using System;using System.Linq;using System.Threading.Tasks;+using Grand.Infrastructure;namespace Grand.Web.Admin.Controllers{@@ -153,7 +154,9 @@ namespace Grand.Web.Admin.Controllers//delete[HttpPost][PermissionAuthorizeAction(PermissionActionName.Delete)]- public async Task<IActionResult> Delete(string id, [FromServices] ICustomerActivityService customerActivityService)+ public async Task<IActionResult> Delete(string id,+ [FromServices] IWorkContext workContext,+ [FromServices] ICustomerActivityService customerActivityService){if (ModelState.IsValid){@@ -161,7 +164,9 @@ namespace Grand.Web.Admin.Controllersawait _contactAttributeService.DeleteContactAttribute(contactAttribute);//activity log- await customerActivityService.InsertActivity("DeleteContactAttribute", contactAttribute.Id, _translationService.GetResource("ActivityLog.DeleteContactAttribute"), contactAttribute.Name);+ await customerActivityService.InsertActivity("DeleteContactAttribute", contactAttribute.Id,+ workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteContactAttribute"), contactAttribute.Name);Success(_translationService.GetResource("Admin.Catalog.Attributes.ContactAttributes.Deleted"));return RedirectToAction("List");diff --git a/src/Web/Grand.Web.Admin/Controllers/CustomerActionController.cs b/src/Web/Grand.Web.Admin/Controllers/CustomerActionController.csindex 5be8e7586..197d22758 100644--- a/src/Web/Grand.Web.Admin/Controllers/CustomerActionController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/CustomerActionController.cs@@ -10,6 +10,7 @@ using Grand.Business.Customers.Interfaces;using Grand.Business.Marketing.Interfaces.Customers;using Grand.Domain.Catalog;using Grand.Domain.Customers;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;@@ -203,7 +204,7 @@ namespace Grand.Web.Admin.Controllers}[HttpPost]- public async Task<IActionResult> Delete(string id)+ public async Task<IActionResult> Delete(string id, [FromServices] IWorkContext workContext){var customerAction = await _customerActionService.GetCustomerActionById(id);if (customerAction == null)@@ -212,7 +213,9 @@ namespace Grand.Web.Admin.Controllerstry{//activity log- await _customerActivityService.InsertActivity("DeleteCustomerAction", customerAction.Id, _translationService.GetResource("ActivityLog.DeleteCustomerAction"), customerAction.Name);+ await _customerActivityService.InsertActivity("DeleteCustomerAction", customerAction.Id,+ workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCustomerAction"), customerAction.Name);await _customerActionService.DeleteCustomerAction(customerAction);Success(_translationService.GetResource("Admin.Customers.CustomerAction.Deleted"));return RedirectToAction("List");diff --git a/src/Web/Grand.Web.Admin/Controllers/DocumentController.cs b/src/Web/Grand.Web.Admin/Controllers/DocumentController.csindex ea4129067..dce4fbae6 100644--- a/src/Web/Grand.Web.Admin/Controllers/DocumentController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/DocumentController.cs@@ -3,6 +3,7 @@ using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Services.Security;using Grand.Business.Customers.Interfaces;using Grand.Business.Marketing.Interfaces.Documents;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Documents;@@ -10,7 +11,6 @@ using Grand.Web.Common.DataSource;using Grand.Web.Common.Filters;using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;-using System;using System.Threading.Tasks;namespace Grand.Web.Admin.Controllers@@ -24,13 +24,15 @@ namespace Grand.Web.Admin.Controllersprivate readonly ITranslationService _translationService;private readonly ICustomerService _customerService;private readonly ICustomerActivityService _customerActivityService;+ private readonly IWorkContext _workContext;public DocumentController(IDocumentViewModelService documentViewModelService,IDocumentService documentService,IDocumentTypeService documentTypeService,ITranslationService translationService,ICustomerService customerService,- ICustomerActivityService customerActivityService)+ ICustomerActivityService customerActivityService,+ IWorkContext workContext){_documentViewModelService = documentViewModelService;_documentService = documentService;@@ -38,6 +40,7 @@ namespace Grand.Web.Admin.Controllers_translationService = translationService;_customerService = customerService;_customerActivityService = customerActivityService;+ _workContext = workContext;}public IActionResult Index() => RedirectToAction("List");@@ -164,7 +167,9 @@ namespace Grand.Web.Admin.Controllersawait _documentTypeService.Insert(documenttype);//activity log- await _customerActivityService.InsertActivity("AddNewDocumentType", documenttype.Id, _translationService.GetResource("ActivityLog.AddNewDocumentType"), documenttype.Name);+ await _customerActivityService.InsertActivity("AddNewDocumentType", documenttype.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewDocumentType"), documenttype.Name);Success(_translationService.GetResource("Admin.Documents.Type.Added"));return continueEditing ? RedirectToAction("EditType", new { id = documenttype.Id }) : RedirectToAction("Types");@@ -198,7 +203,9 @@ namespace Grand.Web.Admin.Controllersawait _documentTypeService.Update(documentType);//activity log- await _customerActivityService.InsertActivity("EditDocumentType", documentType.Id, _translationService.GetResource("ActivityLog.EditDocumentType"), documentType.Name);+ await _customerActivityService.InsertActivity("EditDocumentType", documentType.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditDocumentType"), documentType.Name);Success(_translationService.GetResource("Admin.Documents.Type.Updated"));return continueEditing ? RedirectToAction("EditType", new { id = documentType.Id }) : RedirectToAction("Types");@@ -220,7 +227,9 @@ namespace Grand.Web.Admin.Controllersawait _documentTypeService.Delete(documentType);//activity log- await _customerActivityService.InsertActivity("DeleteDocumentType", documentType.Id, _translationService.GetResource("ActivityLog.DeleteDocumentType"), documentType.Name);+ await _customerActivityService.InsertActivity("DeleteDocumentType", documentType.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteDocumentType"), documentType.Name);Success(_translationService.GetResource("Admin.Documents.Type.Deleted"));return RedirectToAction("Types");diff --git a/src/Web/Grand.Web.Admin/Controllers/InteractiveFormController.cs b/src/Web/Grand.Web.Admin/Controllers/InteractiveFormController.csindex e7a886808..4fb6458cb 100644--- a/src/Web/Grand.Web.Admin/Controllers/InteractiveFormController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/InteractiveFormController.cs@@ -15,6 +15,7 @@ using System;using System.Linq;using System.Text;using System.Threading.Tasks;+using Grand.Infrastructure;namespace Grand.Web.Admin.Controllers{@@ -26,18 +27,21 @@ namespace Grand.Web.Admin.Controllersprivate readonly ILanguageService _languageService;private readonly ICustomerActivityService _customerActivityService;private readonly IEmailAccountService _emailAccountService;+ private readonly IWorkContext _workContext;public InteractiveFormController(IInteractiveFormService interactiveFormService,ITranslationService translationService,ILanguageService languageService,ICustomerActivityService customerActivityService,- IEmailAccountService emailAccountService)+ IEmailAccountService emailAccountService,+ IWorkContext workContext){_interactiveFormService = interactiveFormService;_translationService = translationService;_languageService = languageService;_customerActivityService = customerActivityService;_emailAccountService = emailAccountService;+ _workContext = workContext;}#region Utilities@@ -108,7 +112,9 @@ namespace Grand.Web.Admin.Controllersform.CreatedOnUtc = DateTime.UtcNow;await _interactiveFormService.InsertForm(form);- await _customerActivityService.InsertActivity("InteractiveFormAdd", form.Id, _translationService.GetResource("ActivityLog.InteractiveFormAdd"), form.Name);+ await _customerActivityService.InsertActivity("InteractiveFormAdd", form.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormAdd"), form.Name);Success(_translationService.GetResource("admin.marketing.InteractiveForms.Added"));return continueEditing ? RedirectToAction("Edit", new { id = form.Id }) : RedirectToAction("List");@@ -158,7 +164,9 @@ namespace Grand.Web.Admin.Controllersform = model.ToEntity(form);await _interactiveFormService.UpdateForm(form);- await _customerActivityService.InsertActivity("InteractiveFormEdit", form.Id, _translationService.GetResource("ActivityLog.InteractiveFormUpdate"), form.Name);+ await _customerActivityService.InsertActivity("InteractiveFormEdit", form.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormUpdate"), form.Name);Success(_translationService.GetResource("admin.marketing.InteractiveForms.Updated"));return continueEditing ? RedirectToAction("Edit", new { id = form.Id }) : RedirectToAction("List");@@ -188,7 +196,9 @@ namespace Grand.Web.Admin.Controllersreturn RedirectToAction("List");await _interactiveFormService.DeleteForm(form);- await _customerActivityService.InsertActivity("InteractiveFormDelete", form.Id, _translationService.GetResource("ActivityLog.InteractiveFormDeleted"), form.Name);+ await _customerActivityService.InsertActivity("InteractiveFormDelete", form.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormDeleted"), form.Name);Success(_translationService.GetResource("admin.marketing.InteractiveForms.Deleted"));return RedirectToAction("List");@@ -229,7 +239,9 @@ namespace Grand.Web.Admin.Controllersform.FormAttributes.Remove(form.FormAttributes.FirstOrDefault(x => x.Id == id));await _interactiveFormService.UpdateForm(form);- await _customerActivityService.InsertActivity("InteractiveFormEdit", form.Id, _translationService.GetResource("ActivityLog.InteractiveFormDeleteAttribute"), form.Name);+ await _customerActivityService.InsertActivity("InteractiveFormEdit", form.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormDeleteAttribute"), form.Name);return new JsonResult("");}@@ -263,7 +275,9 @@ namespace Grand.Web.Admin.Controllersform.FormAttributes.Add(attribute);await _interactiveFormService.UpdateForm(form);- await _customerActivityService.InsertActivity("InteractiveFormEdit", attribute.Id, _translationService.GetResource("ActivityLog.InteractiveFormAddAttribute"), attribute.Name);+ await _customerActivityService.InsertActivity("InteractiveFormEdit", attribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormAddAttribute"), attribute.Name);Success(_translationService.GetResource("admin.marketing.InteractiveForms.Attribute.Added"));@@ -311,7 +325,9 @@ namespace Grand.Web.Admin.Controllers{attribute = model.ToEntity(attribute);await _interactiveFormService.UpdateForm(form);- await _customerActivityService.InsertActivity("InteractiveFormEdit", attribute.Id, _translationService.GetResource("ActivityLog.InteractiveFormUpdateAttribute"), attribute.Name);+ await _customerActivityService.InsertActivity("InteractiveFormEdit", attribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormUpdateAttribute"), attribute.Name);Success(_translationService.GetResource("admin.marketing.InteractiveForms.Attribute.Updated"));return continueEditing ? RedirectToAction("EditAttribute", new { formId = form.Id, aid = attribute.Id }) : RedirectToAction("Edit", new { id = form.Id });}@@ -390,7 +406,9 @@ namespace Grand.Web.Admin.Controllersvar vaf = model.ToEntity();attribute.FormAttributeValues.Add(vaf);await _interactiveFormService.UpdateForm(fo);- await _customerActivityService.InsertActivity("InteractiveFormEdit", vaf.Id, _translationService.GetResource("ActivityLog.InteractiveFormAddAttributeValue"), vaf.Name);+ await _customerActivityService.InsertActivity("InteractiveFormEdit", vaf.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormAddAttributeValue"), vaf.Name);return Content("");}@@ -445,7 +463,9 @@ namespace Grand.Web.Admin.Controllers{vaf = model.ToEntity();await _interactiveFormService.UpdateForm(fo);- await _customerActivityService.InsertActivity("InteractiveFormEdit", vaf.Id, _translationService.GetResource("ActivityLog.InteractiveFormUpdateAttributeValue"), vaf.Name);+ await _customerActivityService.InsertActivity("InteractiveFormEdit", vaf.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormUpdateAttributeValue"), vaf.Name);return Content("");}@@ -469,7 +489,9 @@ namespace Grand.Web.Admin.Controllersattribute.FormAttributeValues.Remove(vaf);await _interactiveFormService.UpdateForm(form);- await _customerActivityService.InsertActivity("InteractiveFormEdit", vaf.Id, _translationService.GetResource("ActivityLog.InteractiveFormDeleteAttributeValue"), vaf.Name);+ await _customerActivityService.InsertActivity("InteractiveFormEdit", vaf.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.InteractiveFormDeleteAttributeValue"), vaf.Name);return new JsonResult("");}diff --git a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs b/src/Web/Grand.Web.Admin/Controllers/OrderController.csindex 7337fdc96..fcc92e867 100644--- a/src/Web/Grand.Web.Admin/Controllers/OrderController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/OrderController.cs@@ -413,7 +413,9 @@ namespace Grand.Web.Admin.Controllersif (ModelState.IsValid){await _mediator.Send(new DeleteOrderCommand() { Order = order });- await customerActivityService.InsertActivity("DeleteOrder", id, _translationService.GetResource("ActivityLog.DeleteOrder"), order.Id);+ await customerActivityService.InsertActivity("DeleteOrder", id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteOrder"), order.Id);return RedirectToAction("List");}Error(ModelState);@@ -444,7 +446,9 @@ namespace Grand.Web.Admin.Controllersif (!shipments.Any()){await _mediator.Send(new DeleteOrderCommand() { Order = order });- await customerActivityService.InsertActivity("DeleteOrder", order.Id, _translationService.GetResource("ActivityLog.DeleteOrder"), order.Id);+ await customerActivityService.InsertActivity("DeleteOrder", order.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteOrder"), order.Id);}}}diff --git a/src/Web/Grand.Web.Admin/Controllers/PaymentController.cs b/src/Web/Grand.Web.Admin/Controllers/PaymentController.csindex 12a193266..52ff28541 100644--- a/src/Web/Grand.Web.Admin/Controllers/PaymentController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/PaymentController.cs@@ -253,7 +253,9 @@ namespace Grand.Web.Admin.Controllersawait _settingService.SaveSetting(paymentSettings);//activity log- await customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));return RedirectToAction("Settings");diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.csindex 2dfe9b3ec..7065d0f68 100644--- a/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ProductAttributeController.cs@@ -110,7 +110,9 @@ namespace Grand.Web.Admin.Controllersawait _productAttributeService.InsertProductAttribute(productAttribute);//activity log- await _customerActivityService.InsertActivity("AddNewProductAttribute", productAttribute.Id, _translationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);+ await _customerActivityService.InsertActivity("AddNewProductAttribute", productAttribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewProductAttribute"), productAttribute.Name);Success(_translationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Added"));return continueEditing ? RedirectToAction("Edit", new { id = productAttribute.Id }) : RedirectToAction("List");@@ -159,7 +161,9 @@ namespace Grand.Web.Admin.Controllersawait _productAttributeService.UpdateProductAttribute(productAttribute);//activity log- await _customerActivityService.InsertActivity("EditProductAttribute", productAttribute.Id, _translationService.GetResource("ActivityLog.EditProductAttribute"), productAttribute.Name);+ await _customerActivityService.InsertActivity("EditProductAttribute", productAttribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditProductAttribute"), productAttribute.Name);Success(_translationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Updated"));if (continueEditing)@@ -198,7 +202,9 @@ namespace Grand.Web.Admin.Controllersawait _productAttributeService.DeleteProductAttribute(productAttribute);//activity log- await _customerActivityService.InsertActivity("DeleteProductAttribute", productAttribute.Id, _translationService.GetResource("ActivityLog.DeleteProductAttribute"), productAttribute.Name);+ await _customerActivityService.InsertActivity("DeleteProductAttribute", productAttribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteProductAttribute"), productAttribute.Name);Success(_translationService.GetResource("Admin.Catalog.Attributes.ProductAttributes.Deleted"));return RedirectToAction("List");diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductController.csindex b64e5603c..fa31ccdbc 100644--- a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs@@ -2941,7 +2941,9 @@ namespace Grand.Web.Admin.Controllersif (string.IsNullOrEmpty(toDelete.OrderId)){//activity log- await customerActivityService.InsertActivity("DeleteBid", toDelete.ProductId, _translationService.GetResource("ActivityLog.DeleteBid"), product.Name);+ await customerActivityService.InsertActivity("DeleteBid", toDelete.ProductId,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteBid"), product.Name);//delete bidawait _auctionService.DeleteBid(toDelete);return Json("");diff --git a/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.cs b/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.csindex 4ef302005..4f88c6950 100644--- a/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/SalesEmployeeController.cs@@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Mvc;using System;using System.Linq;using System.Threading.Tasks;+using Grand.Infrastructure;namespace Grand.Web.Admin.Controllers{@@ -28,7 +29,7 @@ namespace Grand.Web.Admin.Controllersprivate readonly ICustomerActivityService _customerActivityService;private readonly ITranslationService _translationService;private readonly IDocumentService _documentService;-+ private readonly IWorkContext _workContext;#endregion#region Constructors@@ -39,7 +40,9 @@ namespace Grand.Web.Admin.ControllersIOrderService orderService,IDocumentService documentService,ICustomerActivityService customerActivityService,- ITranslationService translationService)+ ITranslationService translationService,+ IWorkContext workContext+ ){_salesEmployeeService = salesEmployeeService;_customerService = customerService;@@ -47,6 +50,7 @@ namespace Grand.Web.Admin.Controllers_documentService = documentService;_customerActivityService = customerActivityService;_translationService = translationService;+ _workContext = workContext;}#endregion@@ -85,7 +89,9 @@ namespace Grand.Web.Admin.Controllersawait _salesEmployeeService.UpdateSalesEmployee(salesemployee);//activity log- await _customerActivityService.InsertActivity("EditSalesEmployee", salesemployee.Id, _translationService.GetResource("ActivityLog.EditSalesEmployee"),+ await _customerActivityService.InsertActivity("EditSalesEmployee", salesemployee.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSalesEmployee"),salesemployee.Name);return new JsonResult("");@@ -105,7 +111,9 @@ namespace Grand.Web.Admin.Controllersawait _salesEmployeeService.InsertSalesEmployee(salesEmployee);//activity log- await _customerActivityService.InsertActivity("AddNewSalesEmployee", salesEmployee.Id, _translationService.GetResource("ActivityLog.AddNewSalesEmployee"),+ await _customerActivityService.InsertActivity("AddNewSalesEmployee", salesEmployee.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewSalesEmployee"),salesEmployee.Name);return new JsonResult("");@@ -134,7 +142,9 @@ namespace Grand.Web.Admin.Controllersawait _salesEmployeeService.DeleteSalesEmployee(salesemployee);//activity log- await _customerActivityService.InsertActivity("DeleteSalesEmployee", salesemployee.Id, _translationService.GetResource("ActivityLog.DeleteSalesEmployee"),+ await _customerActivityService.InsertActivity("DeleteSalesEmployee", salesemployee.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteSalesEmployee"),salesemployee.Name);return new JsonResult("");diff --git a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs b/src/Web/Grand.Web.Admin/Controllers/SettingController.csindex e30d4cf9c..96594fd74 100644--- a/src/Web/Grand.Web.Admin/Controllers/SettingController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/SettingController.cs@@ -36,6 +36,7 @@ using Grand.Web.Common.Security.Authorization;using Grand.Web.Common.Security.Captcha;using Grand.Web.Common.Themes;using MediatR;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc;using Microsoft.AspNetCore.Mvc.Rendering;using System;@@ -149,7 +150,9 @@ namespace Grand.Web.Admin.Controllersawait ClearCache();//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));return RedirectToAction("Content");@@ -180,7 +183,9 @@ namespace Grand.Web.Admin.Controllersawait ClearCache();//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));return RedirectToAction("Vendor");@@ -209,7 +214,9 @@ namespace Grand.Web.Admin.Controllersawait ClearCache();//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));@@ -336,7 +343,9 @@ namespace Grand.Web.Admin.Controllersawait ClearCache();//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));return RedirectToAction("Sales");@@ -569,7 +578,9 @@ namespace Grand.Web.Admin.Controllersawait _pictureService.ClearThumbs();//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));return RedirectToAction("Media");@@ -589,7 +600,9 @@ namespace Grand.Web.Admin.Controllersawait SavePictureStorage(storeIdDb);//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));//now clear cacheawait ClearCache();@@ -663,7 +676,9 @@ namespace Grand.Web.Admin.Controllersawait ClearCache();//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));@@ -807,7 +822,9 @@ namespace Grand.Web.Admin.Controllersawait ClearCache();//activity log- await _customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await _customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));diff --git a/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs b/src/Web/Grand.Web.Admin/Controllers/ShippingController.csindex 35ef62e75..051391023 100644--- a/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/ShippingController.cs@@ -349,7 +349,9 @@ namespace Grand.Web.Admin.Controllersawait _settingService.SaveSetting(shippingSettings, storeScope);//activity log- await customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));return RedirectToAction("Settings");diff --git a/src/Web/Grand.Web.Admin/Controllers/SpecificationAttributeController.cs b/src/Web/Grand.Web.Admin/Controllers/SpecificationAttributeController.csindex 170d5bd40..6d7a2d97d 100644--- a/src/Web/Grand.Web.Admin/Controllers/SpecificationAttributeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/SpecificationAttributeController.cs@@ -105,7 +105,9 @@ namespace Grand.Web.Admin.Controllers}await _specificationAttributeService.InsertSpecificationAttribute(specificationAttribute);//activity log- await _customerActivityService.InsertActivity("AddNewSpecAttribute", specificationAttribute.Id, _translationService.GetResource("ActivityLog.AddNewSpecAttribute"), specificationAttribute.Name);+ await _customerActivityService.InsertActivity("AddNewSpecAttribute", specificationAttribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewSpecAttribute"), specificationAttribute.Name);Success(_translationService.GetResource("Admin.Catalog.Attributes.SpecificationAttributes.Added"));return continueEditing ? RedirectToAction("Edit", new { id = specificationAttribute.Id }) : RedirectToAction("List");}@@ -152,7 +154,9 @@ namespace Grand.Web.Admin.Controllers}await _specificationAttributeService.UpdateSpecificationAttribute(specificationAttribute);//activity log- await _customerActivityService.InsertActivity("EditSpecAttribute", specificationAttribute.Id, _translationService.GetResource("ActivityLog.EditSpecAttribute"), specificationAttribute.Name);+ await _customerActivityService.InsertActivity("EditSpecAttribute", specificationAttribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSpecAttribute"), specificationAttribute.Name);Success(_translationService.GetResource("Admin.Catalog.Attributes.SpecificationAttributes.Updated"));@@ -189,7 +193,9 @@ namespace Grand.Web.Admin.Controllersawait _specificationAttributeService.DeleteSpecificationAttribute(specificationAttribute);//activity log- await _customerActivityService.InsertActivity("DeleteSpecAttribute", specificationAttribute.Id, _translationService.GetResource("ActivityLog.DeleteSpecAttribute"), specificationAttribute.Name);+ await _customerActivityService.InsertActivity("DeleteSpecAttribute", specificationAttribute.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteSpecAttribute"), specificationAttribute.Name);Success(_translationService.GetResource("Admin.Catalog.Attributes.SpecificationAttributes.Deleted"));return RedirectToAction("List");diff --git a/src/Web/Grand.Web.Admin/Controllers/TaxController.cs b/src/Web/Grand.Web.Admin/Controllers/TaxController.csindex 8e86ad8ca..623fc7eed 100644--- a/src/Web/Grand.Web.Admin/Controllers/TaxController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/TaxController.cs@@ -194,7 +194,9 @@ namespace Grand.Web.Admin.Controllersawait ClearCache();//activity log- await customerActivityService.InsertActivity("EditSettings", "", _translationService.GetResource("ActivityLog.EditSettings"));+ await customerActivityService.InsertActivity("EditSettings", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditSettings"));Success(_translationService.GetResource("Admin.Configuration.Updated"));return RedirectToAction("Settings");diff --git a/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs b/src/Web/Grand.Web.Admin/Services/BrandViewModelService.csindex 0e8150a9e..852a51cee 100644--- a/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/BrandViewModelService.cs@@ -15,6 +15,7 @@ using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Collections.Generic;@@ -38,6 +39,7 @@ namespace Grand.Web.Admin.Servicesprivate readonly IDateTimeService _dateTimeService;private readonly ILanguageService _languageService;private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;private readonly SeoSettings _seoSettings;#endregion@@ -56,6 +58,7 @@ namespace Grand.Web.Admin.ServicesIDateTimeService dateTimeService,ILanguageService languageService,IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor,SeoSettings seoSettings){_brandLayoutService = brandLayoutService;@@ -69,6 +72,7 @@ namespace Grand.Web.Admin.Services_dateTimeService = dateTimeService;_languageService = languageService;_workContext = workContext;+ _httpContextAccessor = httpContextAccessor;_seoSettings = seoSettings;}@@ -141,7 +145,9 @@ namespace Grand.Web.Admin.Servicesawait _pictureService.UpdatePictureSeoNames(brand.PictureId, brand.Name);//activity log- await _customerActivityService.InsertActivity("AddNewBrand", brand.Id, _translationService.GetResource("ActivityLog.AddNewBrand"), brand.Name);+ await _customerActivityService.InsertActivity("AddNewBrand", brand.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewBrand"), brand.Name);return brand;}@@ -186,7 +192,9 @@ namespace Grand.Web.Admin.Servicesawait _pictureService.UpdatePictureSeoNames(brand.PictureId, brand.Name);//activity log- await _customerActivityService.InsertActivity("EditBrand", brand.Id, _translationService.GetResource("ActivityLog.EditBrand"), brand.Name);+ await _customerActivityService.InsertActivity("EditBrand", brand.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditBrand"), brand.Name);return brand;}@@ -194,7 +202,9 @@ namespace Grand.Web.Admin.Services{await _brandService.DeleteBrand(brand);//activity log- await _customerActivityService.InsertActivity("DeleteBrand", brand.Id, _translationService.GetResource("ActivityLog.DeleteBrand"), brand.Name);+ await _customerActivityService.InsertActivity("DeleteBrand", brand.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteBrand"), brand.Name);}public virtual async Task<(IEnumerable<BrandModel.ActivityLogModel> activityLogModels, int totalCount)> PrepareActivityLogModel(string brandId, int pageIndex, int pageSize)diff --git a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.csindex d55795c70..0be908439 100644--- a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs@@ -12,10 +12,12 @@ using Grand.Business.Storage.Interfaces;using Grand.Domain.Catalog;using Grand.Domain.Discounts;using Grand.Domain.Seo;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Collections.Generic;@@ -40,13 +42,31 @@ namespace Grand.Web.Admin.Servicesprivate readonly IVendorService _vendorService;private readonly IDateTimeService _dateTimeService;private readonly ILanguageService _languageService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;+private readonly CatalogSettings _catalogSettings;private readonly SeoSettings _seoSettings;- public CategoryViewModelService(ICategoryService categoryService, IProductCategoryService productCategoryService, ICategoryLayoutService categoryLayoutService, IDiscountService discountService,- ITranslationService translationService, IStoreService storeService, ICustomerService customerService, IPictureService pictureService,- ISlugService slugService, ICustomerActivityService customerActivityService, IProductService productService,- IVendorService vendorService, IDateTimeService dateTimeService, ILanguageService languageService, CatalogSettings catalogSettings, SeoSettings seoSettings)+ public CategoryViewModelService(+ ICategoryService categoryService,+ IProductCategoryService productCategoryService,+ ICategoryLayoutService categoryLayoutService,+ IDiscountService discountService,+ ITranslationService translationService,+ IStoreService storeService,+ ICustomerService customerService,+ IPictureService pictureService,+ ISlugService slugService,+ ICustomerActivityService customerActivityService,+ IProductService productService,+ IVendorService vendorService,+ IDateTimeService dateTimeService,+ ILanguageService languageService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor,+ CatalogSettings catalogSettings,+ SeoSettings seoSettings){_categoryService = categoryService;_productCategoryService = productCategoryService;@@ -61,6 +81,8 @@ namespace Grand.Web.Admin.Services_pictureService = pictureService;_vendorService = vendorService;_languageService = languageService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;_catalogSettings = catalogSettings;_dateTimeService = dateTimeService;_seoSettings = seoSettings;@@ -188,7 +210,9 @@ namespace Grand.Web.Admin.Servicesawait _pictureService.UpdatePictureSeoNames(category.PictureId, category.Name);//activity log- await _customerActivityService.InsertActivity("AddNewCategory", category.Id, _translationService.GetResource("ActivityLog.AddNewCategory"), category.Name);+ await _customerActivityService.InsertActivity("AddNewCategory", category.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCategory"), category.Name);return category;}@@ -235,14 +259,18 @@ namespace Grand.Web.Admin.Servicesawait _pictureService.UpdatePictureSeoNames(category.PictureId, category.Name);//activity log- await _customerActivityService.InsertActivity("EditCategory", category.Id, _translationService.GetResource("ActivityLog.EditCategory"), category.Name);+ await _customerActivityService.InsertActivity("EditCategory", category.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCategory"), category.Name);return category;}public virtual async Task DeleteCategory(Category category){await _categoryService.DeleteCategory(category);//activity log- await _customerActivityService.InsertActivity("DeleteCategory", category.Id, _translationService.GetResource("ActivityLog.DeleteCategory"), category.Name);+ await _customerActivityService.InsertActivity("DeleteCategory", category.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCategory"), category.Name);}public virtual async Task<(IEnumerable<CategoryModel.CategoryProductModel> categoryProductModels, int totalCount)> PrepareCategoryProductModel(string categoryId, int pageIndex, int pageSize)diff --git a/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.csindex 8cfaa31fe..20a3d1c7b 100644--- a/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CheckoutAttributeViewModelService.cs@@ -18,6 +18,7 @@ using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;+using Microsoft.AspNetCore.Http;namespace Grand.Web.Admin.Services{@@ -29,6 +30,7 @@ namespace Grand.Web.Admin.Servicesprivate readonly ITaxCategoryService _taxCategoryService;private readonly IWorkContext _workContext;private readonly ICurrencyService _currencyService;+ private readonly IHttpContextAccessor _httpContextAccessor;private readonly CurrencySettings _currencySettings;private readonly IMeasureService _measureService;private readonly MeasureSettings _measureSettings;@@ -42,6 +44,7 @@ namespace Grand.Web.Admin.ServicesIWorkContext workContext,ICurrencyService currencyService,ICustomerActivityService customerActivityService,+ IHttpContextAccessor httpContextAccessor,CurrencySettings currencySettings,IMeasureService measureService,MeasureSettings measureSettings@@ -54,6 +57,7 @@ namespace Grand.Web.Admin.Services_workContext = workContext;_currencyService = currencyService;_customerActivityService = customerActivityService;+ _httpContextAccessor = httpContextAccessor;_currencySettings = currencySettings;_measureService = measureService;_measureSettings = measureSettings;@@ -228,7 +232,9 @@ namespace Grand.Web.Admin.Servicesawait _checkoutAttributeService.InsertCheckoutAttribute(checkoutAttribute);//activity log- await _customerActivityService.InsertActivity("AddNewCheckoutAttribute", checkoutAttribute.Id, _translationService.GetResource("ActivityLog.AddNewCheckoutAttribute"), checkoutAttribute.Name);+ await _customerActivityService.InsertActivity("AddNewCheckoutAttribute", checkoutAttribute.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCheckoutAttribute"), checkoutAttribute.Name);return checkoutAttribute;}public virtual async Task<CheckoutAttribute> UpdateCheckoutAttributeModel(CheckoutAttribute checkoutAttribute, CheckoutAttributeModel model)@@ -238,7 +244,9 @@ namespace Grand.Web.Admin.Servicesawait _checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);//activity log- await _customerActivityService.InsertActivity("EditCheckoutAttribute", checkoutAttribute.Id, _translationService.GetResource("ActivityLog.EditCheckoutAttribute"), checkoutAttribute.Name);+ await _customerActivityService.InsertActivity("EditCheckoutAttribute", checkoutAttribute.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCheckoutAttribute"), checkoutAttribute.Name);return checkoutAttribute;}diff --git a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.csindex 0033cda98..93fddafaa 100644--- a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs@@ -1,6 +1,5 @@-using Grand.Business.Catalog.Interfaces.Categories;+using Grand.Business.Catalog.Interfaces.Collections;using Grand.Business.Catalog.Interfaces.Discounts;-using Grand.Business.Catalog.Interfaces.Collections;using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Extensions;using Grand.Business.Common.Interfaces.Directory;@@ -10,14 +9,15 @@ using Grand.Business.Common.Interfaces.Seo;using Grand.Business.Common.Interfaces.Stores;using Grand.Business.Customers.Interfaces;using Grand.Business.Storage.Interfaces;-using Grand.Infrastructure;using Grand.Domain.Catalog;using Grand.Domain.Discounts;using Grand.Domain.Seo;-using Grand.Web.Common.Extensions;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;+using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Collections.Generic;@@ -45,6 +45,7 @@ namespace Grand.Web.Admin.Servicesprivate readonly IDateTimeService _dateTimeService;private readonly ILanguageService _languageService;private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;private readonly SeoSettings _seoSettings;#endregion@@ -67,6 +68,7 @@ namespace Grand.Web.Admin.ServicesIDateTimeService dateTimeService,ILanguageService languageService,IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor,SeoSettings seoSettings){_collectionLayoutService = collectionLayoutService;@@ -84,6 +86,7 @@ namespace Grand.Web.Admin.Services_dateTimeService = dateTimeService;_languageService = languageService;_workContext = workContext;+ _httpContextAccessor = httpContextAccessor;_seoSettings = seoSettings;}@@ -106,8 +109,7 @@ namespace Grand.Web.Admin.Servicesvar layouts = await _collectionLayoutService.GetAllCollectionLayouts();foreach (var layout in layouts){- model.AvailableCollectionLayouts.Add(new SelectListItem- {+ model.AvailableCollectionLayouts.Add(new SelectListItem {Text = layout.Name,Value = layout.Id});@@ -157,7 +159,9 @@ namespace Grand.Web.Admin.Servicesawait _pictureService.UpdatePictureSeoNames(collection.PictureId, collection.Name);//activity log- await _customerActivityService.InsertActivity("AddNewCollection", collection.Id, _translationService.GetResource("ActivityLog.AddNewCollection"), collection.Name);+ await _customerActivityService.InsertActivity("AddNewCollection", collection.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCollection"), collection.Name);return collection;}@@ -202,7 +206,9 @@ namespace Grand.Web.Admin.Servicesawait _pictureService.UpdatePictureSeoNames(collection.PictureId, collection.Name);//activity log- await _customerActivityService.InsertActivity("EditCollection", collection.Id, _translationService.GetResource("ActivityLog.EditCollection"), collection.Name);+ await _customerActivityService.InsertActivity("EditCollection", collection.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCollection"), collection.Name);return collection;}@@ -210,13 +216,15 @@ namespace Grand.Web.Admin.Services{await _collectionService.DeleteCollection(collection);//activity log- await _customerActivityService.InsertActivity("DeleteCollection", collection.Id, _translationService.GetResource("ActivityLog.DeleteCollection"), collection.Name);+ await _customerActivityService.InsertActivity("DeleteCollection", collection.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCollection"), collection.Name);}public virtual async Task<CollectionModel.AddCollectionProductModel> PrepareAddCollectionProductModel(string storeId){var model = new CollectionModel.AddCollectionProductModel();-+//collectionsmodel.AvailableCollections.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });foreach (var m in await _collectionService.GetAllCollections(showHidden: true))@@ -251,8 +259,7 @@ namespace Grand.Web.Admin.Servicesvar items = new List<CollectionModel.CollectionProductModel>();foreach (var x in productCollections){- items.Add(new CollectionModel.CollectionProductModel- {+ items.Add(new CollectionModel.CollectionProductModel {Id = x.Id,CollectionId = x.CollectionId,ProductId = x.ProductId,@@ -275,7 +282,7 @@ namespace Grand.Web.Admin.ServicesproductCollection.IsFeaturedProduct = model.IsFeaturedProduct;productCollection.DisplayOrder = model.DisplayOrder;-+await _productCollectionService.UpdateProductCollection(productCollection, model.ProductId);}public virtual async Task ProductDelete(string id, string productId)@@ -302,8 +309,7 @@ namespace Grand.Web.Admin.Servicesif (product.ProductCollections.Where(x => x.CollectionId == model.CollectionId).Count() == 0){await _productCollectionService.InsertProductCollection(- new ProductCollection- {+ new ProductCollection {CollectionId = model.CollectionId,IsFeaturedProduct = false,DisplayOrder = 1,@@ -319,8 +325,7 @@ namespace Grand.Web.Admin.Servicesforeach (var x in activityLog){var customer = await _customerService.GetCustomerById(x.CustomerId);- var m = new CollectionModel.ActivityLogModel- {+ var m = new CollectionModel.ActivityLogModel {Id = x.Id,ActivityLogTypeName = (await _customerActivityService.GetActivityTypeById(x.ActivityLogTypeId))?.Name,Comment = x.Comment,diff --git a/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.csindex 8e144b3c1..6380d4c67 100644--- a/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/ContactAttributeViewModelService.cs@@ -15,6 +15,7 @@ using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;+using Microsoft.AspNetCore.Http;namespace Grand.Web.Admin.Services{@@ -26,18 +27,21 @@ namespace Grand.Web.Admin.Servicesprivate readonly ITranslationService _translationService;private readonly IWorkContext _workContext;private readonly ICustomerActivityService _customerActivityService;+ private readonly IHttpContextAccessor _httpContextAccessor;public ContactAttributeViewModelService(IContactAttributeService contactAttributeService,IContactAttributeParser contactAttributeParser,ITranslationService translationService,IWorkContext workContext,- ICustomerActivityService customerActivityService)+ ICustomerActivityService customerActivityService,+ IHttpContextAccessor httpContextAccessor){_contactAttributeService = contactAttributeService;_contactAttributeParser = contactAttributeParser;_translationService = translationService;_workContext = workContext;_customerActivityService = customerActivityService;+ _httpContextAccessor = httpContextAccessor;}#region Utilities@@ -148,7 +152,9 @@ namespace Grand.Web.Admin.Servicesawait _contactAttributeService.InsertContactAttribute(contactAttribute);//activity log- await _customerActivityService.InsertActivity("AddNewContactAttribute", contactAttribute.Id, _translationService.GetResource("ActivityLog.AddNewContactAttribute"), contactAttribute.Name);+ await _customerActivityService.InsertActivity("AddNewContactAttribute", contactAttribute.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewContactAttribute"), contactAttribute.Name);return contactAttribute;}public virtual async Task<ContactAttribute> UpdateContactAttributeModel(ContactAttribute contactAttribute, ContactAttributeModel model)@@ -158,7 +164,9 @@ namespace Grand.Web.Admin.Servicesawait _contactAttributeService.UpdateContactAttribute(contactAttribute);//activity log- await _customerActivityService.InsertActivity("EditContactAttribute", contactAttribute.Id, _translationService.GetResource("ActivityLog.EditContactAttribute"), contactAttribute.Name);+ await _customerActivityService.InsertActivity("EditContactAttribute", contactAttribute.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditContactAttribute"), contactAttribute.Name);return contactAttribute;}diff --git a/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CourseViewModelService.csindex cf212c320..1553035d4 100644--- a/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CourseViewModelService.cs@@ -17,6 +17,7 @@ using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Admin.Models.Courses;using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using Microsoft.Extensions.DependencyInjection;using System;@@ -39,14 +40,26 @@ namespace Grand.Web.Admin.Servicesprivate readonly ICustomerActivityService _customerActivityService;private readonly IProductCourseService _productCourseService;private readonly IDownloadService _downloadService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;+private readonly IServiceProvider _serviceProvider;private readonly SeoSettings _seoSettings;- public CourseViewModelService(ICourseService courseService, ICourseLevelService courseLevelService, ICourseLessonService courseLessonService,+ public CourseViewModelService(+ ICourseService courseService,+ ICourseLevelService courseLevelService,+ ICourseLessonService courseLessonService,ICourseSubjectService courseSubjectService,- ISlugService slugService, IPictureService pictureService, ILanguageService languageService,- ITranslationService translationService, ICustomerActivityService customerActivityService, IProductCourseService productCourseService,+ ISlugService slugService,+ IPictureService pictureService,+ ILanguageService languageService,+ ITranslationService translationService,+ ICustomerActivityService customerActivityService,+ IProductCourseService productCourseService,IDownloadService downloadService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor,IServiceProvider serviceProvider,SeoSettings seoSettings){@@ -61,6 +74,8 @@ namespace Grand.Web.Admin.Services_customerActivityService = customerActivityService;_productCourseService = productCourseService;_downloadService = downloadService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;_serviceProvider = serviceProvider;_seoSettings = seoSettings;}@@ -113,7 +128,9 @@ namespace Grand.Web.Admin.Services//activity log- await _customerActivityService.InsertActivity("AddNewCourse", course.Id, _translationService.GetResource("ActivityLog.AddNewCourse"), course.Name);+ await _customerActivityService.InsertActivity("AddNewCourse", course.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCourse"), course.Name);return course;}@@ -151,7 +168,9 @@ namespace Grand.Web.Admin.Servicesawait _productCourseService.UpdateCourseOnProduct(course.ProductId, course.Id);//activity log- await _customerActivityService.InsertActivity("EditCourse", course.Id, _translationService.GetResource("ActivityLog.EditCourse"), course.Name);+ await _customerActivityService.InsertActivity("EditCourse", course.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCourse"), course.Name);return course;}@@ -159,7 +178,9 @@ namespace Grand.Web.Admin.Services{await _courseService.Delete(course);//activity log- await _customerActivityService.InsertActivity("DeleteCourse", course.Id, _translationService.GetResource("ActivityLog.DeleteCourse"), course.Name);+ await _customerActivityService.InsertActivity("DeleteCourse", course.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCourse"), course.Name);}public virtual async Task<CourseLessonModel> PrepareCourseLessonModel(string courseId, CourseLessonModel model = null)@@ -188,7 +209,9 @@ namespace Grand.Web.Admin.Servicesvar lesson = model.ToEntity();await _courseLessonService.Insert(lesson);//activity log- await _customerActivityService.InsertActivity("AddNewCourseLesson", lesson.Id, _translationService.GetResource("ActivityLog.AddNewCourseLesson"), lesson.Name);+ await _customerActivityService.InsertActivity("AddNewCourseLesson", lesson.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCourseLesson"), lesson.Name);return lesson;}@@ -226,7 +249,9 @@ namespace Grand.Web.Admin.Services}//activity log- await _customerActivityService.InsertActivity("EditCourseLesson", lesson.Id, _translationService.GetResource("ActivityLog.EditLessonCourse"), lesson.Name);+ await _customerActivityService.InsertActivity("EditCourseLesson", lesson.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditLessonCourse"), lesson.Name);return lesson;}@@ -249,7 +274,9 @@ namespace Grand.Web.Admin.Services}//activity log- await _customerActivityService.InsertActivity("DeleteCourseLesson", lesson.Id, _translationService.GetResource("ActivityLog.DeleteCourseLesson"), lesson.Name);+ await _customerActivityService.InsertActivity("DeleteCourseLesson", lesson.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCourseLesson"), lesson.Name);}public virtual async Task<CourseModel.AssociateProductToCourseModel> PrepareAssociateProductToCourseModel()diff --git a/src/Web/Grand.Web.Admin/Services/CustomerActionViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerActionViewModelService.csindex 26eb5a7d8..ec9f91eda 100644--- a/src/Web/Grand.Web.Admin/Services/CustomerActionViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CustomerActionViewModelService.cs@@ -10,17 +10,18 @@ using Grand.Business.Marketing.Interfaces.Customers;using Grand.Business.Messages.Interfaces;using Grand.Domain.Catalog;using Grand.Domain.Customers;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Admin.Models.Customers;using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;-using static Grand.Domain.Customers.CustomerAction;namespace Grand.Web.Admin.Services{@@ -39,6 +40,8 @@ namespace Grand.Web.Admin.Servicesprivate readonly IMessageTemplateService _messageTemplateService;private readonly IDateTimeService _dateTimeService;private readonly IProductService _productService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;public CustomerActionViewModelService(ICustomerService customerService,IGroupService groupService,@@ -52,7 +55,9 @@ namespace Grand.Web.Admin.ServicesIInteractiveFormService interactiveFormService,IMessageTemplateService messageTemplateService,IDateTimeService dateTimeService,- IProductService productService)+ IProductService productService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor){_customerService = customerService;_groupService = groupService;@@ -67,6 +72,8 @@ namespace Grand.Web.Admin.Services_messageTemplateService = messageTemplateService;_dateTimeService = dateTimeService;_productService = productService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;}public virtual async Task PrepareReactObjectModel(CustomerActionModel model)@@ -159,7 +166,9 @@ namespace Grand.Web.Admin.Services{var customeraction = model.ToEntity(_dateTimeService);await _customerActionService.InsertCustomerAction(customeraction);- await _customerActivityService.InsertActivity("AddNewCustomerAction", customeraction.Id, _translationService.GetResource("ActivityLog.AddNewCustomerAction"), customeraction.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerAction", customeraction.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCustomerAction"), customeraction.Name);return customeraction;}public virtual async Task<CustomerAction> UpdateCustomerActionModel(CustomerAction customeraction, CustomerActionModel model)@@ -171,7 +180,9 @@ namespace Grand.Web.Admin.Servicescustomeraction = model.ToEntity(customeraction, _dateTimeService);await _customerActionService.UpdateCustomerAction(customeraction);- await _customerActivityService.InsertActivity("EditCustomerAction", customeraction.Id, _translationService.GetResource("ActivityLog.EditCustomerAction"), customeraction.Name);+ await _customerActivityService.InsertActivity("EditCustomerAction", customeraction.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCustomerAction"), customeraction.Name);return customeraction;}@@ -210,16 +221,20 @@ namespace Grand.Web.Admin.ServicescustomerAction.Conditions.Add(condition);await _customerActionService.UpdateCustomerAction(customerAction);- await _customerActivityService.InsertActivity("AddNewCustomerActionCondition", customerAction.Id, _translationService.GetResource("ActivityLog.AddNewCustomerAction"), customerAction.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerActionCondition", customerAction.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCustomerAction"), customerAction.Name);return (customerAction.Id, condition.Id);}- public virtual async Task<CustomerAction> UpdateCustomerActionConditionModel(CustomerAction customeraction, ActionCondition condition, CustomerActionConditionModel model)+ public virtual async Task<CustomerAction> UpdateCustomerActionConditionModel(CustomerAction customeraction, CustomerAction.ActionCondition condition, CustomerActionConditionModel model){condition = model.ToEntity(condition);await _customerActionService.UpdateCustomerAction(customeraction);//activity log- await _customerActivityService.InsertActivity("EditCustomerActionCondition", customeraction.Id, _translationService.GetResource("ActivityLog.EditCustomerActionCondition"), customeraction.Name);+ await _customerActivityService.InsertActivity("EditCustomerActionCondition", customeraction.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCustomerActionCondition"), customeraction.Name);return customeraction;}diff --git a/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.csindex 35288e68d..1ffa01cd3 100644--- a/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.cs@@ -6,11 +6,13 @@ using Grand.Business.Common.Interfaces.Stores;using Grand.Business.Customers.Interfaces;using Grand.Domain.Catalog;using Grand.Domain.Customers;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Admin.Models.Customers;using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System.Collections.Generic;using System.Linq;@@ -28,6 +30,8 @@ namespace Grand.Web.Admin.Servicesprivate readonly IStoreService _storeService;private readonly IVendorService _vendorService;private readonly IDateTimeService _dateTimeService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;#region Constructors@@ -39,7 +43,9 @@ namespace Grand.Web.Admin.ServicesIProductService productService,IStoreService storeService,IVendorService vendorService,- IDateTimeService dateTimeService)+ IDateTimeService dateTimeService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor){_groupService = groupService;_customerGroupProductService = customerGroupProductService;@@ -49,6 +55,8 @@ namespace Grand.Web.Admin.Services_storeService = storeService;_vendorService = vendorService;_dateTimeService = dateTimeService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;}#endregion@@ -72,7 +80,9 @@ namespace Grand.Web.Admin.Servicesvar customerGroup = model.ToEntity();await _groupService.InsertCustomerGroup(customerGroup);//activity log- await _customerActivityService.InsertActivity("AddNewCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.AddNewCustomerGroup"), customerGroup.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerGroup", customerGroup.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCustomerGroup"), customerGroup.Name);return customerGroup;}public virtual async Task<CustomerGroup> UpdateCustomerGroupModel(CustomerGroup customerGroup, CustomerGroupModel model)@@ -81,7 +91,9 @@ namespace Grand.Web.Admin.Servicesawait _groupService.UpdateCustomerGroup(customerGroup);//activity log- await _customerActivityService.InsertActivity("EditCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.EditCustomerGroup"), customerGroup.Name);+ await _customerActivityService.InsertActivity("EditCustomerGroup", customerGroup.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCustomerGroup"), customerGroup.Name);return customerGroup;}public virtual async Task DeleteCustomerGroup(CustomerGroup customerGroup)@@ -89,7 +101,9 @@ namespace Grand.Web.Admin.Servicesawait _groupService.DeleteCustomerGroup(customerGroup);//activity log- await _customerActivityService.InsertActivity("DeleteCustomerGroup", customerGroup.Id, _translationService.GetResource("ActivityLog.DeleteCustomerGroup"), customerGroup.Name);+ await _customerActivityService.InsertActivity("DeleteCustomerGroup", customerGroup.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCustomerGroup"), customerGroup.Name);}public virtual async Task<IList<CustomerGroupProductModel>> PrepareCustomerGroupProductModel(string customerGroupId){diff --git a/src/Web/Grand.Web.Admin/Services/CustomerReminderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerReminderViewModelService.csindex ee0af2aa2..b2154f21e 100644--- a/src/Web/Grand.Web.Admin/Services/CustomerReminderViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CustomerReminderViewModelService.cs@@ -1,6 +1,4 @@-using Grand.Business.Catalog.Interfaces.Categories;-using Grand.Business.Catalog.Interfaces.Collections;-using Grand.Business.Catalog.Interfaces.Products;+using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Common.Interfaces.Directory;using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;@@ -11,11 +9,13 @@ using Grand.Business.Marketing.Services.Customers;using Grand.Business.Messages.Interfaces;using Grand.Domain.Catalog;using Grand.Domain.Customers;-using Grand.Web.Common.Extensions;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Admin.Models.Customers;+using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using Microsoft.Extensions.DependencyInjection;using System;@@ -33,6 +33,8 @@ namespace Grand.Web.Admin.Servicesprivate readonly ICustomerReminderService _customerReminderService;private readonly IEmailAccountService _emailAccountService;private readonly IDateTimeService _dateTimeService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;private readonly IServiceProvider _serviceProvider;#region Constructors@@ -43,6 +45,8 @@ namespace Grand.Web.Admin.ServicesICustomerReminderService customerReminderService,IEmailAccountService emailAccountService,IDateTimeService dateTimeService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor,IServiceProvider serviceProvider){_customerService = customerService;@@ -51,6 +55,8 @@ namespace Grand.Web.Admin.Services_customerReminderService = customerReminderService;_emailAccountService = emailAccountService;_dateTimeService = dateTimeService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;_serviceProvider = serviceProvider;}@@ -73,7 +79,9 @@ namespace Grand.Web.Admin.Servicesvar customerreminder = model.ToEntity(_dateTimeService);await _customerReminderService.InsertCustomerReminder(customerreminder);//activity log- await _customerActivityService.InsertActivity("AddNewCustomerReminder", customerreminder.Id, _translationService.GetResource("ActivityLog.AddNewCustomerReminder"), customerreminder.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerReminder", customerreminder.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCustomerReminder"), customerreminder.Name);return customerreminder;}public virtual async Task<CustomerReminder> UpdateCustomerReminderModel(CustomerReminder customerReminder, CustomerReminderModel model)@@ -85,7 +93,9 @@ namespace Grand.Web.Admin.ServicescustomerReminder = model.ToEntity(customerReminder, _dateTimeService);await _customerReminderService.UpdateCustomerReminder(customerReminder);- await _customerActivityService.InsertActivity("EditCustomerReminder", customerReminder.Id, _translationService.GetResource("ActivityLog.EditCustomerReminder"), customerReminder.Name);+ await _customerActivityService.InsertActivity("EditCustomerReminder", customerReminder.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCustomerReminder"), customerReminder.Name);return customerReminder;}public virtual async Task RunReminder(CustomerReminder customerReminder)@@ -107,15 +117,16 @@ namespace Grand.Web.Admin.Services}public virtual async Task DeleteCustomerReminder(CustomerReminder customerReminder){- await _customerActivityService.InsertActivity("DeleteCustomerReminder", customerReminder.Id, _translationService.GetResource("ActivityLog.DeleteCustomerReminder"), customerReminder.Name);+ await _customerActivityService.InsertActivity("DeleteCustomerReminder", customerReminder.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCustomerReminder"), customerReminder.Name);await _customerReminderService.DeleteCustomerReminder(customerReminder);}public virtual async Task<SerializeCustomerReminderHistoryModel> PrepareHistoryModelForList(SerializeCustomerReminderHistory history){- return new SerializeCustomerReminderHistoryModel- {+ return new SerializeCustomerReminderHistoryModel {Id = history.Id,Email = (await _customerService.GetCustomerById(history.CustomerId)).Email,SendDate = _dateTimeService.ConvertToUserTime(history.SendDate, DateTimeKind.Utc),@@ -132,8 +143,7 @@ namespace Grand.Web.Admin.Services{if (customerReminder.ReminderRuleId == CustomerReminderRuleEnum.AbandonedCart || customerReminder.ReminderRuleId == CustomerReminderRuleEnum.CompletedOrder|| customerReminder.ReminderRuleId == CustomerReminderRuleEnum.UnpaidOrder)- model.ConditionType.Add(new SelectListItem()- {+ model.ConditionType.Add(new SelectListItem() {Value = ((int)item).ToString(),Text = item.ToString()});@@ -143,8 +153,7 @@ namespace Grand.Web.Admin.Servicesitem != CustomerReminderConditionTypeEnum.Collection &&item != CustomerReminderConditionTypeEnum.Category){- model.ConditionType.Add(new SelectListItem()- {+ model.ConditionType.Add(new SelectListItem() {Value = ((int)item).ToString(),Text = item.ToString()});@@ -156,8 +165,7 @@ namespace Grand.Web.Admin.Services}public virtual async Task<CustomerReminder.ReminderCondition> InsertConditionModel(CustomerReminder customerReminder, CustomerReminderModel.ConditionModel model){- var condition = new CustomerReminder.ReminderCondition()- {+ var condition = new CustomerReminder.ReminderCondition() {Name = model.Name,ConditionTypeId = model.ConditionTypeId,ConditionId = model.ConditionId,@@ -165,7 +173,9 @@ namespace Grand.Web.Admin.ServicescustomerReminder.Conditions.Add(condition);await _customerReminderService.UpdateCustomerReminder(customerReminder);- await _customerActivityService.InsertActivity("AddNewCustomerReminderCondition", customerReminder.Id, _translationService.GetResource("ActivityLog.AddNewCustomerReminder"), customerReminder.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerReminderCondition", customerReminder.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCustomerReminder"), customerReminder.Name);return condition;}@@ -176,8 +186,7 @@ namespace Grand.Web.Admin.Servicesmodel.CustomerReminderId = customerReminder.Id;foreach (CustomerReminderConditionTypeEnum item in Enum.GetValues(typeof(CustomerReminderConditionTypeEnum))){- model.ConditionType.Add(new SelectListItem()- {+ model.ConditionType.Add(new SelectListItem() {Value = ((int)item).ToString(),Text = item.ToString()});@@ -188,7 +197,9 @@ namespace Grand.Web.Admin.Services{condition = model.ToEntity(condition);await _customerReminderService.UpdateCustomerReminder(customerReminder);- await _customerActivityService.InsertActivity("EditCustomerReminderCondition", customerReminder.Id, _translationService.GetResource("ActivityLog.EditCustomerReminderCondition"), customerReminder.Name);+ await _customerActivityService.InsertActivity("EditCustomerReminderCondition", customerReminder.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCustomerReminderCondition"), customerReminder.Name);return condition;}public virtual async Task ConditionDelete(string Id, string customerReminderId)@@ -344,8 +355,7 @@ namespace Grand.Web.Admin.Servicesvar condition = customerReminder.Conditions.FirstOrDefault(x => x.Id == model.ConditionId);if (condition != null){- var _cr = new CustomerReminder.ReminderCondition.CustomerRegister()- {+ var _cr = new CustomerReminder.ReminderCondition.CustomerRegister() {RegisterField = model.CustomerRegisterName,RegisterValue = model.CustomerRegisterValue,};@@ -377,8 +387,7 @@ namespace Grand.Web.Admin.Servicesvar condition = customerReminder.Conditions.FirstOrDefault(x => x.Id == model.ConditionId);if (condition != null){- var _cr = new CustomerReminder.ReminderCondition.CustomerRegister()- {+ var _cr = new CustomerReminder.ReminderCondition.CustomerRegister() {RegisterField = model.CustomerAttributeName,RegisterValue = model.CustomerAttributeValue,};@@ -410,8 +419,7 @@ namespace Grand.Web.Admin.Servicesvar emailAccounts = await _emailAccountService.GetAllEmailAccounts();foreach (var item in emailAccounts){- model.EmailAccounts.Add(new SelectListItem- {+ model.EmailAccounts.Add(new SelectListItem {Text = item.Email,Value = item.Id.ToString()});@@ -421,8 +429,7 @@ namespace Grand.Web.Admin.Services}public virtual async Task<CustomerReminder.ReminderLevel> InsertReminderLevel(CustomerReminder customerReminder, CustomerReminderModel.ReminderLevelModel model){- var level = new CustomerReminder.ReminderLevel()- {+ var level = new CustomerReminder.ReminderLevel() {Name = model.Name,Level = model.Level,BccEmailAddresses = model.BccEmailAddresses,@@ -436,7 +443,9 @@ namespace Grand.Web.Admin.ServicescustomerReminder.Levels.Add(level);await _customerReminderService.UpdateCustomerReminder(customerReminder);- await _customerActivityService.InsertActivity("AddNewCustomerReminderLevel", customerReminder.Id, _translationService.GetResource("ActivityLog.AddNewCustomerReminderLevel"), customerReminder.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerReminderLevel", customerReminder.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCustomerReminderLevel"), customerReminder.Name);return level;}public virtual async Task<CustomerReminder.ReminderLevel> UpdateReminderLevel(CustomerReminder customerReminder, CustomerReminder.ReminderLevel customerReminderLevel, CustomerReminderModel.ReminderLevelModel model)@@ -451,7 +460,9 @@ namespace Grand.Web.Admin.ServicescustomerReminderLevel.Hour = model.Hour;customerReminderLevel.Minutes = model.Minutes;await _customerReminderService.UpdateCustomerReminder(customerReminder);- await _customerActivityService.InsertActivity("EditCustomerReminderCondition", customerReminder.Id, _translationService.GetResource("ActivityLog.EditCustomerReminderLevel"), customerReminder.Name);+ await _customerActivityService.InsertActivity("EditCustomerReminderCondition", customerReminder.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCustomerReminderLevel"), customerReminder.Name);return customerReminderLevel;}public virtual async Task DeleteLevel(string Id, string customerReminderId)@@ -475,15 +486,13 @@ namespace Grand.Web.Admin.Services}public virtual async Task<CustomerReminderModel.ConditionModel.AddProductToConditionModel> PrepareProductToConditionModel(string customerReminderId, string conditionId){- var categoryService = _serviceProvider.GetRequiredService<ICategoryService>();- var collectionService = _serviceProvider.GetRequiredService<ICollectionService>();var storeService = _serviceProvider.GetRequiredService<IStoreService>();var vendorService = _serviceProvider.GetRequiredService<IVendorService>();var model = new CustomerReminderModel.ConditionModel.AddProductToConditionModel();model.ConditionId = conditionId;model.CustomerReminderId = customerReminderId;-+//storesmodel.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });foreach (var s in await storeService.GetAllStores())diff --git a/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.csindex 36e8c5363..ea1c0b595 100644--- a/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.cs@@ -7,11 +7,13 @@ using Grand.Business.Customers.Interfaces;using Grand.Business.Marketing.Interfaces.Customers;using Grand.Domain.Catalog;using Grand.Domain.Customers;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Admin.Models.Customers;using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System.Collections.Generic;using System.Linq;@@ -28,6 +30,8 @@ namespace Grand.Web.Admin.Servicesprivate readonly IVendorService _vendorService;private readonly ICustomerTagService _customerTagService;private readonly IDateTimeService _dateTimeService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;public CustomerTagViewModelService(ITranslationService translationService,@@ -36,7 +40,9 @@ namespace Grand.Web.Admin.ServicesIStoreService storeService,IVendorService vendorService,ICustomerTagService customerTagService,- IDateTimeService dateTimeService)+ IDateTimeService dateTimeService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor){_translationService = translationService;_customerActivityService = customerActivityService;@@ -45,6 +51,8 @@ namespace Grand.Web.Admin.Services_vendorService = vendorService;_customerTagService = customerTagService;_dateTimeService = dateTimeService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;}public virtual CustomerModel PrepareCustomerModelForList(Customer customer)@@ -67,7 +75,9 @@ namespace Grand.Web.Admin.Servicesawait _customerTagService.InsertCustomerTag(customertag);//activity log- await _customerActivityService.InsertActivity("AddNewCustomerTag", customertag.Id, _translationService.GetResource("ActivityLog.AddNewCustomerTag"), customertag.Name);+ await _customerActivityService.InsertActivity("AddNewCustomerTag", customertag.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewCustomerTag"), customertag.Name);return customertag;}public virtual async Task<CustomerTag> UpdateCustomerTagModel(CustomerTag customerTag, CustomerTagModel model)@@ -78,13 +88,17 @@ namespace Grand.Web.Admin.Servicesawait _customerTagService.UpdateCustomerTag(customerTag);//activity log- await _customerActivityService.InsertActivity("EditCustomerTage", customerTag.Id, _translationService.GetResource("ActivityLog.EditCustomerTag"), customerTag.Name);+ await _customerActivityService.InsertActivity("EditCustomerTage", customerTag.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditCustomerTag"), customerTag.Name);return customerTag;}public virtual async Task DeleteCustomerTag(CustomerTag customerTag){//activity log- await _customerActivityService.InsertActivity("DeleteCustomerTag", customerTag.Id, _translationService.GetResource("ActivityLog.DeleteCustomerTag"), customerTag.Name);+ await _customerActivityService.InsertActivity("DeleteCustomerTag", customerTag.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteCustomerTag"), customerTag.Name);await _customerTagService.DeleteCustomerTag(customerTag);}public virtual async Task<CustomerTagProductModel.AddProductModel> PrepareProductModel(string customerTagId)diff --git a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.csindex 12e66080c..78c37f393 100644--- a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs@@ -799,7 +799,7 @@ namespace Grand.Web.Admin.Servicesawait SaveCustomerTags(customer, ParseCustomerTags(model.CustomerTags));//activity log- await _customerActivityService.InsertActivity("AddNewCustomer", customer.Id, _translationService.GetResource("ActivityLog.AddNewCustomer"), customer.Id);+ await _customerActivityService.InsertActivity("AddNewCustomer", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewCustomer"), customer.Id);return customer;}@@ -1020,7 +1020,7 @@ namespace Grand.Web.Admin.Servicesawait SaveCustomerTags(customer, ParseCustomerTags(model.CustomerTags));//activity log- await _customerActivityService.InsertActivity("EditCustomer", customer.Id, _translationService.GetResource("ActivityLog.EditCustomer"), customer.Id);+ await _customerActivityService.InsertActivity("EditCustomer", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.EditCustomer"), customer.Id);return customer;}@@ -1037,7 +1037,7 @@ namespace Grand.Web.Admin.Services}//activity log- await _customerActivityService.InsertActivity("DeleteCustomer", customer.Id, _translationService.GetResource("ActivityLog.DeleteCustomer"), customer.Id);+ await _customerActivityService.InsertActivity("DeleteCustomer", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.DeleteCustomer"), customer.Id);}public virtual async Task DeleteSelected(IList<string> selectedIds)@@ -1052,7 +1052,7 @@ namespace Grand.Web.Admin.Servicesawait _customerService.DeleteCustomer(customer);}//activity log- await _customerActivityService.InsertActivity("DeleteCustomer", customer.Id, _translationService.GetResource("ActivityLog.DeleteCustomer"), customer.Id);+ await _customerActivityService.InsertActivity("DeleteCustomer", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.DeleteCustomer"), customer.Id);}}@@ -1082,7 +1082,7 @@ namespace Grand.Web.Admin.Servicesnull : (DateTime?)_dateTimeService.ConvertToUtcTime(model.DontSendBeforeDate.Value)};await queuedEmailService.InsertQueuedEmail(email);- await _customerActivityService.InsertActivity("CustomerAdmin.SendEmail", "", _translationService.GetResource("ActivityLog.SendEmailfromAdminPanel"), customer, model.Subject);+ await _customerActivityService.InsertActivity("CustomerAdmin.SendEmail", "", customer, "", _translationService.GetResource("ActivityLog.SendEmailfromAdminPanel"), model.Subject);}public virtual async Task<IEnumerable<CustomerModel.LoyaltyPointsHistoryModel>> PrepareLoyaltyPointsHistoryModel(string customerId)@@ -1105,7 +1105,7 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task<LoyaltyPointsHistory> InsertLoyaltyPointsHistory(Customer customer, string storeId, int addLoyaltyPointsValue, string addLoyaltyPointsMessage){//activity log- await _customerActivityService.InsertActivity("AddLoyaltyPoints", customer.Id, _translationService.GetResource("ActivityLog.AddNewLoyaltyPoints"), customer.Email, addLoyaltyPointsValue);+ await _customerActivityService.InsertActivity("AddLoyaltyPoints", customer.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.AddNewLoyaltyPoints"), customer.Email, addLoyaltyPointsValue);return await _loyaltyPointsService.AddLoyaltyPointsHistory(customer.Id, addLoyaltyPointsValue, storeId, addLoyaltyPointsMessage);}@@ -1281,7 +1281,7 @@ namespace Grand.Web.Admin.Servicesif (cart != null){//activity log- await _customerActivityService.InsertActivity("CustomerAdmin.UpdateCartCustomer", _workContext.CurrentCustomer.Id,+ await _customerActivityService.InsertActivity("CustomerAdmin.UpdateCartCustomer", customer.Id,_workContext.CurrentCustomer,"",_translationService.GetResource("ActivityLog.UpdateCartCustomer"), customer.Email, customer.Id, unitprice);return await _serviceProvider.GetRequiredService<IShoppingCartService>()diff --git a/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.cs b/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.csindex f48103a52..9760b8ae0 100644--- a/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/DiscountViewModelService.cs@@ -1,6 +1,7 @@-using Grand.Business.Catalog.Interfaces.Categories;-using Grand.Business.Catalog.Interfaces.Discounts;+using Grand.Business.Catalog.Interfaces.Brands;+using Grand.Business.Catalog.Interfaces.Categories;using Grand.Business.Catalog.Interfaces.Collections;+using Grand.Business.Catalog.Interfaces.Discounts;using Grand.Business.Catalog.Interfaces.Prices;using Grand.Business.Catalog.Interfaces.Products;using Grand.Business.Checkout.Interfaces.Orders;@@ -10,22 +11,21 @@ using Grand.Business.Common.Interfaces.Localization;using Grand.Business.Common.Interfaces.Logging;using Grand.Business.Common.Interfaces.Stores;using Grand.Business.Customers.Interfaces;-using Grand.Infrastructure;using Grand.Domain.Catalog;-using Grand.Domain.Directory;using Grand.Domain.Discounts;using Grand.Domain.Vendors;-using Grand.Web.Common.Extensions;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Admin.Models.Discounts;+using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;-using Grand.Business.Catalog.Interfaces.Brands;namespace Grand.Web.Admin.Services{@@ -47,6 +47,7 @@ namespace Grand.Web.Admin.Servicesprivate readonly IOrderService _orderService;private readonly IPriceFormatter _priceFormatter;private readonly IDateTimeService _dateTimeService;+ private readonly IHttpContextAccessor _httpContextAccessor;#endregion@@ -65,7 +66,8 @@ namespace Grand.Web.Admin.ServicesIVendorService vendorService,IOrderService orderService,IPriceFormatter priceFormatter,- IDateTimeService dateTimeService)+ IDateTimeService dateTimeService,+ IHttpContextAccessor httpContextAccessor){_discountService = discountService;_translationService = translationService;@@ -81,14 +83,14 @@ namespace Grand.Web.Admin.Services_orderService = orderService;_priceFormatter = priceFormatter;_dateTimeService = dateTimeService;+ _httpContextAccessor = httpContextAccessor;}#endregionpublic virtual DiscountListModel PrepareDiscountListModel(){- var model = new DiscountListModel- {+ var model = new DiscountListModel {AvailableDiscountTypes = DiscountType.AssignedToOrderTotal.ToSelectList(_translationService, _workContext, false).ToList()};model.AvailableDiscountTypes.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });@@ -146,8 +148,7 @@ namespace Grand.Web.Admin.Services{if (discountPlugin != null){- model.DiscountRequirementMetaInfos.Add(new DiscountModel.DiscountRequirementMetaInfo- {+ model.DiscountRequirementMetaInfos.Add(new DiscountModel.DiscountRequirementMetaInfo {DiscountRequirementId = dr.Id,RuleName = discountRequirement.FriendlyName,ConfigurationUrl = GetRequirementUrlInternal(discountRequirement, discount, dr.Id)@@ -165,7 +166,9 @@ namespace Grand.Web.Admin.Servicesawait _discountService.InsertDiscount(discount);//activity log- await _customerActivityService.InsertActivity("AddNewDiscount", discount.Id, _translationService.GetResource("ActivityLog.AddNewDiscount"), discount.Name);+ await _customerActivityService.InsertActivity("AddNewDiscount", discount.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewDiscount"), discount.Name);return discount;}@@ -216,7 +219,9 @@ namespace Grand.Web.Admin.Services}//activity log- await _customerActivityService.InsertActivity("EditDiscount", discount.Id, _translationService.GetResource("ActivityLog.EditDiscount"), discount.Name);+ await _customerActivityService.InsertActivity("EditDiscount", discount.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditDiscount"), discount.Name);return discount;}@@ -224,12 +229,13 @@ namespace Grand.Web.Admin.Services{await _discountService.DeleteDiscount(discount);//activity log- await _customerActivityService.InsertActivity("DeleteDiscount", discount.Id, _translationService.GetResource("ActivityLog.DeleteDiscount"), discount.Name);+ await _customerActivityService.InsertActivity("DeleteDiscount", discount.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteDiscount"), discount.Name);}public virtual async Task InsertCouponCode(string discountId, string couponCode){- var coupon = new DiscountCoupon- {+ var coupon = new DiscountCoupon {CouponCode = couponCode.ToUpper(),DiscountId = discountId};@@ -256,7 +262,7 @@ namespace Grand.Web.Admin.Services}public virtual async Task<DiscountModel.AddProductToDiscountModel> PrepareProductToDiscountModel(){- var model = new DiscountModel.AddProductToDiscountModel();+ var model = new DiscountModel.AddProductToDiscountModel();//storesmodel.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = " " });foreach (var s in await _storeService.GetAllStores())@@ -398,8 +404,7 @@ namespace Grand.Web.Admin.Servicesforeach (var x in duh){var order = await _orderService.GetOrderById(x.OrderId);- var duhModel = new DiscountModel.DiscountUsageHistoryModel- {+ var duhModel = new DiscountModel.DiscountUsageHistoryModel {Id = x.Id,DiscountId = x.DiscountId,OrderId = x.OrderId,diff --git a/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.cs b/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.csindex 2c0d71873..5e87e63e5 100644--- a/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/DocumentViewModelService.cs@@ -10,9 +10,11 @@ using Grand.Business.Marketing.Interfaces.Documents;using Grand.Business.Storage.Interfaces;using Grand.Domain.Common;using Grand.Domain.Documents;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Documents;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Collections.Generic;@@ -37,6 +39,8 @@ namespace Grand.Web.Admin.Servicesprivate readonly ISalesEmployeeService _salesEmployeeService;private readonly ICustomerActivityService _customerActivityService;private readonly IDownloadService _downloadService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;public DocumentViewModelService(IDocumentService documentService,@@ -52,8 +56,9 @@ namespace Grand.Web.Admin.ServicesIVendorService vendorService,ISalesEmployeeService salesEmployeeService,ICustomerActivityService customerActivityService,- IDownloadService downloadService- )+ IDownloadService downloadService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor){_documentService = documentService;_documentTypeService = documentTypeService;@@ -69,6 +74,8 @@ namespace Grand.Web.Admin.Services_salesEmployeeService = salesEmployeeService;_customerActivityService = customerActivityService;_downloadService = downloadService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;}public virtual async Task<(IEnumerable<DocumentModel> documetListModel, int totalCount)> PrepareDocumentListModel(DocumentListModel model, int pageIndex, int pageSize)@@ -225,7 +232,9 @@ namespace Grand.Web.Admin.Servicesawait _documentService.Insert(document);//activity log- await _customerActivityService.InsertActivity("AddNewDocument", document.Id, _translationService.GetResource("ActivityLog.AddNewDocument"), document.Name);+ await _customerActivityService.InsertActivity("AddNewDocument", document.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewDocument"), document.Name);return document;}@@ -250,7 +259,9 @@ namespace Grand.Web.Admin.Services}//activity log- await _customerActivityService.InsertActivity("EditDocument", document.Id, _translationService.GetResource("ActivityLog.EditDocument"), document.Name);+ await _customerActivityService.InsertActivity("EditDocument", document.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditDocument"), document.Name);return document;}@@ -268,7 +279,9 @@ namespace Grand.Web.Admin.Services}//activity log- await _customerActivityService.InsertActivity("DeleteDocument", document.Id, _translationService.GetResource("ActivityLog.DeleteDocument"), document.Name);+ await _customerActivityService.InsertActivity("DeleteDocument", document.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteDocument"), document.Name);}}diff --git a/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.cs b/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.csindex 4c6393f4b..13ee428b5 100644--- a/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/GiftVoucherViewModelService.cs@@ -16,12 +16,14 @@ using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;+using Microsoft.AspNetCore.Http;namespace Grand.Web.Admin.Services{public partial class GiftVoucherViewModelService : IGiftVoucherViewModelService{#region Fields+private readonly IGiftVoucherService _giftVoucherService;private readonly IOrderService _orderService;private readonly IPriceFormatter _priceFormatter;@@ -33,6 +35,8 @@ namespace Grand.Web.Admin.Servicesprivate readonly ILanguageService _languageService;private readonly ICustomerActivityService _customerActivityService;private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;+#endregion#region Constructors@@ -44,7 +48,8 @@ namespace Grand.Web.Admin.ServicesICurrencyService currencyService,LanguageSettings languageSettings,ITranslationService translationService, ILanguageService languageService,- ICustomerActivityService customerActivityService, IWorkContext workContext)+ ICustomerActivityService customerActivityService, IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor){_giftVoucherService = giftVoucherService;_orderService = orderService;@@ -57,6 +62,7 @@ namespace Grand.Web.Admin.Services_languageService = languageService;_customerActivityService = customerActivityService;_workContext = workContext;+ _httpContextAccessor = httpContextAccessor;}#endregion@@ -132,7 +138,9 @@ namespace Grand.Web.Admin.Servicesawait _giftVoucherService.InsertGiftVoucher(giftVoucher);//activity log- await _customerActivityService.InsertActivity("AddNewGiftVoucher", giftVoucher.Id, _translationService.GetResource("ActivityLog.AddNewGiftVoucher"), giftVoucher.Code);+ await _customerActivityService.InsertActivity("AddNewGiftVoucher", giftVoucher.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewGiftVoucher"), giftVoucher.Code);return giftVoucher;}public virtual async Task<Order> FillGiftVoucherModel(GiftVoucher giftVoucher, GiftVoucherModel model)@@ -184,7 +192,9 @@ namespace Grand.Web.Admin.ServicesgiftVoucher = model.ToEntity(giftVoucher, _dateTimeService);await _giftVoucherService.UpdateGiftVoucher(giftVoucher);//activity log- await _customerActivityService.InsertActivity("EditGiftVoucher", giftVoucher.Id, _translationService.GetResource("ActivityLog.EditGiftVoucher"), giftVoucher.Code);+ await _customerActivityService.InsertActivity("EditGiftVoucher", giftVoucher.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditGiftVoucher"), giftVoucher.Code);return giftVoucher;}@@ -192,7 +202,9 @@ namespace Grand.Web.Admin.Services{await _giftVoucherService.DeleteGiftVoucher(giftVoucher);//activity log- await _customerActivityService.InsertActivity("DeleteGiftVoucher", giftVoucher.Id, _translationService.GetResource("ActivityLog.DeleteGiftVoucher"), giftVoucher.Code);+ await _customerActivityService.InsertActivity("DeleteGiftVoucher", giftVoucher.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteGiftVoucher"), giftVoucher.Code);}public virtual async Task<GiftVoucherModel> PrepareGiftVoucherModel(GiftVoucher giftVoucher){diff --git a/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.cs b/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.csindex 70c09db82..36dfabedc 100644--- a/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/KnowledgebaseViewModelService.cs@@ -8,9 +8,11 @@ using Grand.Business.Marketing.Extensions;using Grand.Business.Marketing.Interfaces.Knowledgebase;using Grand.Domain.Knowledgebase;using Grand.Domain.Seo;+using Grand.Infrastructure;using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Knowledgebase;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Collections.Generic;@@ -28,12 +30,21 @@ namespace Grand.Web.Admin.Servicesprivate readonly IDateTimeService _dateTimeService;private readonly ISlugService _slugService;private readonly ILanguageService _languageService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;+private readonly SeoSettings _seoSettings;public KnowledgebaseViewModelService(ITranslationService translationService,- IKnowledgebaseService knowledgebaseService, ICustomerActivityService customerActivityService,- ICustomerService customerService, IDateTimeService dateTimeService, ISlugService slugService,- ILanguageService languageService, SeoSettings seoSettings)+ IKnowledgebaseService knowledgebaseService,+ ICustomerActivityService customerActivityService,+ ICustomerService customerService,+ IDateTimeService dateTimeService,+ ISlugService slugService,+ ILanguageService languageService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor,+ SeoSettings seoSettings){_translationService = translationService;_knowledgebaseService = knowledgebaseService;@@ -42,6 +53,8 @@ namespace Grand.Web.Admin.Services_dateTimeService = dateTimeService;_slugService = slugService;_languageService = languageService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;_seoSettings = seoSettings;}@@ -189,6 +202,7 @@ namespace Grand.Web.Admin.Servicesawait _knowledgebaseService.InsertKnowledgebaseCategory(knowledgebaseCategory);await _slugService.SaveSlug(knowledgebaseCategory, model.SeName, "");await _customerActivityService.InsertActivity("CreateKnowledgebaseCategory", knowledgebaseCategory.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),_translationService.GetResource("ActivityLog.CreateKnowledgebaseCategory"), knowledgebaseCategory.Name);return knowledgebaseCategory;@@ -203,6 +217,7 @@ namespace Grand.Web.Admin.Servicesawait _knowledgebaseService.UpdateKnowledgebaseCategory(knowledgebaseCategory);await _slugService.SaveSlug(knowledgebaseCategory, model.SeName, "");await _customerActivityService.InsertActivity("UpdateKnowledgebaseCategory", knowledgebaseCategory.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),_translationService.GetResource("ActivityLog.UpdateKnowledgebaseCategory"), knowledgebaseCategory.Name);return knowledgebaseCategory;@@ -211,6 +226,7 @@ namespace Grand.Web.Admin.Services{await _knowledgebaseService.DeleteKnowledgebaseCategory(knowledgebaseCategory);await _customerActivityService.InsertActivity("DeleteKnowledgebaseCategory", knowledgebaseCategory.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),_translationService.GetResource("ActivityLog.DeleteKnowledgebaseCategory"), knowledgebaseCategory.Name);}public virtual async Task<KnowledgebaseArticleModel> PrepareKnowledgebaseArticleModel()@@ -235,6 +251,7 @@ namespace Grand.Web.Admin.Servicesawait _knowledgebaseService.InsertKnowledgebaseArticle(knowledgebaseArticle);await _slugService.SaveSlug(knowledgebaseArticle, model.SeName, "");await _customerActivityService.InsertActivity("CreateKnowledgebaseArticle", knowledgebaseArticle.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),_translationService.GetResource("ActivityLog.CreateKnowledgebaseArticle"), knowledgebaseArticle.Name);return knowledgebaseArticle;@@ -250,6 +267,7 @@ namespace Grand.Web.Admin.Servicesawait _knowledgebaseService.UpdateKnowledgebaseArticle(knowledgebaseArticle);await _slugService.SaveSlug(knowledgebaseArticle, model.SeName, "");await _customerActivityService.InsertActivity("UpdateKnowledgebaseArticle", knowledgebaseArticle.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),_translationService.GetResource("ActivityLog.UpdateKnowledgebaseArticle"), knowledgebaseArticle.Name);return knowledgebaseArticle;@@ -258,6 +276,7 @@ namespace Grand.Web.Admin.Services{await _knowledgebaseService.DeleteKnowledgebaseArticle(knowledgebaseArticle);await _customerActivityService.InsertActivity("DeleteKnowledgebaseArticle", knowledgebaseArticle.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),_translationService.GetResource("ActivityLog.DeleteKnowledgebaseArticle"), knowledgebaseArticle.Name);}public virtual async Task InsertKnowledgebaseRelatedArticle(KnowledgebaseArticleModel.AddRelatedArticleModel model)diff --git a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.csindex f6d323203..7375c4455 100644--- a/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/MerchandiseReturnViewModelService.cs@@ -24,6 +24,7 @@ using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;+using Microsoft.AspNetCore.Http;namespace Grand.Web.Admin.Services{@@ -42,13 +43,14 @@ namespace Grand.Web.Admin.Servicesprivate readonly ICustomerActivityService _customerActivityService;private readonly IMerchandiseReturnService _merchandiseReturnService;private readonly IPriceFormatter _priceFormatter;- private readonly ICurrencyService _currencyService;private readonly AddressSettings _addressSettings;private readonly OrderSettings _orderSettings;private readonly ICountryService _countryService;private readonly IAddressAttributeService _addressAttributeService;private readonly IAddressAttributeParser _addressAttributeParser;private readonly IDownloadService _downloadService;+ private readonly IHttpContextAccessor _httpContextAccessor;+#endregion Fields#region Constructors@@ -62,13 +64,13 @@ namespace Grand.Web.Admin.ServicesICustomerActivityService customerActivityService,IMerchandiseReturnService merchandiseReturnService,IPriceFormatter priceFormatter,- ICurrencyService currencyService,AddressSettings addressSettings,ICountryService countryService,IAddressAttributeService addressAttributeService,IAddressAttributeParser addressAttributeParser,IDownloadService downloadService,- OrderSettings orderSettings)+ OrderSettings orderSettings,+ IHttpContextAccessor httpContextAccessor){_orderService = orderService;_workContext = workContext;@@ -81,13 +83,13 @@ namespace Grand.Web.Admin.Services_customerActivityService = customerActivityService;_merchandiseReturnService = merchandiseReturnService;_priceFormatter = priceFormatter;- _currencyService = currencyService;_addressSettings = addressSettings;_countryService = countryService;_addressAttributeService = addressAttributeService;_addressAttributeParser = addressAttributeParser;_downloadService = downloadService;_orderSettings = orderSettings;+ _httpContextAccessor = httpContextAccessor;}#endregion@@ -290,7 +292,9 @@ namespace Grand.Web.Admin.ServicesmerchandiseReturn.NotifyCustomer = model.NotifyCustomer;await _merchandiseReturnService.UpdateMerchandiseReturn(merchandiseReturn);//activity log- await _customerActivityService.InsertActivity("EditMerchandiseReturn", merchandiseReturn.Id, _translationService.GetResource("ActivityLog.EditMerchandiseReturn"), merchandiseReturn.Id);+ await _customerActivityService.InsertActivity("EditMerchandiseReturn", merchandiseReturn.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditMerchandiseReturn"), merchandiseReturn.Id);if (model.NotifyCustomer)await NotifyCustomer(merchandiseReturn);@@ -300,7 +304,9 @@ namespace Grand.Web.Admin.Services{await _merchandiseReturnService.DeleteMerchandiseReturn(merchandiseReturn);//activity log- await _customerActivityService.InsertActivity("DeleteMerchandiseReturn", merchandiseReturn.Id, _translationService.GetResource("ActivityLog.DeleteMerchandiseReturn"), merchandiseReturn.Id);+ await _customerActivityService.InsertActivity("DeleteMerchandiseReturn", merchandiseReturn.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteMerchandiseReturn"), merchandiseReturn.Id);}public virtual async Task<IList<MerchandiseReturnModel.MerchandiseReturnNote>> PrepareMerchandiseReturnNotes(MerchandiseReturn merchandiseReturn)diff --git a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.csindex 8bde87f05..a5ed72a90 100644--- a/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/OrderViewModelService.cs@@ -1005,7 +1005,10 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task LogEditOrder(string orderId){- await _customerActivityService.InsertActivity("EditOrder", orderId, _translationService.GetResource("ActivityLog.EditOrder"), orderId);+ var httpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();+ await _customerActivityService.InsertActivity("EditOrder", orderId,+ _workContext.CurrentCustomer, httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditOrder"), orderId);}public virtual async Task<Address> UpdateOrderAddress(Order order, Address address, OrderAddressModel model, List<CustomAttribute> customAttributes){diff --git a/src/Web/Grand.Web.Admin/Services/PageViewModelService.cs b/src/Web/Grand.Web.Admin/Services/PageViewModelService.csindex 22ffeeaa1..7be14111f 100644--- a/src/Web/Grand.Web.Admin/Services/PageViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/PageViewModelService.cs@@ -13,6 +13,8 @@ using Grand.Web.Admin.Models.Pages;using Microsoft.AspNetCore.Mvc.Rendering;using System;using System.Threading.Tasks;+using Grand.Infrastructure;+using Microsoft.AspNetCore.Http;namespace Grand.Web.Admin.Services{@@ -26,10 +28,22 @@ namespace Grand.Web.Admin.Servicesprivate readonly IStoreService _storeService;private readonly ILanguageService _languageService;private readonly IDateTimeService _dateTimeService;+ private readonly IWorkContext _workContext;+ private readonly IHttpContextAccessor _httpContextAccessor;private readonly SeoSettings _seoSettings;- public PageViewModelService(IPageLayoutService pageLayoutService, IPageService pageService, ISlugService slugService, ITranslationService translationService,- ICustomerActivityService customerActivityService, IStoreService storeService, ILanguageService languageService, IDateTimeService dateTimeService, SeoSettings seoSettings)+ public PageViewModelService(+ IPageLayoutService pageLayoutService,+ IPageService pageService,+ ISlugService slugService,+ ITranslationService translationService,+ ICustomerActivityService customerActivityService,+ IStoreService storeService,+ ILanguageService languageService,+ IDateTimeService dateTimeService,+ IWorkContext workContext,+ IHttpContextAccessor httpContextAccessor,+ SeoSettings seoSettings){_pageLayoutService = pageLayoutService;_pageService = pageService;@@ -39,6 +53,8 @@ namespace Grand.Web.Admin.Services_storeService = storeService;_languageService = languageService;_dateTimeService = dateTimeService;+ _workContext = workContext;+ _httpContextAccessor = httpContextAccessor;_seoSettings = seoSettings;}@@ -84,7 +100,9 @@ namespace Grand.Web.Admin.Servicesawait _slugService.SaveSlug(page, model.SeName, "");//activity log- await _customerActivityService.InsertActivity("AddNewPage", page.Id, _translationService.GetResource("ActivityLog.AddNewPage"), page.Title ?? page.SystemName);+ await _customerActivityService.InsertActivity("AddNewPage", page.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewPage"), page.Title ?? page.SystemName);return page;}public virtual async Task<Page> UpdatePageModel(Page page, PageModel model)@@ -102,7 +120,9 @@ namespace Grand.Web.Admin.Services//search engine nameawait _slugService.SaveSlug(page, model.SeName, "");//activity log- await _customerActivityService.InsertActivity("EditPage", page.Id, _translationService.GetResource("ActivityLog.EditPage"), page.Title ?? page.SystemName);+ await _customerActivityService.InsertActivity("EditPage", page.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditPage"), page.Title ?? page.SystemName);return page;}@@ -110,7 +130,9 @@ namespace Grand.Web.Admin.Services{await _pageService.DeletePage(page);//activity log- await _customerActivityService.InsertActivity("DeletePage", page.Id, _translationService.GetResource("ActivityLog.DeletePage"), page.Title ?? page.SystemName);+ await _customerActivityService.InsertActivity("DeletePage", page.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeletePage"), page.Title ?? page.SystemName);}}}diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.csindex 7d8d155b3..6ea7eb7cd 100644--- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs@@ -29,6 +29,7 @@ using Grand.Web.Admin.Extensions;using Grand.Web.Admin.Interfaces;using Grand.Web.Admin.Models.Catalog;using Grand.Web.Common.Extensions;+using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc.Rendering;using Microsoft.Extensions.DependencyInjection;using System;@@ -73,6 +74,7 @@ namespace Grand.Web.Admin.Servicesprivate readonly IStockQuantityService _stockQuantityService;private readonly ILanguageService _languageService;private readonly IProductAttributeFormatter _productAttributeFormatter;+ private readonly IHttpContextAccessor _httpContextAccessor;private readonly IServiceProvider _serviceProvider;private readonly CurrencySettings _currencySettings;private readonly MeasureSettings _measureSettings;@@ -111,6 +113,7 @@ namespace Grand.Web.Admin.ServicesILanguageService languageService,IProductAttributeFormatter productAttributeFormatter,IStockQuantityService stockQuantityService,+ IHttpContextAccessor httpContextAccessor,IServiceProvider serviceProvider,CurrencySettings currencySettings,MeasureSettings measureSettings,@@ -148,6 +151,7 @@ namespace Grand.Web.Admin.Services_stockQuantityService = stockQuantityService;_languageService = languageService;_productAttributeFormatter = productAttributeFormatter;+ _httpContextAccessor = httpContextAccessor;_serviceProvider = serviceProvider;_currencySettings = currencySettings;_measureSettings = measureSettings;@@ -941,7 +945,9 @@ namespace Grand.Web.Admin.Servicesawait _productService.UpdateProduct(product);//activity log- await _customerActivityService.InsertActivity("AddNewProduct", product.Id, _translationService.GetResource("ActivityLog.AddNewProduct"), product.Name);+ await _customerActivityService.InsertActivity("AddNewProduct", product.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.AddNewProduct"), product.Name);return product;}@@ -1038,7 +1044,9 @@ namespace Grand.Web.Admin.Servicesawait _downloadService.DeleteDownload(prevSampleDownload);}//activity log- await _customerActivityService.InsertActivity("EditProduct", product.Id, _translationService.GetResource("ActivityLog.EditProduct"), product.Name);+ await _customerActivityService.InsertActivity("EditProduct", product.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.EditProduct"), product.Name);return product;}public virtual async Task DeleteProduct(Product product)@@ -1060,7 +1068,9 @@ namespace Grand.Web.Admin.Servicesawait _downloadService.DeleteDownload(sampledownload);}//activity log- await _customerActivityService.InsertActivity("DeleteProduct", product.Id, _translationService.GetResource("ActivityLog.DeleteProduct"), product.Name);+ await _customerActivityService.InsertActivity("DeleteProduct", product.Id,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.DeleteProduct"), product.Name);}public virtual async Task DeleteSelected(IList<string> selectedIds){diff --git a/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.csindex bb8536e71..f079d512b 100644--- a/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs+++ b/src/Web/Grand.Web.Admin/Services/ShipmentViewModelService.cs@@ -42,6 +42,7 @@ namespace Grand.Web.Admin.Servicesprivate readonly IDownloadService _downloadService;private readonly IShippingService _shippingService;private readonly IStockQuantityService _stockQuantityService;+ private readonly IHttpContextAccessor _httpContextAccessor;private readonly MeasureSettings _measureSettings;private readonly ShippingSettings _shippingSettings;private readonly ShippingProviderSettings _shippingProviderSettings;@@ -62,6 +63,7 @@ namespace Grand.Web.Admin.ServicesIDownloadService downloadService,IShippingService shippingService,IStockQuantityService stockQuantityService,+ IHttpContextAccessor httpContextAccessor,MeasureSettings measureSettings,ShippingSettings shippingSettings,ShippingProviderSettings shippingProviderSettings)@@ -81,6 +83,7 @@ namespace Grand.Web.Admin.Services_downloadService = downloadService;_shippingService = shippingService;_stockQuantityService = stockQuantityService;+ _httpContextAccessor = httpContextAccessor;_measureSettings = measureSettings;_shippingSettings = shippingSettings;_shippingProviderSettings = shippingProviderSettings;@@ -292,7 +295,8 @@ namespace Grand.Web.Admin.Servicespublic virtual async Task LogShipment(string shipmentId, string message){- await _customerActivityService.InsertActivity("EditShipment", shipmentId, message);+ await _customerActivityService.InsertActivity("EditShipment", shipmentId,+ _workContext.CurrentCustomer, _httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(), message);}public virtual async Task<(IEnumerable<Shipment> shipments, int totalCount)> PrepareShipments(ShipmentListModel model, int pageIndex, int pageSize){diff --git a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.csindex f416f3890..500f62cfa 100644--- a/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs+++ b/src/Web/Grand.Web.Common/Filters/CustomerActivityAttribute.cs@@ -133,7 +133,8 @@ namespace Grand.Web.Common.Filtersif (!_workContext.CurrentCustomer.IsSearchEngineAccount()){//activity- await _customerActivityService.InsertActivity("PublicStore.Url", pageUrl, pageUrl, _workContext.CurrentCustomer);+ await _customerActivityService.InsertActivity("PublicStore.Url", pageUrl, _workContext.CurrentCustomer,+ context.HttpContext?.Connection?.RemoteIpAddress?.ToString(), pageUrl);//actionawait _customerActionEventService.Url(_workContext.CurrentCustomer, context.HttpContext?.Request?.Path.ToString(), context.HttpContext?.Request?.Headers["Referer"]);}diff --git a/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.csindex be47f8ec4..414d9db48 100644--- a/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs+++ b/src/Web/Grand.Web/Commands/Handler/Blogs/InsertBlogCommentCommandHandler.cs@@ -68,7 +68,7 @@ namespace Grand.Web.Commands.Handler.Blogsawait _messageProviderService.SendBlogCommentMessage(request.BlogPost, comment, _languageSettings.DefaultAdminLanguageId);//activity log- await _customerActivityService.InsertActivity("PublicStore.AddBlogComment", comment.Id, _translationService.GetResource("ActivityLog.PublicStore.AddBlogComment"));+ await _customerActivityService.InsertActivity("PublicStore.AddBlogComment", comment.Id, _workContext.CurrentCustomer, "", _translationService.GetResource("ActivityLog.PublicStore.AddBlogComment"));return comment;}diff --git a/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.csindex 473addc47..9955245bf 100644--- a/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.cs+++ b/src/Web/Grand.Web/Commands/Handler/Common/ContactUsSendCommandHandler.cs@@ -73,7 +73,9 @@ namespace Grand.Web.Commands.Handler.Commonrequest.Model = await SendContactUs(request, request.Store);//activity log- await _customerActivityService.InsertActivity("PublicStore.ContactUs", "", _translationService.GetResource("ActivityLog.PublicStore.ContactUs"));+ await _customerActivityService.InsertActivity("PublicStore.ContactUs", "",+ _workContext.CurrentCustomer, request.IpAddress,+ _translationService.GetResource("ActivityLog.PublicStore.ContactUs"));}elsediff --git a/src/Web/Grand.Web/Commands/Handler/Common/PopupInteractiveCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Common/PopupInteractiveCommandHandler.csindex 8840d0d01..962552b97 100644--- a/src/Web/Grand.Web/Commands/Handler/Common/PopupInteractiveCommandHandler.cs+++ b/src/Web/Grand.Web/Commands/Handler/Common/PopupInteractiveCommandHandler.cs@@ -134,7 +134,9 @@ namespace Grand.Web.Commands.Handler.Commonawait _mediator.Publish(new PopupInteractiveEvent(_workContext.CurrentCustomer, request.Form, enquiryForm));//activity log- await _customerActivityService.InsertActivity("PublicStore.InteractiveForm", form.Id, string.Format(_translationService.GetResource("ActivityLog.PublicStore.InteractiveForm"), form.Name));+ await _customerActivityService.InsertActivity("PublicStore.InteractiveForm", form.Id,+ _workContext.CurrentCustomer, "",+ string.Format(_translationService.GetResource("ActivityLog.PublicStore.InteractiveForm"), form.Name));}return errors;diff --git a/src/Web/Grand.Web/Commands/Handler/Customers/DeleteAccountCommandHandler.cs b/src/Web/Grand.Web/Commands/Handler/Customers/DeleteAccountCommandHandler.csindex 628769b1b..c42846ebb 100644--- a/src/Web/Grand.Web/Commands/Handler/Customers/DeleteAccountCommandHandler.cs+++ b/src/Web/Grand.Web/Commands/Handler/Customers/DeleteAccountCommandHandler.cs@@ -42,7 +42,9 @@ namespace Grand.Web.Commands.Handler.Customerspublic async Task<bool> Handle(DeleteAccountCommand request, CancellationToken cancellationToken){//activity log- await _customerActivityService.InsertActivity("PublicStore.DeleteAccount", "", _translationService.GetResource("ActivityLog.DeleteAccount"), request.Customer);+ await _customerActivityService.InsertActivity("PublicStore.DeleteAccount", request.Customer.Id,+ request.Customer, request.IpAddress,+ _translationService.GetResource("ActivityLog.DeleteAccount"), request.Customer);//send notification to customerawait _messageProviderService.SendCustomerDeleteStoreOwnerMessage(request.Customer, _languageSettings.DefaultAdminLanguageId);diff --git a/src/Web/Grand.Web/Commands/Models/Customers/DeleteAccountCommand.cs b/src/Web/Grand.Web/Commands/Models/Customers/DeleteAccountCommand.csindex 090588c06..b6e00db54 100644--- a/src/Web/Grand.Web/Commands/Models/Customers/DeleteAccountCommand.cs+++ b/src/Web/Grand.Web/Commands/Models/Customers/DeleteAccountCommand.cs@@ -8,5 +8,6 @@ namespace Grand.Web.Commands.Models.Customers{public Customer Customer { get; set; }public Store Store { get; set; }+ public string IpAddress { get; set; }}}diff --git a/src/Web/Grand.Web/Controllers/AccountController.cs b/src/Web/Grand.Web/Controllers/AccountController.csindex 2ac800f2d..b61378171 100644--- a/src/Web/Grand.Web/Controllers/AccountController.cs+++ b/src/Web/Grand.Web/Controllers/AccountController.cs@@ -1001,7 +1001,7 @@ namespace Grand.Web.Controllerscase CustomerLoginResults.Successful:{//delete account- await _mediator.Send(new DeleteAccountCommand() { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore });+ await _mediator.Send(new DeleteAccountCommand() { Customer = _workContext.CurrentCustomer, Store = _workContext.CurrentStore, IpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString(), });//standard logoutawait _authenticationService.SignOut();diff --git a/src/Web/Grand.Web/Controllers/ActionCartController.cs b/src/Web/Grand.Web/Controllers/ActionCartController.csindex 1e50b3e99..d2b4b2737 100644--- a/src/Web/Grand.Web/Controllers/ActionCartController.cs+++ b/src/Web/Grand.Web/Controllers/ActionCartController.cs@@ -221,7 +221,9 @@ namespace Grand.Web.Controllerscase ShoppingCartType.Wishlist:{//activity log- await _customerActivityService.InsertActivity("PublicStore.AddToWishlist", product.Id, _translationService.GetResource("ActivityLog.PublicStore.AddToWishlist"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddToWishlist", product.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddToWishlist"), product.Name);if (_shoppingCartSettings.DisplayWishlistAfterAddingProduct || forceredirection){@@ -249,7 +251,9 @@ namespace Grand.Web.Controllersdefault:{//activity log- await _customerActivityService.InsertActivity("PublicStore.AddToShoppingCart", product.Id, _translationService.GetResource("ActivityLog.PublicStore.AddToShoppingCart"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddToShoppingCart", product.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddToShoppingCart"), product.Name);if (_shoppingCartSettings.DisplayCartAfterAddingProduct || forceredirection){@@ -528,7 +532,9 @@ namespace Grand.Web.Controllerscase ShoppingCartType.Wishlist:{//activity log- await _customerActivityService.InsertActivity("PublicStore.AddToWishlist", product.Id, _translationService.GetResource("ActivityLog.PublicStore.AddToWishlist"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddToWishlist", product.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddToWishlist"), product.Name);if (_shoppingCartSettings.DisplayWishlistAfterAddingProduct){@@ -556,7 +562,9 @@ namespace Grand.Web.Controllersdefault:{//activity log- await _customerActivityService.InsertActivity("PublicStore.AddToShoppingCart", product.Id, _translationService.GetResource("ActivityLog.PublicStore.AddToShoppingCart"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddToShoppingCart", product.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddToShoppingCart"), product.Name);if (_shoppingCartSettings.DisplayCartAfterAddingProduct){@@ -685,7 +693,9 @@ namespace Grand.Web.Controllersawait auctionService.NewBid(customer, product, _workContext.CurrentStore, _workContext.WorkingLanguage, warehouseId, bid);//activity log- await _customerActivityService.InsertActivity("PublicStore.AddNewBid", product.Id, _translationService.GetResource("ActivityLog.PublicStore.AddToBid"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddNewBid", product.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddToBid"), product.Name);var addtoCartModel = await _mediator.Send(new GetAddToCart() {Product = product,diff --git a/src/Web/Grand.Web/Controllers/CatalogController.cs b/src/Web/Grand.Web/Controllers/CatalogController.csindex 438b9c781..27c3cc96b 100644--- a/src/Web/Grand.Web/Controllers/CatalogController.cs+++ b/src/Web/Grand.Web/Controllers/CatalogController.cs@@ -145,7 +145,9 @@ namespace Grand.Web.ControllersDisplayEditLink(Url.Action("Edit", "Category", new { id = category.Id, area = "Admin" }));//activity log- await _customerActivityService.InsertActivity("PublicStore.ViewCategory", category.Id, _translationService.GetResource("ActivityLog.PublicStore.ViewCategory"), category.Name);+ await _customerActivityService.InsertActivity("PublicStore.ViewCategory", category.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.ViewCategory"), category.Name);await _customerActionEventService.Viewed(customer, HttpContext.Request.Path.ToString(), Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers["Referer"].ToString() : "");//model@@ -198,7 +200,9 @@ namespace Grand.Web.ControllersDisplayEditLink(Url.Action("Edit", "Brand", new { id = brand.Id, area = "Admin" }));//activity log- await _customerActivityService.InsertActivity("PublicStore.ViewBrand", brand.Id, _translationService.GetResource("ActivityLog.PublicStore.ViewBrand"), brand.Name);+ await _customerActivityService.InsertActivity("PublicStore.ViewBrand", brand.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.ViewBrand"), brand.Name);await _customerActionEventService.Viewed(customer, HttpContext.Request.Path.ToString(), Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers[HeaderNames.Referer].ToString() : "");//model@@ -262,7 +266,9 @@ namespace Grand.Web.ControllersDisplayEditLink(Url.Action("Edit", "Collection", new { id = collection.Id, area = "Admin" }));//activity log- await _customerActivityService.InsertActivity("PublicStore.ViewCollection", collection.Id, _translationService.GetResource("ActivityLog.PublicStore.ViewCollection"), collection.Name);+ await _customerActivityService.InsertActivity("PublicStore.ViewCollection", collection.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.ViewCollection"), collection.Name);await _customerActionEventService.Viewed(customer, HttpContext.Request.Path.ToString(), Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers[HeaderNames.Referer].ToString() : "");//model@@ -396,7 +402,9 @@ namespace Grand.Web.Controllers{var vendorReview = await _mediator.Send(new InsertVendorReviewCommand() { Vendor = vendor, Store = _workContext.CurrentStore, Model = model });//activity log- await _customerActivityService.InsertActivity("PublicStore.AddVendorReview", vendor.Id, _translationService.GetResource("ActivityLog.PublicStore.AddVendorReview"), vendor.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddVendorReview", vendor.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddVendorReview"), vendor.Name);//raise eventif (vendorReview.IsApproved)diff --git a/src/Web/Grand.Web/Controllers/CheckoutController.cs b/src/Web/Grand.Web/Controllers/CheckoutController.csindex c4580259c..6414fbb61 100644--- a/src/Web/Grand.Web/Controllers/CheckoutController.cs+++ b/src/Web/Grand.Web/Controllers/CheckoutController.cs@@ -999,7 +999,9 @@ namespace Grand.Web.Controllersvar placeOrderResult = await _mediator.Send(new PlaceOrderCommand());if (placeOrderResult.Success){- await _customerActivityService.InsertActivity("PublicStore.PlaceOrder", "", _translationService.GetResource("ActivityLog.PublicStore.PlaceOrder"), placeOrderResult.PlacedOrder.Id);+ await _customerActivityService.InsertActivity("PublicStore.PlaceOrder", "",+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.PlaceOrder"), placeOrderResult.PlacedOrder.Id);var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(placeOrderResult.PaymentTransaction.PaymentMethodSystemName);if (paymentMethod == null)diff --git a/src/Web/Grand.Web/Controllers/CourseController.cs b/src/Web/Grand.Web/Controllers/CourseController.csindex 8156229a6..3420ab1f5 100644--- a/src/Web/Grand.Web/Controllers/CourseController.cs+++ b/src/Web/Grand.Web/Controllers/CourseController.cs@@ -114,7 +114,9 @@ namespace Grand.Web.ControllersDisplayEditLink(Url.Action("Edit", "Course", new { id = course.Id, area = "Admin" }));//activity log- await _customerActivityService.InsertActivity("PublicStore.ViewCourse", course.Id, _translationService.GetResource("ActivityLog.PublicStore.ViewCourse"), course.Name);+ await _customerActivityService.InsertActivity("PublicStore.ViewCourse", course.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.ViewCourse"), course.Name);await _customerActionEventService.Viewed(customer, HttpContext.Request.Path.ToString(), Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers["Referer"].ToString() : "");//model@@ -150,7 +152,9 @@ namespace Grand.Web.ControllersDisplayEditLink(Url.Action("EditLesson", "Course", new { id = lesson.Id, area = "Admin" }));//activity log- await _customerActivityService.InsertActivity("PublicStore.ViewLesson", lesson.Id, _translationService.GetResource("ActivityLog.PublicStore.ViewLesson"), lesson.Name);+ await _customerActivityService.InsertActivity("PublicStore.ViewLesson", lesson.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.ViewLesson"), lesson.Name);await _customerActionEventService.Viewed(customer, HttpContext.Request.Path.ToString(), Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers["Referer"].ToString() : "");//modeldiff --git a/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs b/src/Web/Grand.Web/Controllers/KnowledgebaseController.csindex e46c4fba7..ca67c7352 100644--- a/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs+++ b/src/Web/Grand.Web/Controllers/KnowledgebaseController.cs@@ -311,7 +311,9 @@ namespace Grand.Web.Controllersawait _messageProviderService.SendArticleCommentMessage(article, comment, _languageSettings.DefaultAdminLanguageId);//activity log- await _customerActivityService.InsertActivity("PublicStore.AddArticleComment", comment.Id, _translationService.GetResource("ActivityLog.PublicStore.AddArticleComment"));+ await _customerActivityService.InsertActivity("PublicStore.AddArticleComment", comment.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddArticleComment"));//The text boxes should be cleared after a comment has been posted//That' why we reload the pagediff --git a/src/Web/Grand.Web/Controllers/NewsController.cs b/src/Web/Grand.Web/Controllers/NewsController.csindex 583a27b36..efd3c8f11 100644--- a/src/Web/Grand.Web/Controllers/NewsController.cs+++ b/src/Web/Grand.Web/Controllers/NewsController.cs@@ -128,7 +128,9 @@ namespace Grand.Web.Controllersawait _mediator.Publish(new NewsCommentEvent(newsItem, model.AddNewComment));//activity log- await _customerActivityService.InsertActivity("PublicStore.AddNewsComment", newsItem.Id, _translationService.GetResource("ActivityLog.PublicStore.AddNewsComment"));+ await _customerActivityService.InsertActivity("PublicStore.AddNewsComment", newsItem.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddNewsComment"));//The text boxes should be cleared after a comment has been postedTempData["Grand.news.addcomment.result"] = _translationService.GetResource("News.Comments.SuccessfullyAdded");diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.csindex a30da100f..99a82cd17 100644--- a/src/Web/Grand.Web/Controllers/ProductController.cs+++ b/src/Web/Grand.Web/Controllers/ProductController.cs@@ -176,8 +176,9 @@ namespace Grand.Web.Controllers}//activity log- await _customerActivityService.InsertActivity("PublicStore.ViewProduct", product.Id, _translationService.GetResource("ActivityLog.PublicStore.ViewProduct"), product.Name);- await _customerActionEventService.Viewed(customer, this.HttpContext.Request.Path.ToString(), this.Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers[HeaderNames.Referer].ToString() : "");+ await _customerActivityService.InsertActivity("PublicStore.ViewProduct", product.Id, _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.ViewProduct"), product.Name);+ await _customerActionEventService.Viewed(customer, this.HttpContext.Request.Path.ToString(), Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers[HeaderNames.Referer].ToString() : "");await _productService.UpdateMostView(product);return View(productLayoutViewPath, model);@@ -422,7 +423,8 @@ namespace Grand.Web.Controllersawait _recentlyViewedProductsService.AddProductToRecentlyViewedList(customer.Id, product.Id);//activity log- await _customerActivityService.InsertActivity("PublicStore.ViewProduct", product.Id, _translationService.GetResource("ActivityLog.PublicStore.ViewProduct"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.ViewProduct", product.Id, _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.ViewProduct"), product.Name);await _customerActionEventService.Viewed(customer, HttpContext.Request.Path.ToString(), Request.Headers[HeaderNames.Referer].ToString() != null ? Request.Headers[HeaderNames.Referer].ToString() : "");await _productService.UpdateMostView(product);@@ -544,7 +546,9 @@ namespace Grand.Web.Controllers//notificationawait _mediator.Publish(new ProductReviewEvent(product, model.AddProductReview));- await _customerActivityService.InsertActivity("PublicStore.AddProductReview", product.Id, _translationService.GetResource("ActivityLog.PublicStore.AddProductReview"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddProductReview", product.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddProductReview"), product.Name);//raise eventif (productReview.IsApproved)@@ -775,7 +779,9 @@ namespace Grand.Web.Controllers});//activity log- await _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id, _translationService.GetResource("ActivityLog.PublicStore.AskQuestion"));+ await _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AskQuestion"));model.SuccessfullySent = true;model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id);@@ -836,7 +842,9 @@ namespace Grand.Web.Controllers});//activity log- await _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id, _translationService.GetResource("ActivityLog.PublicStore.AskQuestion"));+ await _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AskQuestion"));//return Jsonreturn Json(new{@@ -887,7 +895,9 @@ namespace Grand.Web.Controllers_compareProductsService.AddProductToCompareList(productId);//activity log- await _customerActivityService.InsertActivity("PublicStore.AddToCompareList", productId, _translationService.GetResource("ActivityLog.PublicStore.AddToCompareList"), product.Name);+ await _customerActivityService.InsertActivity("PublicStore.AddToCompareList", productId,+ _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),+ _translationService.GetResource("ActivityLog.PublicStore.AddToCompareList"), product.Name);return Json(new{