public ManagerResponse <UpdateWishListLinesResult, WishList> UpdateWishListLines(CommerceStorefront storefront, WishList wishList, List <CartLineUpdateArgument> wishListLineUpdateArguments) { Assert.ArgumentNotNull(wishList, nameof(wishList)); Assert.ArgumentNotNull(storefront, nameof(storefront)); List <WishListLine> lineList = new List <WishListLine>(); foreach (CartLineUpdateArgument lineUpdateArgument in wishListLineUpdateArguments) { CartLineUpdateArgument inputModel = lineUpdateArgument; Assert.ArgumentNotNullOrEmpty(inputModel.ExternalLineId, "inputModel.ExternalLineId"); int quantity = (int)inputModel.LineArguments.Quantity; WishListLine wishListLine = wishList.Lines.FirstOrDefault(l => l.ExternalId == inputModel.ExternalLineId); if (wishListLine != null) { wishListLine.Quantity = quantity; lineList.Add(wishListLine); } } UpdateWishListLinesResult wishListResult = _wishListServiceProvider.UpdateWishListLines(new UpdateWishListLinesRequest(wishList, lineList)); Helpers.LogSystemMessages(wishListResult.SystemMessages, wishListResult); UpdateWishListLinesResult serviceProviderResult = wishListResult; return(new ManagerResponse <UpdateWishListLinesResult, WishList>(serviceProviderResult, serviceProviderResult.WishList)); }
// Not implemented public virtual WishListJsonResult UpdateWishListLines(IStorefrontContext storefrontContext, IVisitorContext visitorContext, string lineNumber, Decimal quantity) { Assert.ArgumentNotNull((object)storefrontContext, nameof(storefrontContext)); Assert.ArgumentNotNull((object)visitorContext, nameof(visitorContext)); Assert.ArgumentNotNull((object)lineNumber, nameof(lineNumber)); Assert.IsTrue(quantity > Decimal.Zero, "quantity > 0"); WishListJsonResult model = this.ModelProvider.GetModel <WishListJsonResult>(); CommerceStorefront currentStorefront = storefrontContext.CurrentStorefront; ManagerResponse <GetWishListResult, WishList> currentWishList = this.WishListManager.GetWishList(visitorContext, storefrontContext); if (!currentWishList.ServiceProviderResult.Success || currentWishList.Result == null) { string systemMessage = "Wish List not found."; currentWishList.ServiceProviderResult.SystemMessages.Add(new SystemMessage() { Message = systemMessage }); model.SetErrors((ServiceProviderResult)currentWishList.ServiceProviderResult); return(model); } CartLineUpdateArgument lineUpdateArgument = new CartLineUpdateArgument() { ExternalLineId = lineNumber, LineArguments = { Quantity = quantity } }; ManagerResponse <UpdateWishListLinesResult, WishList> managerResponse = this.WishListManager.UpdateWishListLines(currentStorefront, currentWishList.Result, new List <CartLineUpdateArgument>() { lineUpdateArgument }); if (!managerResponse.ServiceProviderResult.Success) { model.SetErrors((ServiceProviderResult)managerResponse.ServiceProviderResult); return(model); } model.Initialize(managerResponse.Result); model.Success = true; return(model); }