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


C# Profile.Update方法代码示例

本文整理汇总了C#中Profile.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Profile.Update方法的具体用法?C# Profile.Update怎么用?C# Profile.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Profile的用法示例。


在下文中一共展示了Profile.Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessCommerceParty

        /// <summary>
        /// Processes the commerce party.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="customerProfile">The customer profile.</param>
        /// <param name="partyToAdd">The party to add.</param>
        /// <returns>Newly created party.</returns>
        protected virtual Party ProcessCommerceParty(AddPartiesResult result, Profile customerProfile, RefSFModels.CommerceParty partyToAdd)
        {
            Assert.ArgumentNotNull(partyToAdd.Name, "partyToAdd.Name");
            Assert.ArgumentNotNull(partyToAdd.ExternalId, "partyToAdd.ExternalId");

            Profile addressProfile = null;
            var response = this.CreateAddressProfile(partyToAdd.ExternalId, ref addressProfile);
            if (!response.Success)
            {
                result.Success = false;
                response.SystemMessages.ToList().ForEach(m => result.SystemMessages.Add(m));
                return null;
            }

            var requestToCommerceProfile = new TranslateEntityToCommerceAddressProfileRequest(partyToAdd, addressProfile);
            PipelineUtility.RunCommerceConnectPipeline<TranslateEntityToCommerceAddressProfileRequest, CommerceResult>(CommerceServerStorefrontConstants.PipelineNames.TranslateEntityToCommerceAddressProfile, requestToCommerceProfile);

            addressProfile.Update();

            ProfilePropertyListCollection<string> addressList;
            var profileValue = customerProfile["GeneralInfo.address_list"].Value as object[];
            if (profileValue != null)
            {
                var e = profileValue.Select(i => i.ToString());
                addressList = new ProfilePropertyListCollection<string>(e);
            }
            else
            {
                addressList = new ProfilePropertyListCollection<string>();
            }

            addressList.Add(partyToAdd.ExternalId);
            customerProfile["GeneralInfo.address_list"].Value = addressList.Cast<object>().ToArray();

            if (partyToAdd.IsPrimary)
            {
                customerProfile["GeneralInfo.preferred_address"].Value = partyToAdd.ExternalId;
            }

            customerProfile.Update();

            var newParty = this.EntityFactory.Create<RefSFModels.CommerceParty>("Party");
            TranslateCommerceAddressProfileToEntityRequest requestToEntity = new TranslateCommerceAddressProfileToEntityRequest(addressProfile, newParty);
            PipelineUtility.RunCommerceConnectPipeline<TranslateCommerceAddressProfileToEntityRequest, CommerceResult>(CommerceServerStorefrontConstants.PipelineNames.TranslateCommerceAddressProfileToEntity, requestToEntity);

            return requestToEntity.DestinationParty;
        }
开发者ID:Brad-Christie,项目名称:sccs-demo,代码行数:54,代码来源:AddParties.cs


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