/// <summary>
        /// Deletes the commerce profile.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="profileName">Name of the profile.</param>
        /// <returns>The service provider result.</returns>
        private ServiceProviderResult DeleteCommerceProfile(string id, string profileName)
        {
            ServiceProviderResult result = new ServiceProviderResult {
                Success = true
            };

            try
            {
                var deleteArgs = new DeleteProfileArgs();
                deleteArgs.InputParameters.Name = profileName;
                deleteArgs.InputParameters.Id   = id;

                CorePipeline.Run(CommerceConstants.PipelineNames.DeleteProfile, deleteArgs);
                result.Success = deleteArgs.OutputParameters.Success;
            }
            catch (Exception e)
            {
                result = new ServiceProviderResult {
                    Success = false
                };
                result.SystemMessages.Add(new SystemMessage {
                    Message = e.Message
                });
            }

            return(result);
        }
        protected ServiceProviderResult CreateAddressProfile(string id, ref Profile profile)
        {
            ServiceProviderResult result = new ServiceProviderResult {
                Success = true
            };

            try
            {
                var createArgs = new CreateProfileArgs();
                createArgs.InputParameters.Name = "Address";
                createArgs.InputParameters.Id   = id;

                CorePipeline.Run(CommerceConstants.PipelineNames.CreateProfile, createArgs);
                profile = createArgs.OutputParameters.CommerceProfile;
            }
            catch (Exception e)
            {
                result = new ServiceProviderResult {
                    Success = false
                };
                result.SystemMessages.Add(new SystemMessage {
                    Message = e.Message
                });
            }

            return(result);
        }
Beispiel #3
0
        private ServiceProviderResult GetCommerceProfile(string id, string profileName, ref Profile profile)
        {
            var result = new ServiceProviderResult {
                Success = true
            };

            try
            {
                var createArgs = new GetProfileArgs();
                createArgs.InputParameters.Name = profileName;
                createArgs.InputParameters.Id   = id;

                CorePipeline.Run(CommerceConstants.PipelineNames.GetProfile, createArgs);
                profile = createArgs.OutputParameters.CommerceProfile;
            }
            catch (Exception e)
            {
                result = new ServiceProviderResult {
                    Success = false
                };
                result.SystemMessages.Add(new SystemMessage {
                    Message = e.Message
                });
            }

            return(result);
        }
Beispiel #4
0
        public override void Process(ServicePipelineArgs args)
        {
            ValidateArguments <CreateUserRequest, CreateUserResult>(args, out var request, out var result);
            Assert.IsNotNull(request.UserName, "request.UserName");
            Assert.IsNotNull(request.Password, "request.Password");
            Container container = GetContainer(request.Shop.Name, string.Empty, "", "", args.Request.CurrencyCode,
                                               new DateTime?());
            CommerceUser commerceUser1 = result.CommerceUser;

            if (commerceUser1 != null &&
                commerceUser1.UserName.Equals(request.UserName, StringComparison.OrdinalIgnoreCase))
            {
                string entityId = "Entity-Customer-" + request.UserName;
                ServiceProviderResult currentResult = new ServiceProviderResult();
                EntityView            entityView    = GetEntityView(container, entityId, string.Empty, "Details", string.Empty,
                                                                    currentResult);
                if (currentResult.Success && !string.IsNullOrEmpty(entityView.EntityId))
                {
                    base.Process(args);
                    return;
                }
            }

            EntityView entityView1 =
                GetEntityView(container, string.Empty, string.Empty, "Details", "AddCustomer", result);

            if (!result.Success)
            {
                return;
            }
            entityView1.Properties.FirstOrDefault(p => p.Name.Equals("Domain")).Value    = request.UserName.Split('\\')[0];
            entityView1.Properties.FirstOrDefault(p => p.Name.Equals("LoginName")).Value =
                request.UserName.Split('\\')[1];
            entityView1.Properties.FirstOrDefault(p => p.Name.Equals("AccountStatus")).Value = "ActiveAccount";
            if (!string.IsNullOrEmpty(request.Email))
            {
                entityView1.Properties.FirstOrDefault(p => p.Name.Equals("Email")).Value = request.Email;
            }
            CommerceCommand commerceCommand = DoAction(container, entityView1, result);

            if (commerceCommand != null &&
                commerceCommand.ResponseCode.Equals("ok", StringComparison.OrdinalIgnoreCase))
            {
                CommerceUser commerceUser2 = EntityFactory.Create <CommerceUser>("CommerceUser");
                commerceUser2.Email      = request.Email;
                commerceUser2.UserName   = request.UserName;
                commerceUser2.ExternalId = commerceCommand.Models.OfType <CustomerAdded>().FirstOrDefault()?.CustomerId;
                result.CommerceUser      = commerceUser2;
                request.Properties.Add(new PropertyItem()
                {
                    Key   = "UserId",
                    Value = result.CommerceUser.ExternalId
                });
                string entityId = "Entity-Customer-" + request.UserName;
                TestSave(container, entityId, request, result, commerceUser2.ExternalId);
            }

            base.Process(args);
        }
        internal WishList TranslateCartToWishListEntity(Cart cart, ServiceProviderResult currentResult)
        {
            WishList result = new WishList();

            Translate(cart, result);

            return(result);
        }
Beispiel #6
0
        public BaseApiModel(ServiceProviderResult result)
        {
            Success = true;

            if (result != null)
            {
                SetErrors(result);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseJsonResult"/> class.
        /// </summary>
        /// <param name="result">The service provider result.</param>
        public BaseJsonResult(ServiceProviderResult result)
        {
            this.Success = true;

            if (result != null)
            {
                this.SetErrors(result);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseJsonResult"/> class.
        /// </summary>
        /// <param name="result">The service provider result.</param>
        public BaseJsonResult(ServiceProviderResult result)
        {
            this.Success = true;

            if (result != null)
            {
                this.SetErrors(result);
            }
        }
 /// <summary>
 /// Adds the basket errors to result.
 /// </summary>
 /// <param name="cart">The cart.</param>
 /// <param name="result">The result.</param>
 protected virtual void AddBasketErrorsToResult(CommerceCart cart, ServiceProviderResult result)
 {
     if (cart != null && cart.Properties["_Basket_Errors"] != null)
     {
         List <string> basketErrors = cart.Properties["_Basket_Errors"] as List <string>;
         basketErrors.ForEach(m => result.SystemMessages.Add(new SystemMessage {
             Message = m
         }));
     }
 }
Beispiel #10
0
        public static void WriteToSitecoreLog(this ServiceProviderResult result)
        {
            if (result.Success)
            {
                return;
            }
            var systemMessages = result.SystemMessages.ToList();

            foreach (var message in systemMessages)
            {
                Sitecore.Diagnostics.Log.Error(message.Message, result);
            }
        }
        public void SetErrors(ServiceProviderResult result)
        {
            this.Success = result.Success;
            if (result.SystemMessages.Count <= 0)
            {
                return;
            }

            foreach (var systemMessage in result.SystemMessages)
            {
                var message = !string.IsNullOrEmpty(systemMessage.Message) ? systemMessage.Message : null;
                this.SetError(message);
            }
        }
Beispiel #12
0
        public void SetErrors(ServiceProviderResult result)
        {
            Success = result.Success;
            if (result.SystemMessages.Count <= 0)
            {
                return;
            }

            var errors = result.SystemMessages;

            foreach (var error in errors)
            {
                Errors.Add(DictionaryPhraseRepository.Current.Get($"/Commerce/System Messages/{error.Message}", $"[System Error: {error.Message}]"));
            }
        }
        /// <summary>
        /// Sets the errors.
        /// </summary>
        /// <param name="result">The result.</param>
        public void SetErrors(ServiceProviderResult result)
        {
            this.Success = result.Success;
            if (result.SystemMessages.Count <= 0)
            {
                return;
            }

            var errors = result.SystemMessages;

            foreach (var error in errors)
            {
                var message = StorefrontManager.GetSystemMessage(error.Message);
                this.Errors.Add(string.IsNullOrEmpty(message) ? error.Message : message);
            }
        }
Beispiel #14
0
 private void AddBasketErrorsToResult(CommerceCart cart, ServiceProviderResult result)
 {
     if (cart?.Properties[KnownBasketWeaklyTypeProperties.BasketErrors] != null)
     {
         var basketErrors = cart.Properties[KnownBasketWeaklyTypeProperties.BasketErrors] as List <string>;
         if (basketErrors == null)
         {
             return;
         }
         foreach (var m in basketErrors)
         {
             result.SystemMessages.Add(new SystemMessage {
                 Message = m
             });
         }
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DeleteCartTest"/> class.
        /// </summary>
        public DeleteCartTest()
        {
            this.visitorId = Guid.NewGuid();
            this.cart      = new Cart {
                ExternalId = this.visitorId.ToString()
            };
            this.request = new DeleteCartRequest(this.cart);
            this.result  = new CartResult();
            this.args    = new ServicePipelineArgs(this.request, this.result);

            this.client = Substitute.For <ICartsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new DeleteCart {
                ClientFactory = clientFactory
            };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadExternalCommerceSystemManufacturersTest" /> class.
        /// </summary>
        public ReadExternalCommerceSystemManufacturersTest()
        {
            this.entityFactory = Substitute.For <IEntityFactory>();

            this.entityFactory.Create("Manufacturer").Returns(callInfo => new Manufacturer());

            this.client = Substitute.For <IProductsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <IProductsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new ReadExternalCommerceSystemManufacturers {
                EntityFactory = entityFactory, ClientFactory = clientFactory
            };

            this.request = new SynchronizeManufacturersRequest();
            this.result  = new ServiceProviderResult();
            this.args    = new ServicePipelineArgs(this.request, this.result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReadExternalCommerceSystemVariantsTest"/> class.
        /// </summary>
        public ReadExternalCommerceSystemVariantsTest()
        {
            this.entityFactory = Substitute.For <IEntityFactory>();

            this.entityFactory.Create("RelationType").Returns(callInfo => new RelationType());
            this.entityFactory.Create("Relation").Returns(callInfo => new Relation());

            this.client = Substitute.For <IProductsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <IProductsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new ReadExternalCommerceSystemVariants {
                EntityFactory = this.entityFactory, ClientFactory = clientFactory
            };
            this.request = new SynchronizeProductRelationsRequest("100500");
            this.result  = new ServiceProviderResult();
            this.args    = new ServicePipelineArgs(this.request, this.result);
        }
        protected ServiceProviderResult CreateAddressProfile(string id, ref Profile profile)
        {
            ServiceProviderResult result = new ServiceProviderResult { Success = true };

            try
            {
                var createArgs = new CreateProfileArgs();
                createArgs.InputParameters.Name = "Address";
                createArgs.InputParameters.Id = id;

                CorePipeline.Run(CommerceConstants.PipelineNames.CreateProfile, createArgs);
                profile = createArgs.OutputParameters.CommerceProfile;
            }
            catch (Exception e)
            {
                result = new ServiceProviderResult { Success = false };
                result.SystemMessages.Add(new SystemMessage { Message = e.Message });
            }

            return result;
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref="SaveProductToExternalCommerceSystemTest" /> class.
        /// </summary>
        public SaveProductToExternalCommerceSystemTest()
        {
            this.client = Substitute.For <IProductsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <IProductsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new SaveProductToExternalCommerceSystem {
                ClientFactory = clientFactory
            };

            this.product = new Product {
                ExternalId = "100500", Name = "Cool car", ShortDescription = "Yea, dude. You wants this one", FullDescription = "Don't think, just pay for this"
            };
            this.language = "en";
            this.request  = new SynchronizeProductRequest("100500")
            {
                Language = this.language
            };
            this.result = new ServiceProviderResult();
            this.args   = new ServicePipelineArgs(this.request, this.result);
            this.args.Request.Properties["Product"] = this.product;
        }
        /// <summary>
        /// Deletes the commerce profile.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="profileName">Name of the profile.</param>
        /// <returns>The service provider result.</returns>
        private ServiceProviderResult DeleteCommerceProfile(string id, string profileName)
        {
            ServiceProviderResult result = new ServiceProviderResult { Success = true };

            try
            {
                var deleteArgs = new DeleteProfileArgs();
                deleteArgs.InputParameters.Name = profileName;
                deleteArgs.InputParameters.Id = id;

                CorePipeline.Run(CommerceConstants.PipelineNames.DeleteProfile, deleteArgs);
                result.Success = deleteArgs.OutputParameters.Success;
            }
            catch (Exception e)
            {
                result = new ServiceProviderResult { Success = false };
                result.SystemMessages.Add(new SystemMessage { Message = e.Message });
            }

            return result;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AddressItemBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public AddressItemBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyCardsJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyCardsJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
Beispiel #23
0
 public ChangePasswordApiModel(ServiceProviderResult result) : base(result)
 {
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyCardsBaseApiModel"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyCardsBaseApiModel(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AvailableStatesBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public AvailableStatesBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AvailableStatesBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public AvailableStatesBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
        /// <summary>
        /// Sets the errors.
        /// </summary>
        /// <param name="result">The result.</param>
        public void SetErrors(ServiceProviderResult result)
        {
            this.Success = result.Success;
            if (result.SystemMessages.Count <= 0)
            {
                return;
            }

            var errors = result.SystemMessages;
            foreach (var error in errors)
            {
                var message = StorefrontManager.GetSystemMessage(error.Message);
                this.Errors.Add(string.IsNullOrEmpty(message) ? error.Message : message);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateLoyaltyCardBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public UpdateLoyaltyCardBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OrdersBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public OrdersBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StockInfoListBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public StockInfoListBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AddressListItemBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public AddressListItemBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WishListBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public WishListBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 public StockInfoApiModel(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CSCartBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 public CSCartBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WishListsBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public WishListsBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GiftCardBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public GiftCardBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyRewardPointItemBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyRewardPointItemBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
     this.Transactions = new List<LoyaltyTransactionItemBaseJsonResult>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckoutDataBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public CheckoutDataBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OrderBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 public OrderBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyRewardPointItemJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyRewardPointItemJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyCardItemBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyCardItemBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
     this.RewardPoints = new List <LoyaltyRewardPointItemBaseJsonResult>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 public UserBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 public AddressListApiModel(ServiceProviderResult result) : base(result)
 {
 }
 /// <summary>
 /// Adds the basket errors to result.
 /// </summary>
 /// <param name="cart">The cart.</param>
 /// <param name="result">The result.</param>
 protected virtual void AddBasketErrorsToResult(CommerceCart cart, ServiceProviderResult result)
 {
     if (cart != null && cart.Properties["_Basket_Errors"] != null)
     {
         List<string> basketErrors = cart.Properties["_Basket_Errors"] as List<string>;
         basketErrors.ForEach(m => result.SystemMessages.Add(new SystemMessage { Message = m }));
     }
 }
Beispiel #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AddressListItemJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public AddressListItemJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangePasswordBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 public ChangePasswordBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NearbyStoresJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public NearbyStoresJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyCardItemJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyCardItemJsonResult(ServiceProviderResult result)
     : base(result)
 {
     this.Programs = new List<LoyaltyProgramItemBaseJsonResult>();
 }
Beispiel #49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyProgramItemBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyProgramItemBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckoutDataBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public CheckoutDataBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
Beispiel #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoyaltyRewardPointItemBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public LoyaltyRewardPointItemBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
     this.Transactions = new List <LoyaltyTransactionItemBaseJsonResult>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ForgotPasswordBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The result.</param>
 public ForgotPasswordBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubmitOrderBaseJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public SubmitOrderBaseJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AddressItemJsonResult"/> class.
 /// </summary>
 /// <param name="result">The service provider result.</param>
 public AddressItemJsonResult(ServiceProviderResult result)
     : base(result)
 {
 }