本文整理汇总了C#中ICustomerBase类的典型用法代码示例。如果您正苦于以下问题:C# ICustomerBase类的具体用法?C# ICustomerBase怎么用?C# ICustomerBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICustomerBase类属于命名空间,在下文中一共展示了ICustomerBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TryAward
/// <summary>
/// Tries to apply the discount line item reward
/// </summary>
/// <param name="validate">
/// The <see cref="ILineItemContainer"/> to validate against
/// </param>
/// <param name="customer">
/// The customer.
/// </param>
/// <returns>
/// The <see cref="Attempt{ILinetItem}"/>.
/// </returns>
public override Attempt<ILineItem> TryAward(ILineItemContainer validate, ICustomerBase customer)
{
var shippingLineItems = validate.ShippingLineItems();
var audits = shippingLineItems.Select(item =>
new CouponRewardAdjustmentAudit()
{
RelatesToSku = item.Sku,
Log = new[]
{
new DataModifierLog()
{
PropertyName = "Price",
OriginalValue = item.Price,
ModifiedValue = 0M
}
}
}).ToList();
// Get the item template
var discountLineItem = CreateTemplateDiscountLineItem(audits);
var discount = validate.ShippingLineItems().Sum(x => x.TotalPrice);
discountLineItem.Price = discount;
return Attempt<ILineItem>.Succeed(discountLineItem);
}
开发者ID:drpeck,项目名称:Merchello,代码行数:37,代码来源:CouponFreeShippingReward.cs
示例2: TryApply
/// <summary>
/// Validates the constraint against the <see cref="ILineItemContainer"/>
/// </summary>
/// <param name="value">
/// The value to object to which the constraint is to be applied.
/// </param>
/// <param name="customer">
/// The <see cref="ICustomerBase"/>.
/// </param>
/// <returns>
/// The <see cref="Attempt{ILineItemContainer}"/> indicating whether or not the constraint can be enforced.
/// </returns>
public override Attempt<ILineItemContainer> TryApply(ILineItemContainer value, ICustomerBase customer)
{
var visitor = new MaximumQuantityConstraintVisitor(MaximumQuantity);
value.Items.Accept(visitor);
return this.Success(this.CreateNewLineContainer(visitor.ModifiedItems));
}
开发者ID:drpeck,项目名称:Merchello,代码行数:19,代码来源:MaximumQuantityConstraint.cs
示例3: ConsumerItemCacheForInserting
public static IItemCache ConsumerItemCacheForInserting(ICustomerBase customer, ItemCacheType itemCacheType)
{
return new ItemCache(customer.EntityKey, itemCacheType)
{
EntityKey = customer.EntityKey
};
}
开发者ID:BatJan,项目名称:Merchello,代码行数:7,代码来源:MockCustomerItemCacheDataMaker.cs
示例4: GetItemCacheWithKey
/// <summary>
/// Creates a basket for a consumer with a given type
/// </summary>
/// <param name="customer">
/// The customer.
/// </param>
/// <param name="itemCacheType">
/// The item Cache Type.
/// </param>
/// <param name="versionKey">
/// The version Key.
/// </param>
/// <returns>
/// The <see cref="IItemCache"/>.
/// </returns>
public IItemCache GetItemCacheWithKey(ICustomerBase customer, ItemCacheType itemCacheType, Guid versionKey)
{
Mandate.ParameterCondition(Guid.Empty != versionKey, "versionKey");
// determine if the consumer already has a item cache of this type, if so return it.
var itemCache = GetItemCacheByCustomer(customer, itemCacheType);
if (itemCache != null) return itemCache;
itemCache = new ItemCache(customer.Key, itemCacheType)
{
VersionKey = versionKey
};
if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs<IItemCache>(itemCache), this))
{
// registry.WasCancelled = true;
return itemCache;
}
itemCache.EntityKey = customer.Key;
using (new WriteLock(Locker))
{
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateItemCacheRepository(uow))
{
repository.AddOrUpdate(itemCache);
uow.Commit();
}
}
Created.RaiseEvent(new Events.NewEventArgs<IItemCache>(itemCache), this);
return itemCache;
}
开发者ID:arknu,项目名称:Merchello,代码行数:50,代码来源:ItemCacheService.cs
示例5: Basket
internal Basket(IItemCache itemCache, ICustomerBase customer)
{
Mandate.ParameterNotNull(itemCache, "ItemCache");
Mandate.ParameterCondition(itemCache.ItemCacheType == ItemCacheType.Basket, "itemCache");
Mandate.ParameterNotNull(customer, "customer");
_customer = customer;
_itemCache = itemCache;
}
开发者ID:BatJan,项目名称:Merchello,代码行数:9,代码来源:Basket.cs
示例6: CustomerItemCacheBase
/// <summary>
/// Initializes a new instance of the <see cref="CustomerItemCacheBase"/> class.
/// </summary>
/// <param name="itemCache">
/// The item cache.
/// </param>
/// <param name="customer">
/// The customer.
/// </param>
protected CustomerItemCacheBase(IItemCache itemCache, ICustomerBase customer)
{
Mandate.ParameterNotNull(itemCache, "ItemCache");
Mandate.ParameterNotNull(customer, "customer");
_customer = customer;
_itemCache = itemCache;
EnableDataModifiers = true;
this.Initialize();
}
开发者ID:drpeck,项目名称:Merchello,代码行数:19,代码来源:CustomerItemCacheBase.cs
示例7: BasketLineItemFactory
/// <summary>
/// Initializes a new instance of the <see cref="BasketLineItemFactory"/> class.
/// </summary>
/// <param name="umbraco">
/// The umbraco.
/// </param>
/// <param name="currentCustomer">
/// The current Customer.
/// </param>
/// <param name="currency">
/// The currency.
/// </param>
public BasketLineItemFactory(UmbracoHelper umbraco, ICustomerBase currentCustomer, ICurrency currency)
{
Mandate.ParameterNotNull(umbraco, "umbraco");
Mandate.ParameterNotNull(currency, "currency");
Mandate.ParameterNotNull(currentCustomer, "currentCustomer");
this._umbraco = umbraco;
this._currency = currency;
this._currentCustomer = currentCustomer;
}
开发者ID:ProNotion,项目名称:Merchello,代码行数:22,代码来源:BasketLineItemFactory.cs
示例8: TryAward
/// <summary>
/// Tries to apply the discount line item reward
/// </summary>
/// <param name="validate">
/// The <see cref="ILineItemContainer"/> to validate against
/// </param>
/// <param name="customer">
/// The customer.
/// </param>
/// <returns>
/// The <see cref="Attempt{ILinetItem}"/>.
/// </returns>
public override Attempt<ILineItem> TryAward(ILineItemContainer validate, ICustomerBase customer)
{
// Get the item template
var discountLineItem = CreateTemplateDiscountLineItem();
var discount = validate.ShippingLineItems().Sum(x => x.TotalPrice);
discountLineItem.Price = discount;
return Attempt<ILineItem>.Succeed(discountLineItem);
}
开发者ID:ProNotion,项目名称:Merchello,代码行数:23,代码来源:CouponFreeShippingReward.cs
示例9: SalePreparationBase
/// <summary>
/// Initializes a new instance of the <see cref="SalePreparationBase"/> class.
/// </summary>
/// <param name="merchelloContext">
/// The merchello context.
/// </param>
/// <param name="itemCache">
/// The item cache.
/// </param>
/// <param name="customer">
/// The customer.
/// </param>
internal SalePreparationBase(IMerchelloContext merchelloContext, IItemCache itemCache, ICustomerBase customer)
{
Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
Mandate.ParameterNotNull(itemCache, "ItemCache");
Mandate.ParameterCondition(itemCache.ItemCacheType == ItemCacheType.Checkout, "itemCache");
Mandate.ParameterNotNull(customer, "customer");
_merchelloContext = merchelloContext;
_customer = customer;
_itemCache = itemCache;
ApplyTaxesToInvoice = true;
}
开发者ID:kedde,项目名称:Merchello,代码行数:24,代码来源:SalePreparationBase.cs
示例10: EnsureCustomerCreationAndConvertBasket
/// <summary>
/// The ensure customer creation and convert basket.
/// </summary>
/// <param name="customer">
/// The customer.
/// </param>
protected override void EnsureCustomerCreationAndConvertBasket(ICustomerBase customer)
{
if (!customer.IsAnonymous) return;
var memberId = Convert.ToInt32(this.MembershipProviderKey(customer.Key));
var member = _memberService.GetById(memberId);
if (MerchelloConfiguration.Current.CustomerMemberTypes.Any(x => x == member.ContentTypeAlias))
{
base.EnsureCustomerCreationAndConvertBasket(customer);
}
}
开发者ID:ProNotion,项目名称:Merchello,代码行数:18,代码来源:CustomerContext.cs
示例11: TryApply
/// <summary>
/// The try apply.
/// </summary>
/// <param name="value">
/// The value.
/// </param>
/// <param name="customer">
/// The customer.
/// </param>
/// <returns>
/// The <see cref="Attempt"/>.
/// </returns>
public override Attempt<ILineItemContainer> TryApply(ILineItemContainer value, ICustomerBase customer)
{
if (MerchelloContext.Current != null)
{
if (!MerchelloContext.Current.Gateways.Taxation.ProductPricingEnabled) return this.Success(value);
var vistor = new ExcludeTaxesInProductPricesVisitor();
value.Items.Accept(vistor);
return this.Success(value);
}
return Attempt<ILineItemContainer>.Fail(new NullReferenceException("MerchelloContext was null"));
}
开发者ID:drpeck,项目名称:Merchello,代码行数:24,代码来源:ExcludeTaxesIncludedInProductPrices.cs
示例12: CacheCustomer
private void CacheCustomer(ICustomerBase customer)
{
// set/reset the cookie
// TODO decide how we want to deal with cookie persistence options
var cookie = new HttpCookie(ConsumerCookieKey)
{
Value = EncryptionHelper.Encrypt(customer.EntityKey.ToString())
};
_umbracoContext.HttpContext.Response.Cookies.Add(cookie);
_cache.RequestCache.GetCacheItem(ConsumerCookieKey, () => customer.EntityKey);
_cache.RuntimeCache.GetCacheItem(CacheKeys.CostumerCacheKey(customer.EntityKey), () => customer, TimeSpan.FromMinutes(5), true);
}
开发者ID:VDBBjorn,项目名称:Merchello,代码行数:13,代码来源:CustomerContext.cs
示例13: CheckoutContext
/// <summary>
/// Initializes a new instance of the <see cref="CheckoutContext"/> class.
/// </summary>
/// <param name="customer">
/// The <see cref="ICustomerBase"/> associated with this checkout.
/// </param>
/// <param name="itemCache">
/// The temporary <see cref="IItemCache"/> of the basket <see cref="IItemCache"/> to be used in the
/// checkout process.
/// </param>
/// <param name="merchelloContext">
/// The <see cref="IMerchelloContext"/>.
/// </param>
/// <param name="settings">
/// The version change settings.
/// </param>
public CheckoutContext(ICustomerBase customer, IItemCache itemCache, IMerchelloContext merchelloContext, ICheckoutContextSettings settings)
{
Mandate.ParameterNotNull(customer, "customer");
Mandate.ParameterNotNull(itemCache, "itemCache");
Mandate.ParameterNotNull(merchelloContext, "merchelloContext");
Mandate.ParameterNotNull(settings, "settings");
this.MerchelloContext = merchelloContext;
this.ItemCache = itemCache;
this.Customer = customer;
this.Cache = merchelloContext.Cache.RuntimeCache;
this.ApplyTaxesToInvoice = true;
this.Settings = settings;
this.RaiseCustomerEvents = false;
}
开发者ID:jlarc,项目名称:Merchello,代码行数:31,代码来源:CheckoutContext.cs
示例14: TryApply
/// <summary>
/// Validates the constraint against the <see cref="ILineItemContainer"/>
/// </summary>
/// <param name="value">
/// The value to object to which the constraint is to be applied.
/// </param>
/// <param name="customer">
/// The <see cref="ICustomerBase"/>.
/// </param>
/// <returns>
/// The <see cref="Attempt{ILineItemContainer}"/> indicating whether or not the constraint can be enforced.
/// </returns>
public override Attempt<ILineItemContainer> TryApply(ILineItemContainer value, ICustomerBase customer)
{
if (MaximumRedemptions == 0) return Attempt<ILineItemContainer>.Succeed(value);
if (MerchelloContext.Current != null)
{
var offerRedeemedService = ((ServiceContext)MerchelloContext.Current.Services).OfferRedeemedService;
var offerSettingsKey = this.OfferComponentDefinition.OfferSettingsKey;
var remptionCount = offerRedeemedService.GetOfferRedeemedCount(offerSettingsKey);
return remptionCount >= MaximumRedemptions
? this.Fail(value, "Redemption count would exceed the maximum number of allowed")
: this.Success(value);
}
return this.Fail(value, "MerchelloContext was null");
}
开发者ID:drpeck,项目名称:Merchello,代码行数:30,代码来源:MaximumNumberOfRedemptionsConstraint.cs
示例15: TryApply
/// <summary>
/// Validates the constraint against the <see cref="ILineItemContainer"/>
/// </summary>
/// <param name="value">
/// The value to object to which the constraint is to be applied.
/// </param>
/// <param name="customer">
/// The <see cref="ICustomerBase"/>.
/// </param>
/// <returns>
/// The <see cref="Attempt{ILineItemContainer}"/> indicating whether or not the constraint can be enforced.
/// </returns>
public override Attempt<ILineItemContainer> TryApply(ILineItemContainer value, ICustomerBase customer)
{
if (customer.IsAnonymous) return Attempt<ILineItemContainer>.Fail(new OfferRedemptionException("Cannot be applied by anonymous customers."));
if (MerchelloContext.Current != null)
{
var offerRedeemedService = ((ServiceContext)MerchelloContext.Current.Services).OfferRedeemedService;
var offerSettingsKey = this.OfferComponentDefinition.OfferSettingsKey;
var remptions = offerRedeemedService.GetByOfferSettingsKeyAndCustomerKey(offerSettingsKey, customer.Key);
return remptions.Any()
? this.Fail(value, "Customer has already redeemed this offer.")
: this.Success(value);
}
return Attempt<ILineItemContainer>.Fail(new NullReferenceException("MerchelloContext was null"));
}
开发者ID:drpeck,项目名称:Merchello,代码行数:30,代码来源:OneCouponPerCustomerConstraint.cs
示例16: GetItemCache
/// <summary>
/// Gets the checkout <see cref="IItemCache"/> for the <see cref="ICustomerBase"/>
/// </summary>
/// <param name="merchelloContext">
/// The <see cref="IMerchelloContext"/>
/// </param>
/// <param name="customer">
/// The customer associated with the checkout
/// </param>
/// <param name="versionKey">
/// The version key for this <see cref="SalePreparationBase"/>
/// </param>
/// <returns>
/// The <see cref="IItemCache"/> associated with the customer checkout
/// </returns>
protected static IItemCache GetItemCache(IMerchelloContext merchelloContext, ICustomerBase customer, Guid versionKey)
{
var runtimeCache = merchelloContext.Cache.RuntimeCache;
var cacheKey = MakeCacheKey(customer, versionKey);
var itemCache = runtimeCache.GetCacheItem(cacheKey) as IItemCache;
if (itemCache != null) return itemCache;
itemCache = merchelloContext.Services.ItemCacheService.GetItemCacheWithKey(customer, ItemCacheType.Checkout, versionKey);
// this is probably an invalid version of the checkout
if (!itemCache.VersionKey.Equals(versionKey))
{
var oldCacheKey = MakeCacheKey(customer, itemCache.VersionKey);
runtimeCache.ClearCacheItem(oldCacheKey);
Reset(merchelloContext, customer);
// delete the old version
merchelloContext.Services.ItemCacheService.Delete(itemCache);
return GetItemCache(merchelloContext, customer, versionKey);
}
runtimeCache.InsertCacheItem(cacheKey, () => itemCache);
return itemCache;
}
开发者ID:kedde,项目名称:Merchello,代码行数:40,代码来源:SalePreparationBase.cs
示例17: TryApply
/// <summary>
/// Validates the constraint against the <see cref="ILineItemContainer"/>
/// </summary>
/// <param name="value">
/// The value to object to which the constraint is to be applied.
/// </param>
/// <param name="customer">
/// The <see cref="ICustomerBase"/>.
/// </param>
/// <returns>
/// The <see cref="Attempt{ILineItemContainer}"/> indicating whether or not the constraint can be enforced.
/// </returns>
public override Attempt<ILineItemContainer> TryApply(ILineItemContainer value, ICustomerBase customer)
{
return Attempt<ILineItemContainer>.Succeed(CreateNewLineContainer(value.Items.Where(x => x.LineItemType != LineItemType.Shipping)));
}
开发者ID:drpeck,项目名称:Merchello,代码行数:16,代码来源:ExcludeShippingCostConstraint.cs
示例18: EnsureIsLoggedInCustomer
private void EnsureIsLoggedInCustomer(ICustomerBase customer, string membershipId)
{
if (this._cache.RequestCache.GetCacheItem(CacheKeys.EnsureIsLoggedInCustomerValidated(customer.Key)) != null) return;
var dataValue = this.ContextData.Values.FirstOrDefault(x => x.Key == UmbracoMemberIdDataKey);
// If the dataValues do not contain the umbraco member id reinitialize
if (!string.IsNullOrEmpty(dataValue.Value))
{
// Assert are equal
if (!dataValue.Value.Equals(membershipId)) this.Reinitialize(customer);
return;
}
if (dataValue.Value != membershipId) this.Reinitialize(customer);
}
开发者ID:jlarc,项目名称:Merchello,代码行数:16,代码来源:CustomerContextBase.cs
示例19: SaveCustomer
/// <summary>
/// Saves the current customer
/// </summary>
/// <param name="merchelloContext">
/// The merchello Context.
/// </param>
/// <param name="customer">
/// The customer.
/// </param>
private static void SaveCustomer(IMerchelloContext merchelloContext, ICustomerBase customer)
{
if (typeof(AnonymousCustomer) == customer.GetType())
{
merchelloContext.Services.CustomerService.Save(customer as AnonymousCustomer);
}
else
{
((CustomerService)merchelloContext.Services.CustomerService).Save(customer as Customer);
}
}
开发者ID:kedde,项目名称:Merchello,代码行数:20,代码来源:SalePreparationBase.cs
示例20: Reinitialize
/// <summary>
/// Reinitializes the customer context
/// </summary>
/// <param name="customer">
/// The <see cref="CustomerBase"/>
/// </param>
/// <remarks>
/// Sometimes useful to clear the various caches used internally in the customer context
/// </remarks>
public virtual void Reinitialize(ICustomerBase customer)
{
// customer has logged out, so we need to go back to an anonymous customer
var cookie = this._umbracoContext.HttpContext.Request.Cookies[CustomerCookieName];
if (cookie == null)
{
this.Initialize();
return;
}
cookie.Expires = DateTime.Now.AddDays(-1);
this._cache.RequestCache.ClearCacheItem(CustomerCookieName);
this._cache.RuntimeCache.ClearCacheItem(CacheKeys.CustomerCacheKey(customer.Key));
this.Initialize();
}
开发者ID:jlarc,项目名称:Merchello,代码行数:27,代码来源:CustomerContextBase.cs
注:本文中的ICustomerBase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论