public ManagerResponse <CustomerPartiesResult, IEnumerable <CustomerParty> > UpdateCustomerParties(CommerceCustomer customer, IEnumerable <CustomerParty> parties) { Assert.ArgumentNotNull(customer, nameof(customer)); Assert.ArgumentNotNull(parties, nameof(parties)); var updateCustomerPartiesRequest = new UpdateCustomerPartiesRequest(customer, parties.ToList()); CustomerPartiesResult updateCustomerPartiesResult = this.customerServiceProvider.UpdateCustomerParties(updateCustomerPartiesRequest); return(new ManagerResponse <CustomerPartiesResult, IEnumerable <CustomerParty> >(updateCustomerPartiesResult, null)); }
public void ShouldHandleInvalidCustomerId() { var request = new RemovePartiesRequest( new CommerceCustomer { ExternalId = "1234" }, new List <Party>(0) ); var result = new CustomerPartiesResult(); var args = new ServicePipelineArgs(request, result); _processor.Process(args); result.Success.Should().Be(false); result.SystemMessages.Should().HaveCount(x => x > 0); }
public void ShouldCallServiceWithCorrectArgs() { var customerId = Guid.NewGuid(); var request = new RemovePartiesRequest( new CommerceCustomer { ExternalId = customerId.ToString() }, new List <Party> { new Party(), new Party() } ); var result = new CustomerPartiesResult(); var args = new ServicePipelineArgs(request, result); _processor.Process(args); _client.Received().RemoveAddresses(Arg.Is(customerId), Arg.Any <string[]>()); }
/// <summary> /// Processes the arguments. /// </summary> /// <param name="args">The pipeline arguments.</param> public override void Process(ServicePipelineArgs args) { Assert.ArgumentNotNull(args, "args"); RemoveCustomerPartiesRequest request = (RemoveCustomerPartiesRequest)args.Request; CustomerPartiesResult result = (CustomerPartiesResult)args.Result; //- there is no RemovePartiesResult in Services.Customers using (ICustomersServiceChannel channel = this.GetClient()) { Guid customerId; try { customerId = new Guid(request.CommerceCustomer.ExternalId); } catch { customerId = Guid.Empty; } var addressIds = request.Parties.Select(party => party.ExternalId).ToArray(); //var nopResult = channel.RemoveCustomerAddressesByCusomerId(customerId, addressIds.ToArray()); //if (nopResult.Success) //{ // request.Properties.Add("UserId", customerId); // result.Success = true; // result.SystemMessages.Add(new SystemMessage { Message = "Successfully added parties to Nop Commerce System" }); //} //else //{ // result.Success = false; // result.SystemMessages.Add(new SystemMessage { Message = "Error occuder while adding parties to Cusomer " + request.CommerceCustomer.ExternalId }); //} } }