From efba15dc6ef40877f5d8264026c3aebb2efbd754 Mon Sep 17 00:00:00 2001 From: support Date: Sun, 10 Dec 2023 08:38:42 +0100 Subject: [PATCH] Further changes --- .../Installation/InstallDataSettings.cs | 1 - .../Customers/CustomerSettings.cs | 5 ----- .../Mapping/DiscountMappingExtensions.cs | 6 +++++- .../Services/BlogViewModelService.cs | 2 +- .../Services/CategoryViewModelService.cs | 20 ++----------------- .../Services/CollectionViewModelService.cs | 8 ++------ .../Services/CustomerGroupViewModelService.cs | 7 ++----- .../Services/CustomerTagViewModelService.cs | 8 ++------ .../Services/CustomerViewModelService.cs | 6 +++--- .../Controllers/ProductController.cs | 4 ---- 10 files changed, 17 insertions(+), 50 deletions(-) diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs index d0c6bdffb..df6db2e0c 100644 --- a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs +++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs @@ -299,7 +299,6 @@ await _settingService.SaveSetting(new CustomerSettings { OnlineCustomerMinutes = 20, OnlineShoppingCartMinutes = 60, StoreLastVisitedPage = true, - SaveVisitedPage = false, AllowUsersToDeleteAccount = false, AllowUsersToExportData = false, TwoFactorAuthenticationEnabled = false diff --git a/src/Core/Grand.Domain/Customers/CustomerSettings.cs b/src/Core/Grand.Domain/Customers/CustomerSettings.cs index 2fc8d69ef..f5704af34 100644 --- a/src/Core/Grand.Domain/Customers/CustomerSettings.cs +++ b/src/Core/Grand.Domain/Customers/CustomerSettings.cs @@ -139,11 +139,6 @@ public class CustomerSettings : ISettings /// public bool StoreLastVisitedPage { get; set; } - /// - /// For the reasons of efficiency it is required to set, besides settings in activity Log - PublicStore.Url - /// - public bool SaveVisitedPage { get; set; } - /// /// Gets or sets a value indicating whether during registration the customer has a free shipping to the next a order /// diff --git a/src/Web/Grand.Web.Admin/Extensions/Mapping/DiscountMappingExtensions.cs b/src/Web/Grand.Web.Admin/Extensions/Mapping/DiscountMappingExtensions.cs index 29f669d3f..66509e9a2 100644 --- a/src/Web/Grand.Web.Admin/Extensions/Mapping/DiscountMappingExtensions.cs +++ b/src/Web/Grand.Web.Admin/Extensions/Mapping/DiscountMappingExtensions.cs @@ -15,7 +15,11 @@ public static DiscountModel ToModel(this Discount entity, IDateTimeService dateT discount.EndDate = entity.EndDateUtc.ConvertToUserTime(dateTimeService); return discount; } - + public static DiscountModel ToModel(this Discount entity) + { + var discount = entity.MapTo(); + return discount; + } public static Discount ToEntity(this DiscountModel model, IDateTimeService dateTimeService) { var discount = model.MapTo(); diff --git a/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs b/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs index cfa10f573..39255db98 100644 --- a/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs +++ b/src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs @@ -195,7 +195,7 @@ public virtual async Task UpdateBlogPostModel(BlogPostModel model, Blo { model.SearchStoreId = _workContext.CurrentCustomer.StaffStoreId; var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize); - return (products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount); + return (products.Select(x => x.ToModel()).ToList(), products.TotalCount); } public virtual async Task InsertProductModel(string blogPostId, BlogProductModel.AddProductModel model) diff --git a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs index 89f5ac4e2..a2b6a035c 100644 --- a/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs +++ b/src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs @@ -2,7 +2,6 @@ using Grand.Business.Core.Interfaces.Catalog.Discounts; using Grand.Business.Core.Interfaces.Catalog.Products; using Grand.Business.Core.Extensions; -using Grand.Business.Core.Interfaces.Common.Directory; using Grand.Business.Core.Interfaces.Common.Localization; using Grand.Business.Core.Interfaces.Common.Seo; using Grand.Business.Core.Interfaces.Common.Stores; @@ -11,13 +10,11 @@ using Grand.Domain.Catalog; using Grand.Domain.Discounts; using Grand.Domain.Seo; -using Grand.Infrastructure; using Grand.Web.Admin.Extensions; using Grand.Web.Admin.Extensions.Mapping; 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; namespace Grand.Web.Admin.Services @@ -30,16 +27,11 @@ public class CategoryViewModelService : ICategoryViewModelService private readonly IDiscountService _discountService; private readonly ITranslationService _translationService; private readonly IStoreService _storeService; - private readonly ICustomerService _customerService; private readonly ISlugService _slugService; private readonly IPictureService _pictureService; private readonly IProductService _productService; private 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; @@ -50,15 +42,11 @@ public CategoryViewModelService( IDiscountService discountService, ITranslationService translationService, IStoreService storeService, - ICustomerService customerService, IPictureService pictureService, ISlugService slugService, IProductService productService, IVendorService vendorService, - IDateTimeService dateTimeService, ILanguageService languageService, - IWorkContext workContext, - IHttpContextAccessor httpContextAccessor, CatalogSettings catalogSettings, SeoSettings seoSettings) { @@ -68,16 +56,12 @@ public CategoryViewModelService( _discountService = discountService; _translationService = translationService; _storeService = storeService; - _customerService = customerService; _slugService = slugService; _productService = productService; _pictureService = pictureService; _vendorService = vendorService; _languageService = languageService; - _workContext = workContext; - _httpContextAccessor = httpContextAccessor; _catalogSettings = catalogSettings; - _dateTimeService = dateTimeService; _seoSettings = seoSettings; } @@ -103,7 +87,7 @@ protected virtual async Task PrepareDiscountModel(CategoryModel model, Category model.AvailableDiscounts = (await _discountService .GetAllDiscounts(DiscountType.AssignedToCategories, storeId: storeId, showHidden: true)) - .Select(d => d.ToModel(_dateTimeService)) + .Select(d => d.ToModel()) .ToList(); if (!excludeProperties && category != null) @@ -339,7 +323,7 @@ await _productCategoryService.InsertProductCategory( public virtual async Task<(IList products, int totalCount)> PrepareProductModel(CategoryModel.AddCategoryProductModel model, int pageIndex, int pageSize) { var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize); - return (products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount); + return (products.Select(x => x.ToModel()).ToList(), products.TotalCount); } } } diff --git a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs index 6a10a4bf9..fe299f1de 100644 --- a/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs +++ b/src/Web/Grand.Web.Admin/Services/CollectionViewModelService.cs @@ -2,7 +2,6 @@ using Grand.Business.Core.Interfaces.Catalog.Discounts; using Grand.Business.Core.Interfaces.Catalog.Products; using Grand.Business.Core.Extensions; -using Grand.Business.Core.Interfaces.Common.Directory; using Grand.Business.Core.Interfaces.Common.Localization; using Grand.Business.Core.Interfaces.Common.Seo; using Grand.Business.Core.Interfaces.Common.Stores; @@ -35,7 +34,6 @@ public class CollectionViewModelService : ICollectionViewModelService private readonly ITranslationService _translationService; private readonly IDiscountService _discountService; private readonly IVendorService _vendorService; - private readonly IDateTimeService _dateTimeService; private readonly ILanguageService _languageService; private readonly IWorkContext _workContext; private readonly SeoSettings _seoSettings; @@ -55,7 +53,6 @@ public CollectionViewModelService( ITranslationService translationService, IDiscountService discountService, IVendorService vendorService, - IDateTimeService dateTimeService, ILanguageService languageService, IWorkContext workContext, SeoSettings seoSettings) @@ -70,7 +67,6 @@ public CollectionViewModelService( _translationService = translationService; _discountService = discountService; _vendorService = vendorService; - _dateTimeService = dateTimeService; _languageService = languageService; _workContext = workContext; _seoSettings = seoSettings; @@ -110,7 +106,7 @@ public virtual async Task PrepareDiscountModel(CollectionModel model, Collection model.AvailableDiscounts = (await _discountService .GetAllDiscounts(DiscountType.AssignedToCollections, storeId: _workContext.CurrentCustomer.Id, showHidden: true)) - .Select(d => d.ToModel(_dateTimeService)) + .Select(d => d.ToModel()) .ToList(); if (!excludeProperties && collection != null) @@ -223,7 +219,7 @@ public virtual async Task DeleteCollection(Collection collection) public virtual async Task<(IList products, int totalCount)> PrepareProductModel(CollectionModel.AddCollectionProductModel model, int pageIndex, int pageSize) { var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize); - return (products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount); + return (products.Select(x => x.ToModel()).ToList(), products.TotalCount); } public virtual async Task<(IEnumerable collectionProductModels, int totalCount)> PrepareCollectionProductModel(string collectionId, string storeId, int pageIndex, int pageSize) diff --git a/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.cs index 1d9a7b2ef..7b93c71b6 100644 --- a/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.cs +++ b/src/Web/Grand.Web.Admin/Services/CustomerGroupViewModelService.cs @@ -22,7 +22,6 @@ public class CustomerGroupViewModelService : ICustomerGroupViewModelService private readonly IProductService _productService; private readonly IStoreService _storeService; private readonly IVendorService _vendorService; - private readonly IDateTimeService _dateTimeService; #region Constructors @@ -32,8 +31,7 @@ public CustomerGroupViewModelService( ITranslationService translationService, IProductService productService, IStoreService storeService, - IVendorService vendorService, - IDateTimeService dateTimeService) + IVendorService vendorService) { _groupService = groupService; _customerGroupProductService = customerGroupProductService; @@ -41,7 +39,6 @@ public CustomerGroupViewModelService( _productService = productService; _storeService = storeService; _vendorService = vendorService; - _dateTimeService = dateTimeService; } #endregion @@ -119,7 +116,7 @@ public virtual async Task> PrepareCustomerGroup public virtual async Task<(IList products, int totalCount)> PrepareProductModel(CustomerGroupProductModel.AddProductModel model, int pageIndex, int pageSize) { var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize); - return (products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount); + return (products.Select(x => x.ToModel()).ToList(), products.TotalCount); } public virtual async Task InsertProductModel(CustomerGroupProductModel.AddProductModel model) { diff --git a/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.cs index 2fe8e9978..8801d8757 100644 --- a/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.cs +++ b/src/Web/Grand.Web.Admin/Services/CustomerTagViewModelService.cs @@ -1,5 +1,4 @@ using Grand.Business.Core.Interfaces.Catalog.Products; -using Grand.Business.Core.Interfaces.Common.Directory; using Grand.Business.Core.Interfaces.Common.Localization; using Grand.Business.Core.Interfaces.Common.Stores; using Grand.Business.Core.Interfaces.Customers; @@ -22,22 +21,19 @@ public class CustomerTagViewModelService : ICustomerTagViewModelService private readonly IStoreService _storeService; private readonly IVendorService _vendorService; private readonly ICustomerTagService _customerTagService; - private readonly IDateTimeService _dateTimeService; public CustomerTagViewModelService( ITranslationService translationService, IProductService productService, IStoreService storeService, IVendorService vendorService, - ICustomerTagService customerTagService, - IDateTimeService dateTimeService) + ICustomerTagService customerTagService) { _translationService = translationService; _productService = productService; _storeService = storeService; _vendorService = vendorService; _customerTagService = customerTagService; - _dateTimeService = dateTimeService; } public virtual CustomerModel PrepareCustomerModelForList(Customer customer) @@ -96,7 +92,7 @@ public virtual async Task DeleteCustomerTag(CustomerTag customerTag) public virtual async Task<(IList products, int totalCount)> PrepareProductModel(CustomerTagProductModel.AddProductModel model, int pageIndex, int pageSize) { var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize); - return (products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount); + return (products.Select(x => x.ToModel()).ToList(), products.TotalCount); } public virtual async Task InsertProductModel(CustomerTagProductModel.AddProductModel model) { diff --git a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs index c85e9bbc7..9c838faf1 100644 --- a/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs +++ b/src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs @@ -1080,7 +1080,7 @@ public virtual async Task> PrepareShoppingCartItemM var taxService = _serviceProvider.GetRequiredService(); var priceCalculationService = _serviceProvider.GetRequiredService(); var priceFormatter = _serviceProvider.GetRequiredService(); - + var productAttributeFormatter = _serviceProvider.GetRequiredService(); foreach (var sci in cart) { var store = await _storeService.GetStoreById(sci.StoreId); @@ -1094,7 +1094,7 @@ public virtual async Task> PrepareShoppingCartItemM ProductId = sci.ProductId, Quantity = sci.Quantity, ProductName = product.Name, - AttributeInfo = await _serviceProvider.GetRequiredService().FormatAttributes(product, sci.Attributes), + AttributeInfo = await productAttributeFormatter.FormatAttributes(product, sci.Attributes), UnitPrice = priceFormatter.FormatPrice(price), UnitPriceValue = price, Total = priceFormatter.FormatPrice((await taxService.GetProductPrice(product, (await priceCalculationService.GetSubTotal(sci, product)).subTotal)).productprice), @@ -1194,7 +1194,7 @@ public virtual async Task> UpdateCart(Customer customer, string sh public virtual async Task<(IList products, int totalCount)> PrepareProductModel(CustomerModel.AddProductModel model, int pageIndex, int pageSize) { var products = await _productService.PrepareProductList(model.SearchCategoryId, model.SearchBrandId, model.SearchCollectionId, model.SearchStoreId, model.SearchVendorId, model.SearchProductTypeId, model.SearchProductName, pageIndex, pageSize); - return (products.Select(x => x.ToModel(_dateTimeService)).ToList(), products.TotalCount); + return (products.Select(x => x.ToModel()).ToList(), products.TotalCount); } public virtual async Task InsertCustomerAddProductModel(string customerId, bool personalized, CustomerModel.AddProductModel model) diff --git a/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs b/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs index 7f40a74b7..84fdc5932 100644 --- a/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs +++ b/src/Web/Grand.Web.Vendor/Controllers/ProductController.cs @@ -2381,10 +2381,6 @@ await _productViewModelService.DeleteProductAttributeCombinationTierPrices(produ #endregion - #region Activity log - - #endregion - #region Reservation [PermissionAuthorizeAction(PermissionActionName.Preview)]