public ActionResult UpdateLineItem(WishListLineInputModel model) { try { Assert.ArgumentNotNull(model, "model"); var validationResult = new BaseJsonResult(); this.ValidateModel(validationResult); if (validationResult.HasErrors) { return(Json(validationResult, JsonRequestBehavior.AllowGet)); } var response = this.WishListManager.UpdateWishListLine(this.CurrentStorefront, this.CurrentVisitorContext, model); var result = new WishListBaseJsonResult(response.ServiceProviderResult); if (response.ServiceProviderResult.Success && response.Result != null) { this.WishList(model.WishListId, result); } return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception e) { CommerceLog.Current.Error("UpdateLineItem", this, e); return(Json(new BaseJsonResult("UpdateLineItem", e), JsonRequestBehavior.AllowGet)); } }
public ActionResult UpdateLineItem(WishListLineInputModel model) { try { Assert.ArgumentNotNull(model, "model"); var validationResult = new BaseApiModel(); this.ValidateModel(validationResult); if (validationResult.HasErrors) { return(this.Json(validationResult, JsonRequestBehavior.AllowGet)); } var response = this.WishListManager.UpdateWishListLine(this.StorefrontContext.Current, Context.User.Name, model); var result = new WishListBaseApiModel(response.ServiceProviderResult); if (response.ServiceProviderResult.Success && response.Result != null) { this.WishList(model.WishListId, result); } return(this.Json(result, JsonRequestBehavior.AllowGet)); } catch (Sitecore.Commerce.OpenIDConnectionClosedUnexpectedlyException e) { this.CleanNotAuthorizedSession(); return(this.Json(new ErrorApiModel("Login", e), JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(this.Json(new ErrorApiModel("UpdateLineItem", e), JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Updates a single wish list line. /// </summary> /// <param name="storefront">The storefront.</param> /// <param name="visitorContext">The visitor context.</param> /// <param name="model">The model.</param> /// <returns>The manager response with the updated wish list as the result.</returns> public virtual ManagerResponse <UpdateWishListLinesResult, WishList> UpdateWishListLine([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, [NotNull] WishListLineInputModel model) { Assert.ArgumentNotNull(storefront, "storefront"); Assert.ArgumentNotNull(visitorContext, "visitorContext"); Assert.ArgumentNotNull(model, "model"); Assert.ArgumentNotNullOrEmpty(model.WishListId, "model.WishListId"); Assert.ArgumentNotNullOrEmpty(model.ProductId, "model.ProductId"); var wishListLine = new WishListLine { Product = new CommerceCartProduct { ProductId = model.ProductId, ProductVariantId = model.VariantId }, Quantity = model.Quantity }; return(this.UpdateWishListLines(storefront, visitorContext, model.WishListId, new List <WishListLine> { wishListLine })); }