public JsonResult AddWishListsToCart(List <WishListInputModel> models) { try { Assert.ArgumentNotNull(models, "models"); var validationResult = new BaseApiModel(); this.ValidateModel(validationResult); if (validationResult.HasErrors) { return(this.Json(validationResult, JsonRequestBehavior.AllowGet)); } var wishLists = new List <WishListHeader>(); //// TODO: ADD ALL THE ITEMS ON EACH WISH LIST TO THE CART var result = new WishListsBaseApiModel(); result.Initialize(wishLists); 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("AddWishListsToCart", e), JsonRequestBehavior.AllowGet)); } }
public JsonResult AddToWishList(AddToWishListInputModel model) { try { Assert.ArgumentNotNull(model, "model"); var validationResult = new BaseApiModel(); this.ValidateModel(validationResult); if (validationResult.HasErrors) { return(this.Json(validationResult, JsonRequestBehavior.AllowGet)); } var wishLists = new List <WishListHeader>(); var response = this.WishListManager.AddLinesToWishList(this.StorefrontContext.Current, Context.User.Name, model); var result = new WishListsBaseApiModel(response.ServiceProviderResult); if (response.ServiceProviderResult.Success && response.Result != null) { wishLists = this.WishListsHeaders(result); } result.Initialize(wishLists); 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("AddToWishList", e), JsonRequestBehavior.AllowGet)); } }
public JsonResult ActiveWishLists(bool filter = false) { try { var wishLists = new List <WishListHeader>(); var userResponse = this.AccountManager.GetUser(Context.User.Name); var result = new WishListsBaseApiModel(userResponse.ServiceProviderResult); if (userResponse.ServiceProviderResult.Success && userResponse.Result != null) { wishLists = filter ? this.WishListsHeaders(result).Take(5).ToList() : this.WishListsHeaders(result); } result.Initialize(wishLists); 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("ActiveWishLists", e), JsonRequestBehavior.AllowGet)); } }
/// <summary> /// The wish lists headers. /// </summary> /// <param name="result"> /// The result. /// </param> /// <returns> /// The <see cref="List"/>. /// </returns> private List <WishListHeader> WishListsHeaders(WishListsBaseApiModel result) { var response = this.WishListManager.GetWishLists(this.StorefrontContext.Current, Context.User.Name); var wishLists = new List <WishListHeader>(); if (response.ServiceProviderResult.Success && response.Result != null) { wishLists = response.Result.ToList(); } return(wishLists); }