public ManagerResponse <GetPartiesResult, IEnumerable <Party> > GetParties(CommerceCustomer customer) { var request = new GetPartiesRequest(customer); GetPartiesResult parties = this.customerServiceProvider.GetParties(request); IEnumerable <Party> result = !parties.Success || parties.Parties == null ? new List <Party>() : parties.Parties; return(new ManagerResponse <GetPartiesResult, IEnumerable <Party> >(parties, result)); }
public ManagerResponse <GetPartiesResult, IEnumerable <IParty> > GetCustomerParties(string userName) { var result = new GetPartiesResult { Success = false }; var getUserResponse = GetUser(userName); if (!getUserResponse.ServiceProviderResult.Success || getUserResponse.Result == null) { result.SystemMessages.ToList().AddRange(getUserResponse.ServiceProviderResult.SystemMessages); return(new ManagerResponse <GetPartiesResult, IEnumerable <IParty> >(result, null)); } return(GetParties(new CommerceCustomer { ExternalId = getUserResponse.Result.ExternalId })); }
public ManagerResponse <GetPartiesResult, IEnumerable <Party> > GetCurrentCustomerParties(string shopName, string contactId) { var getPartiesResult = new GetPartiesResult(); var user = this.GetUser(contactId); if (!user.ServiceProviderResult.Success || (user.Result == null)) { return(new ManagerResponse <GetPartiesResult, IEnumerable <Party> >(getPartiesResult, null)); } var customer = new CommerceCustomer { ExternalId = user.Result.ExternalId }; return(this.GetParties(customer)); }
/// <summary> /// Gets the current user parties. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <returns>The manager response where the list of parties is returned in the response.</returns> public virtual ManagerResponse <GetPartiesResult, IEnumerable <CommerceParty> > GetCurrentUserParties([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(visitorContext, "visitorContext"); var result = new GetPartiesResult { Success = false }; var getUserResponse = this.GetUser(visitorContext.UserName); if (!getUserResponse.ServiceProviderResult.Success || getUserResponse.Result == null) { result.SystemMessages.ToList().AddRange(getUserResponse.ServiceProviderResult.SystemMessages); return(new ManagerResponse <GetPartiesResult, IEnumerable <CommerceParty> >(result, null)); } return(this.GetParties(storefront, new CommerceCustomer { ExternalId = getUserResponse.Result.ExternalId })); }
/// <summary> /// Gets the current user parties. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <returns>The manager response where the list of parties is returned in the response.</returns> public virtual ManagerResponse<GetPartiesResult, IEnumerable<CSFConnectModels.CommerceParty>> GetCurrentCustomerParties([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(visitorContext, "visitorContext"); var result = new GetPartiesResult { Success = false }; var getUserResponse = this.GetUser(visitorContext.UserName); if (!getUserResponse.ServiceProviderResult.Success || getUserResponse.Result == null) { result.SystemMessages.ToList().AddRange(getUserResponse.ServiceProviderResult.SystemMessages); return new ManagerResponse<GetPartiesResult, IEnumerable<CSFConnectModels.CommerceParty>>(result, null); } return this.GetParties(storefront, new CommerceCustomer { ExternalId = getUserResponse.Result.ExternalId }); }
public void ShouldGetAllPartiesByCustomerId() { var customerId = new Guid(); var request = new GetPartiesRequest(new CommerceCustomer() { ExternalId = customerId.ToString() }); var result = new GetPartiesResult(); var args = new ServicePipelineArgs(request, result); this._client.GetAllAddresses(customerId).Returns(new ArrayOfAddressModelResponse() { Success = true, Result = new[] { new AddressModel() { Address1 = "my address 1", Address2 = "my address 2", FirstName = "Koly", LastName = "Ivanov", City = "Vinnitsa", Company = "Sitecore", CountryThreeLetterIsoCode = "USA", CountryTwoLetterIsoCode = "US", Email = "*****@*****.**", FaxNumber = "9999", Id = "1", PhoneNumber = "043298765", ZipPostalCode = "21000" }, new AddressModel() { Address1 = "test address 1", Address2 = "test address 2", FirstName = "Ivan", LastName = "Petrovich" } } }); _processor.Process(args); result.Parties.Should().HaveCount(2); result.Success.Should().BeTrue(); result.Parties.ElementAt(0).Address1.Should().Be("my address 1"); result.Parties.ElementAt(0).Address2.Should().Be("my address 2"); result.Parties.ElementAt(0).FirstName.Should().Be("Koly"); result.Parties.ElementAt(0).LastName.Should().Be("Ivanov"); result.Parties.ElementAt(0).City.Should().Be("Vinnitsa"); result.Parties.ElementAt(0).Company.Should().Be("Sitecore"); result.Parties.ElementAt(0).Country.Should().Be("US"); result.Parties.ElementAt(0).Email.Should().Be("*****@*****.**"); result.Parties.ElementAt(0).PhoneNumber.Should().Be("043298765"); result.Parties.ElementAt(0).ZipPostalCode.Should().Be("21000"); result.Parties.ElementAt(1).Address1.Should().Be("test address 1"); result.Parties.ElementAt(1).Address2.Should().Be("test address 2"); result.Parties.ElementAt(1).FirstName.Should().Be("Ivan"); result.Parties.ElementAt(1).LastName.Should().Be("Petrovich"); }