Skip to content

Commit

Permalink
Further changes
Browse files Browse the repository at this point in the history
  • Loading branch information
support committed Dec 10, 2023
1 parent 6e5e5c8 commit efba15d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ await _settingService.SaveSetting(new CustomerSettings {
OnlineCustomerMinutes = 20,
OnlineShoppingCartMinutes = 60,
StoreLastVisitedPage = true,
SaveVisitedPage = false,
AllowUsersToDeleteAccount = false,
AllowUsersToExportData = false,
TwoFactorAuthenticationEnabled = false
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Grand.Domain/Customers/CustomerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ public class CustomerSettings : ISettings
/// </summary>
public bool StoreLastVisitedPage { get; set; }

/// <summary>
/// For the reasons of efficiency it is required to set, besides settings in activity Log - PublicStore.Url
/// </summary>
public bool SaveVisitedPage { get; set; }

/// <summary>
/// Gets or sets a value indicating whether during registration the customer has a free shipping to the next a order
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Discount, DiscountModel>();
return discount;
}
public static Discount ToEntity(this DiscountModel model, IDateTimeService dateTimeService)
{
var discount = model.MapTo<DiscountModel, Discount>();
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Grand.Web.Admin/Services/BlogViewModelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public virtual async Task<BlogPost> 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)
Expand Down
20 changes: 2 additions & 18 deletions src/Web/Grand.Web.Admin/Services/CategoryViewModelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;

Expand All @@ -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)
{
Expand All @@ -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;
}

Expand All @@ -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)
Expand Down Expand Up @@ -339,7 +323,7 @@ await _productCategoryService.InsertProductCategory(
public virtual async Task<(IList<ProductModel> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -55,7 +53,6 @@ public CollectionViewModelService(
ITranslationService translationService,
IDiscountService discountService,
IVendorService vendorService,
IDateTimeService dateTimeService,
ILanguageService languageService,
IWorkContext workContext,
SeoSettings seoSettings)
Expand All @@ -70,7 +67,6 @@ public CollectionViewModelService(
_translationService = translationService;
_discountService = discountService;
_vendorService = vendorService;
_dateTimeService = dateTimeService;
_languageService = languageService;
_workContext = workContext;
_seoSettings = seoSettings;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -223,7 +219,7 @@ public virtual async Task DeleteCollection(Collection collection)
public virtual async Task<(IList<ProductModel> 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<CollectionModel.CollectionProductModel> collectionProductModels, int totalCount)> PrepareCollectionProductModel(string collectionId, string storeId, int pageIndex, int pageSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -32,16 +31,14 @@ public CustomerGroupViewModelService(
ITranslationService translationService,
IProductService productService,
IStoreService storeService,
IVendorService vendorService,
IDateTimeService dateTimeService)
IVendorService vendorService)
{
_groupService = groupService;
_customerGroupProductService = customerGroupProductService;
_translationService = translationService;
_productService = productService;
_storeService = storeService;
_vendorService = vendorService;
_dateTimeService = dateTimeService;
}

#endregion
Expand Down Expand Up @@ -119,7 +116,7 @@ public virtual async Task<IList<CustomerGroupProductModel>> PrepareCustomerGroup
public virtual async Task<(IList<ProductModel> 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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -96,7 +92,7 @@ public virtual async Task DeleteCustomerTag(CustomerTag customerTag)
public virtual async Task<(IList<ProductModel> 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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Web/Grand.Web.Admin/Services/CustomerViewModelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ public virtual async Task<IList<ShoppingCartItemModel>> PrepareShoppingCartItemM
var taxService = _serviceProvider.GetRequiredService<ITaxService>();
var priceCalculationService = _serviceProvider.GetRequiredService<IPricingService>();
var priceFormatter = _serviceProvider.GetRequiredService<IPriceFormatter>();

var productAttributeFormatter = _serviceProvider.GetRequiredService<IProductAttributeFormatter>();
foreach (var sci in cart)
{
var store = await _storeService.GetStoreById(sci.StoreId);
Expand All @@ -1094,7 +1094,7 @@ public virtual async Task<IList<ShoppingCartItemModel>> PrepareShoppingCartItemM
ProductId = sci.ProductId,
Quantity = sci.Quantity,
ProductName = product.Name,
AttributeInfo = await _serviceProvider.GetRequiredService<IProductAttributeFormatter>().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),
Expand Down Expand Up @@ -1194,7 +1194,7 @@ public virtual async Task<IList<string>> UpdateCart(Customer customer, string sh
public virtual async Task<(IList<ProductModel> 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)
Expand Down
4 changes: 0 additions & 4 deletions src/Web/Grand.Web.Vendor/Controllers/ProductController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2381,10 +2381,6 @@ await _productViewModelService.DeleteProductAttributeCombinationTierPrices(produ

#endregion

#region Activity log

#endregion

#region Reservation

[PermissionAuthorizeAction(PermissionActionName.Preview)]
Expand Down

0 comments on commit efba15d

Please sign in to comment.