/// <summary> /// Removes the wish list lines. /// </summary> /// <param name="storefront"> /// The storefront. /// </param> /// <param name="userId"> /// The user Id. /// </param> /// <param name="wishListId"> /// The wish list identifier. /// </param> /// <param name="models"> /// The models. /// </param> /// <returns> /// The manager response with the wish list as the result. /// </returns> public virtual ManagerResponse <RemoveWishListLinesResult, WishList> RemoveWishListLines([NotNull] CommerceStorefront storefront, [NotNull] string userId, string wishListId, IEnumerable <WishListLineInputModel> models) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(models, "models"); Assert.ArgumentNotNullOrEmpty(wishListId, "wishListId"); var productIds = models.Select(model => string.IsNullOrEmpty(model.VariantId) ? model.ProductId : model.VariantId).ToList(); var request = new RemoveWishListLinesRequest(new WishList { UserId = userId, CustomerId = userId, ExternalId = wishListId, ShopName = storefront.ShopName }, productIds); var result = this.WishListServiceProvider.RemoveWishListLines(request); result.WriteToSitecoreLog(); return(new ManagerResponse <RemoveWishListLinesResult, WishList>(result, result.WishList)); }
/// <summary> /// Removes the wish list lines. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <param name="wishListId">The wish list identifier.</param> /// <param name="models">The models.</param> /// <returns>The manager response with the wish list as the result.</returns> public virtual ManagerResponse <RemoveWishListLinesResult, WishList> RemoveWishListLines([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, string wishListId, IEnumerable <WishListLineInputModel> models) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(visitorContext, "visitorContext"); Assert.ArgumentNotNull(models, "models"); Assert.ArgumentNotNullOrEmpty(wishListId, "wishListId"); var productIds = models.Select(model => string.IsNullOrEmpty(model.VariantId) ? model.ProductId : model.VariantId).ToList(); var request = new RemoveWishListLinesRequest(new WishList { UserId = visitorContext.UserId, CustomerId = visitorContext.UserId, ExternalId = wishListId, ShopName = storefront.ShopName }, productIds); var result = this.WishListServiceProvider.RemoveWishListLines(request); if (!result.Success) { Helpers.LogSystemMessages(result.SystemMessages, result); } return(new ManagerResponse <RemoveWishListLinesResult, WishList>(result, result.WishList)); }
/// <summary> /// Initializes a new instance of the <see cref="RemoveWishlistLinesTest"/> class. /// </summary> public RemoveWishlistLinesTest() { this.visitorId = Guid.NewGuid(); this.lineToRemove = new WishListLine() { ExternalId = "10", Product = new CartProduct { ProductId = "100500", Price = new Price { Amount = 100 } }, Quantity = 12 }; this.wishlist = new WishList { ExternalId = this.visitorId.ToString(), Lines = new ReadOnlyCollection <WishListLine>(new List <WishListLine> { this.lineToRemove }) }; this.request = new RemoveWishListLinesRequest(this.wishlist, new List <string> { "10" }); this.result = new RemoveWishListLinesResult(); this.args = new ServicePipelineArgs(this.request, this.result); this.client = Substitute.For <IWishlistsServiceChannel>(); var clientFactory = Substitute.For <ServiceClientFactory>(); clientFactory.CreateClient <IWishlistsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client); this.processor = new RemoveWishlistLines { ClientFactory = clientFactory }; }
/// <summary> /// Removes the wish list lines. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <param name="wishListId">The wish list identifier.</param> /// <param name="models">The models.</param> /// <returns> /// The manager response with the wish list as the result. /// </returns> public virtual ManagerResponse<RemoveWishListLinesResult, WishList> RemoveWishListLines([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, string wishListId, IEnumerable<WishListLineInputModel> models) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(visitorContext, "visitorContext"); Assert.ArgumentNotNull(models, "models"); Assert.ArgumentNotNullOrEmpty(wishListId, "wishListId"); var lineIds = models.Select(model => model.ExternalLineId).ToList(); var request = new RemoveWishListLinesRequest(new WishList { UserId = visitorContext.UserId, CustomerId = visitorContext.UserId, ExternalId = wishListId, ShopName = storefront.ShopName }, lineIds); var result = this.WishListServiceProvider.RemoveWishListLines(request); if (!result.Success) { Helpers.LogSystemMessages(result.SystemMessages, result); } return new ManagerResponse<RemoveWishListLinesResult, WishList>(result, result.WishList); }