public ActionResult Wishlist() { if (_sessionContext.CurrentUser == null) { return(RedirectToAction("SignIn")); } var customerId = _sessionContext.CurrentUser.UserId.ToString(); var key = string.Format(CacheKeys.WishList, customerId); if (System.Web.HttpContext.Current.Session[key] != null) { return(View(CustomViews.WISHLIST, System.Web.HttpContext.Current.Session[key])); } var result = _customerRepository.GetWishlist(customerId, false); System.Web.HttpContext.Current.Session[key] = result.Result; foreach (var res in result.Result) { res.SeoName = String.IsNullOrEmpty(res.SeoName) ? res.Name.ToSeo() : res.SeoName; } return(View(CustomViews.WISHLIST, result.Result)); }
public ActionResult BasketToWishlist(List <BasketAddModel> model) { var maximumWishlistItems = _sessionContext.CurrentSiteConfig.BasketSettings.MaximumWishlistItems; var custId = _sessionContext.CurrentUser.UserId.ToString(); var getWishlist = _customerRepository.GetWishlist(custId, false); if (getWishlist != null && getWishlist.Result.Count < maximumWishlistItems) { var response = new ResponseModel <bool>(); foreach (var product in model) { response = _customerRepository.AddProductToWishList(Sanitizer.GetSafeHtmlFragment(product.ProductId.ToLower()), _sessionContext.CurrentUser.UserId, false); } var customerId = _sessionContext.CurrentUser.UserId.ToString(); var key = string.Format(CacheKeys.WishList, customerId); var result = _customerRepository.GetWishlist(customerId, false); System.Web.HttpContext.Current.Session[key] = result.Result; return(JsonSuccess(response.Result, JsonRequestBehavior.AllowGet)); } else { return(JsonSuccess(false, JsonRequestBehavior.AllowGet)); } }
protected CheckoutViewModel GetCheckoutData(string basketId) { var response = _checkoutApi.Checkout(Sanitizer.GetSafeHtmlFragment(basketId)); var checkout = response.Result; if (checkout == null || checkout.BasketId == null || checkout.Basket == null || checkout.Basket.LineItems.Count < 1) { return(null); } foreach (var pay in checkout.PaymentOptions) { pay.CardInfo.Amount = checkout.BalanceAmount.Raw.WithTax; } checkout.LanuguageCode = _sessionContext.CurrentSiteConfig.RegionalSettings.DefaultLanguageCulture; checkout.CurrencyCode = _sessionContext.CurrentSiteConfig.RegionalSettings.DefaultCurrencyCode; var result = _configApi.GetConfig(); var data = result.Result; //checkout.Basket.shippingMethods = 0 is simpl check this implementation later data.ShippingCountries = data.ShippingCountries.Where(x => checkout.Basket.shippingMethods.Any(y => y.CountryCode == x.TwoLetterIsoCode) || checkout.Basket.shippingMethods.Count() == 0).Distinct().ToList(); var model = new CheckoutViewModel { Checkout = checkout, Register = new RegistrationModel(), Login = new LoginViewModel(), BillingCountries = data.BillingCountries, ShippingCountries = data.ShippingCountries, CurrentDate = DateTime.Today.Date.AddDays(1) }; if (_sessionContext.CurrentUser == null) { model.RegistrationPrompt = Convert.ToBoolean(_sessionContext.CurrentSiteConfig.BasketSettings.RegistrationPrompt); } string returnUrl = string.Empty; //So that the user can be referred back to where they were when they click logon if (Request.UrlReferrer != null) { returnUrl = Server.UrlEncode(Request.UrlReferrer.PathAndQuery); } //if (Url.IsLocalUrl(returnUrl) && !string.IsNullOrEmpty(returnUrl)) if (!string.IsNullOrEmpty(returnUrl)) { TempData["ReturnURL"] = returnUrl; } if (_sessionContext.CurrentUser == null) { if (Guid.Parse(checkout.CustomerId) != Guid.Empty) { var customerresult = _customerRepository.GetUserdetailsById <CustomerDetailModel>(checkout.CustomerId); if (customerresult != null) { checkout.Email = customerresult.Result.Email; checkout.CompanyId = customerresult.Result.CompanyId; } } else { _checkoutApi.UpdateUserToBasket(checkout.BasketId, Guid.Empty.ToString()); checkout.Stage = BasketStage.Anonymous.GetHashCode(); } SetDataLayerVariables(response.Result?.Basket, WebhookEventTypes.CheckoutStarted); return(model); } model.Checkout.CustomerId = _sessionContext.CurrentUser.UserId.ToString(); model.Checkout.Email = _sessionContext.CurrentUser.Email; var WishlistResponse = _customerRepository.GetWishlist(model.Checkout.CustomerId, true); model.Checkout.WishlistProducts = WishlistResponse.Result; SetDataLayerVariables(response.Result?.Basket, WebhookEventTypes.CheckoutStarted); return(model); }