Skip to content

Commit

Permalink
#51 Fixed shopper gender issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Orlov committed Jan 11, 2019
1 parent 54c2390 commit 7321c0b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions VirtoCommerce.Storefront/Domain/Marketing/MarketingService.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using VirtoCommerce.Storefront.AutoRestClients.MarketingModuleApi;
using VirtoCommerce.Storefront.AutoRestClients.MarketingModuleApi.Models;
using VirtoCommerce.Storefront.Caching;
using VirtoCommerce.Storefront.Extensions;
using VirtoCommerce.Storefront.Infrastructure;
using VirtoCommerce.Storefront.Model;
using VirtoCommerce.Storefront.Model.Caching;
using VirtoCommerce.Storefront.Model.Common;
using VirtoCommerce.Storefront.Model.Common.Caching;
using VirtoCommerce.Storefront.Model.Marketing;
using VirtoCommerce.Storefront.Model.Services;
Expand All @@ -18,23 +20,28 @@ public class MarketingService : IMarketingService
private readonly IMarketingModuleDynamicContent _dynamicContentApi;
private readonly IStorefrontMemoryCache _memoryCache;
private readonly IApiChangesWatcher _apiChangesWatcher;
private readonly IWorkContextAccessor _workContextAccessor;

public MarketingService(IMarketingModuleDynamicContent dynamicContentApi, IStorefrontMemoryCache memoryCache, IApiChangesWatcher changesWatcher)
public MarketingService(IMarketingModuleDynamicContent dynamicContentApi, IStorefrontMemoryCache memoryCache, IApiChangesWatcher changesWatcher, IWorkContextAccessor workContextAccessor)
{
_dynamicContentApi = dynamicContentApi;
_memoryCache = memoryCache;
_apiChangesWatcher = changesWatcher;
_workContextAccessor = workContextAccessor;
}

public virtual async Task<string> GetDynamicContentHtmlAsync(string storeId, string placeholderName)
{
string htmlContent = null;

var customer = _workContextAccessor.WorkContext.CurrentUser?.Contact;

//TODO: make full context
var evaluationContext = new DynamicContentEvaluationContext
{
StoreId = storeId,
PlaceName = placeholderName
PlaceName = placeholderName,
ShopperGender = customer?.DynamicProperties.GetDynamicPropertyDictValue("Sex")?.Name
};

var cacheKey = CacheKey.With(GetType(), "GetDynamicContentHtmlAsync", storeId, placeholderName);
Expand Down

0 comments on commit 7321c0b

Please sign in to comment.