当前位置: 首页>>代码示例>>C#>>正文


C# ICustomerBase类代码示例

本文整理汇总了C#中ICustomerBase的典型用法代码示例。如果您正苦于以下问题:C# ICustomerBase类的具体用法?C# ICustomerBase怎么用?C# ICustomerBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ICustomerBase类属于命名空间,在下文中一共展示了ICustomerBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的ICustomerBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。