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); } }
private void WishList(string wishListId, WishListBaseJsonResult result) { var response = this.WishListManager.GetWishList(this.CurrentStorefront, this.CurrentVisitorContext, wishListId); var wishList = new WishList(); if (response.ServiceProviderResult.Success && response.Result != null) { wishList = response.Result; } result.Initialize(wishList); result.SetErrors(response.ServiceProviderResult); }
public JsonResult GetWishList(WishListInputModel model) { try { Assert.ArgumentNotNull(model, "model"); var validationResult = new BaseJsonResult(); this.ValidateModel(validationResult); if (validationResult.HasErrors) { return Json(validationResult, JsonRequestBehavior.AllowGet); } var userResponse = this.AccountManager.GetUser(Context.User.Name); var result = new WishListBaseJsonResult(userResponse.ServiceProviderResult); if (userResponse.ServiceProviderResult.Success && userResponse.Result != null) { this.WishList(model.ExternalId, result); } return Json(result, JsonRequestBehavior.AllowGet); } catch (Exception e) { CommerceLog.Current.Error("GetWishList", this, e); return Json(new BaseJsonResult("GetWishList", e), JsonRequestBehavior.AllowGet); } }