Exemplo n.º 1
0
        public virtual async Task <IHttpActionResult> UpdateCart(UpdateCartRequest updateCartRequest)
        {
            if (updateCartRequest == null)
            {
                return(BadRequest("updateCartRequest is required"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var getCartUrlParam = new BaseUrlParameter
            {
                CultureInfo = ComposerContext.CultureInfo
            };

            var checkoutStepInfos = CartUrlProvider.GetCheckoutStepPageInfos(getCartUrlParam);

            var nextStepUrl = CartUrlProvider.GetCheckoutStepUrl(new GetCheckoutStepUrlParam
            {
                CultureInfo = ComposerContext.CultureInfo,
                StepNumber  = updateCartRequest.CurrentStep.GetValueOrDefault() + 1
            });

            var getCartParam = new GetCartParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                CartName    = CartConfiguration.ShoppingCartName,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
            };

            var updateCheckoutCartParam = new UpdateCheckoutCartParam
            {
                GetCartParam = getCartParam,
                CurrentStep  = updateCartRequest.CurrentStep.GetValueOrDefault(),
                IsGuest      = ComposerContext.IsGuest,
                UpdateValues = updateCartRequest.UpdatedCart
            };

            var homepageUrl = GetHomepageUrl();

            var updateCartResultViewModel = await CheckoutService.UpdateCheckoutCartAsync(updateCheckoutCartParam);

            SetHomepageUrl(updateCartResultViewModel.Cart, homepageUrl);
            SetEditCartUrl(updateCartResultViewModel.Cart);

            if (updateCartResultViewModel.Cart.OrderSummary != null)
            {
                updateCartResultViewModel.Cart.OrderSummary.CheckoutStepUrls = checkoutStepInfos.Values.Select(x => x.Url).ToList();
            }

            if (!updateCartResultViewModel.HasErrors)
            {
                updateCartResultViewModel.NextStepUrl = nextStepUrl;
            }

            return(Ok(updateCartResultViewModel));
        }
Exemplo n.º 2
0
        public virtual async Task <IHttpActionResult> GetCart()
        {
            var cartViewModel = await CartService.GetCartViewModelAsync(new GetCartParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                CartName    = CartConfiguration.ShoppingCartName,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
            });

            if (cartViewModel.OrderSummary != null)
            {
                try
                {
                    if (cartViewModel.IsCartEmpty)
                    {
                        cartViewModel.OrderSummary.CheckoutRedirectAction.RedirectUrl = GetCartUrl();
                    }
                    else
                    {
                        //If the cart contains recurring items and user is not authenticated, redirect to sign in
                        if (RecurringOrdersSettings.Enabled && cartViewModel.HasRecurringLineitems && !ComposerContext.IsAuthenticated)
                        {
                            cartViewModel.OrderSummary.CheckoutRedirectAction.RedirectUrl = GetCheckoutSignInUrl();
                        }
                    }
                }
                catch (ArgumentException e) {
                    Log.Error(e.ToString());
                };
            }

            return(Ok(cartViewModel));
        }
Exemplo n.º 3
0
        public virtual async Task <IHttpActionResult> RemoveLineItem(RemoveLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (!ComposerContext.IsAuthenticated)
            {
                return(BadRequest("Authorization required"));
            }

            var vm = await WishListViewService.RemoveLineItemAsync(new RemoveLineItemParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                LineItemId  = new Guid(request.LineItemId),
                CartName    = CartConfiguration.WishlistCartName,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            });

            return(Ok(vm));
        }
Exemplo n.º 4
0
        public async Task <CategoryBrowsingViewModel> GetCategoryAvailableProductsAsync(GetBrowseCategoryParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            if (ViewModel != null)
            {
                return(ViewModel);
            }

            ViewModel = await CategoryBrowsingViewService.GetCategoryBrowsingViewModelAsync(new GetCategoryBrowsingViewModelParam
            {
                CategoryId           = param.CategoryId,
                CategoryName         = await GetCategoryNameAsync(param.CategoryId),
                BaseUrl              = RequestUtils.GetBaseUrl(param.Request).ToString(),
                IsAllProducts        = CategoryMetaContext.GetIsAllProductPage(),
                Page                 = param.Page,
                SortBy               = param.SortBy,
                SortDirection        = param.SortDirection,
                InventoryLocationIds = await InventoryLocationProvider.GetInventoryLocationIdsForSearchAsync(),
                SelectedFacets       = SearchUrlProvider.BuildSelectedFacets(param.Request.QueryString).ToList(),
                CultureInfo          = ComposerContext.CultureInfo,
            }).ConfigureAwait(false);

            return(ViewModel);
        }
Exemplo n.º 5
0
        public virtual async Task <IHttpActionResult> UpdateCart(UpdateCartRequest updateCartRequest)
        {
            if (updateCartRequest == null)
            {
                return(BadRequest("updateCartRequest is required"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var getCartParam = new GetCartParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                CartName    = CartConfiguration.ShoppingCartName,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
            };

            var updateCheckoutCartParam = new UpdateCheckoutCartParam
            {
                GetCartParam = getCartParam,
                CurrentStep  = updateCartRequest.CurrentStep.GetValueOrDefault(),
                IsGuest      = ComposerContext.IsGuest,
                UpdateValues = updateCartRequest.UpdatedCart
            };

            var updateCartResultViewModel = await CheckoutService.UpdateCheckoutCartAsync(updateCheckoutCartParam);

            return(Ok(updateCartResultViewModel));
        }
Exemplo n.º 6
0
        public virtual ActionResult Breadcrumb(string storeNumber)
        {
            if (string.IsNullOrEmpty(storeNumber))
            {
                return(View());
            }
            var breadcrumbViewModel = BreadcrumbViewService.CreateBreadcrumbViewModel(new GetBreadcrumbParam
            {
                CurrentPageId = SitemapNavigator.CurrentPageId.ToString(),
                CultureInfo   = ComposerContext.CultureInfo
            });
            var model = StoreViewService.GetStoreViewModelAsync(new GetStoreByNumberParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                StoreNumber = storeNumber,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
            }).Result;

            if (model == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            if (!string.IsNullOrEmpty(model.LocalizedDisplayName))
            {
                breadcrumbViewModel.ActivePageName = model.LocalizedDisplayName;
            }

            return(View(breadcrumbViewModel));
        }
        protected virtual string GetStoreCanonicalUrl(GetStorePageHeaderViewModelParam param, StoreViewModel store)
        {
            var relativeUri = StoreUrlProvider.GetStoreUrl(new GetStoreUrlParam
            {
                BaseUrl     = param.BaseUrl,
                CultureInfo = param.CultureInfo,
                StoreNumber = param.StoreNumber,
                StoreName   = store.Name
            });

            if (HttpContext.Current == null)
            {
                Log.Error("HttpContext.Current is null");

                return(relativeUri);
            }

            try
            {
                var baseUri = RequestUtils.GetBaseUrl(HttpContext.Current.Request.Url);

                var url = new Uri(baseUri, relativeUri);

                return(url.ToString());
            }
            catch (Exception ex)
            {
                string fullStackTrace = ex.StackTrace + Environment.StackTrace;
                Log.Error($"Error retrieving store canonical url. Exception : {ex}, {fullStackTrace}");

                return(relativeUri);
            }
        }
Exemplo n.º 8
0
        public virtual async Task <IHttpActionResult> CompleteCheckout(CompleteCheckoutRequest request)
        {
            if (request == null)
            {
                return(BadRequest("No request body found."));
            }

            var nextStepUrl = CartUrlProvider.GetCheckoutStepUrl(new GetCheckoutStepUrlParam
            {
                CultureInfo = ComposerContext.CultureInfo,
                StepNumber  = request.CurrentStep + 1
            });

            var checkoutViewModel = await CheckoutService.CompleteCheckoutAsync(new CompleteCheckoutParam
            {
                CartName    = CartConfiguration.ShoppingCartName,
                CustomerId  = ComposerContext.CustomerId,
                CultureInfo = ComposerContext.CultureInfo,
                Scope       = ComposerContext.Scope,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
            });

            checkoutViewModel.NextStepUrl = nextStepUrl;

            return(Ok(checkoutViewModel));
        }
Exemplo n.º 9
0
        protected virtual string GetCanonicalUrl(GetPageHeaderParam param, ProductViewModel product)
        {
            var relativeUri = ProductUrlProvider.GetProductUrl(new GetProductUrlParam
            {
                CultureInfo = param.CultureInfo,
                ProductId   = param.ProductId,
                ProductName = product.DisplayName,
                SKU         = product.Sku
            });

            if (HttpContext.Current == null)
            {
                Log.Error("HttpContext.Current is null");

                return(relativeUri);
            }

            try
            {
                var baseUri = RequestUtils.GetBaseUrl(HttpContext.Current.Request.Url);

                var url = new Uri(baseUri, relativeUri);

                return(url.ToString());
            }
            catch (Exception ex)
            {
                string fullStackTrace = ex.StackTrace + Environment.StackTrace;
                Log.Error($"Error retrieving product canonical url. Exception : {ex}, {fullStackTrace}");

                return(relativeUri);
            }
        }
Exemplo n.º 10
0
        public virtual async Task <IHttpActionResult> UpdateBillingAddress(UpdateBillingAddressViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("No body was found on the request."));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var checkoutUrl = GetCheckoutUrl();
            var homepageUrl = GetHomepageUrl();

            var vm = await CartService.UpdateBillingAddressPostalCodeAsync(new UpdateBillingAddressPostalCodeParam
            {
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                CartName    = CartConfiguration.ShoppingCartName,
                CountryCode = ComposerContext.CountryCode,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                PostalCode  = request.PostalCode,
                Scope       = ComposerContext.Scope
            });

            SetCheckoutUrl(vm, checkoutUrl);
            SetHomepageUrl(vm, homepageUrl);
            SetEditCartUrl(vm);

            return(Ok(vm));
        }
Exemplo n.º 11
0
        public virtual async Task <IHttpActionResult> RemoveCouponAsync(CouponRequest request)
        {
            if (request == null)
            {
                return(BadRequest("No request found."));
            }

            var checkoutUrl = GetCheckoutUrl();
            var homepageUrl = GetHomepageUrl();

            var vm = await CouponViewService.RemoveCouponAsync(new CouponParam
            {
                CartName    = CartConfiguration.ShoppingCartName,
                Scope       = ComposerContext.Scope,
                CouponCode  = request.CouponCode,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            });

            SetCheckoutUrl(vm, checkoutUrl);
            SetHomepageUrl(vm, homepageUrl);
            SetEditCartUrl(vm);

            return(Ok(vm));
        }
Exemplo n.º 12
0
        public virtual async Task <IHttpActionResult> RemoveLineItem(RemoveLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var checkoutUrl = GetCheckoutUrl();
            var homepageUrl = GetHomepageUrl();

            var vm = await CartService.RemoveLineItemAsync(new RemoveLineItemParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                LineItemId  = new Guid(request.LineItemId),
                CartName    = CartConfiguration.ShoppingCartName,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            });

            SetCheckoutUrl(vm, checkoutUrl);
            SetHomepageUrl(vm, homepageUrl);
            SetEditCartUrl(vm);

            return(Ok(vm));
        }
Exemplo n.º 13
0
        public virtual async Task <IHttpActionResult> AddLineItem(AddLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var checkoutUrl = GetCheckoutUrl();
            var homepageUrl = GetHomepageUrl();

            var vm = await CartService.AddLineItemAsync(new AddLineItemParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                CartName    = CartConfiguration.ShoppingCartName,
                ProductId   = request.ProductId,
                VariantId   = request.VariantId,
                Quantity    = request.Quantity.GetValueOrDefault(),
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                RecurringOrderFrequencyName = request.RecurringOrderFrequencyName,
                RecurringOrderProgramName   = request.RecurringOrderProgramName
            });

            SetCheckoutUrl(vm, checkoutUrl);
            SetHomepageUrl(vm, homepageUrl);
            SetEditCartUrl(vm);

            return(Ok(vm));
        }
Exemplo n.º 14
0
        public virtual async Task <IHttpActionResult> SetShippingMethod(SetShippingMethodViewModel request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var checkoutUrl = GetCheckoutUrl();
            var homepageUrl = GetHomepageUrl();

            if (!request.UseCheapest)
            {
                return(new StatusCodeResult(HttpStatusCode.NotImplemented, this));
            }

            var vm = await ShippingMethodService.SetCheapestShippingMethodAsync(new SetCheapestShippingMethodParam
            {
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                CartName    = CartConfiguration.ShoppingCartName,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                Scope       = ComposerContext.Scope
            });

            SetCheckoutUrl(vm, checkoutUrl);
            SetHomepageUrl(vm, homepageUrl);
            SetEditCartUrl(vm);

            return(Ok(vm));
        }
Exemplo n.º 15
0
        public virtual ActionResult CheckoutSignInAsGuest()
        {
            var checkoutUrl = UrlProvider.GetCheckoutPageUrl(new BaseUrlParameter
            {
                CultureInfo = ComposerContext.CultureInfo
            });

            var registerUrl = MyAccountUrlProvider.GetCreateAccountUrl(new BaseUrlParameter
            {
                CultureInfo = ComposerContext.CultureInfo,
                ReturnUrl   = checkoutUrl
            });

            var cart = CartService.GetCartViewModelAsync(new GetCartParam()
            {
                BaseUrl         = RequestUtils.GetBaseUrl(Request).ToString(),
                CartName        = CartConfiguration.ShoppingCartName,
                CultureInfo     = ComposerContext.CultureInfo,
                CustomerId      = ComposerContext.CustomerId,
                ExecuteWorkflow = true,
                Scope           = ComposerContext.Scope
            }).Result;

            var hasRecurringItems = cart.HasRecurringLineitems;

            var checkoutSignInAsGuestViewModel = new CheckoutSignInAsGuestViewModel
            {
                CheckoutUrlTarget = checkoutUrl,
                RegisterUrl       = registerUrl,
                IsCartContainsRecurringLineitems = hasRecurringItems
            };

            return(View("CheckoutSignInAsGuest", checkoutSignInAsGuestViewModel));
        }
Exemplo n.º 16
0
        public virtual async Task <IHttpActionResult> UpdateRecurringOrderCartAddress([FromBody] UpdateRecurringOrderCartAddressRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (request.ShippingAddressId == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var param = new UpdateRecurringOrderCartShippingAddressParam()
            {
                CultureInfo                  = ComposerContext.CultureInfo,
                ScopeId                      = ComposerContext.Scope,
                CartName                     = request.cartName,
                CustomerId                   = ComposerContext.CustomerId,
                ShippingAddressId            = request.ShippingAddressId.ToGuid(),
                BaseUrl                      = RequestUtils.GetBaseUrl(Request).ToString(),
                UseSameForShippingAndBilling = request.UseSameForShippingAndBilling
            };

            if (!string.IsNullOrEmpty(request.BillingAddressId))
            {
                param.BillingAddressId = request.BillingAddressId.ToGuid();
            }

            var results = await RecurringOrderCartsService.UpdateRecurringOrderCartShippingAddressAsync(param).ConfigureAwait(false);

            return(Ok(results));
        }
        protected virtual GetSearchQueryViewModelParams BuildParameters(string queryName, int page, string sortBy, string sortDirection, int maxItemsPerPage)
        {
            var searchCriteria = new SearchCriteria
            {
                NumberOfItemsPerPage = maxItemsPerPage,
                IncludeFacets        = true,
                StartingIndex        = (page - 1) * maxItemsPerPage,
                SortBy               = sortBy,
                SortDirection        = sortDirection,
                Page                 = page,
                BaseUrl              = RequestUtils.GetBaseUrl(Request).ToString(),
                CultureInfo          = ComposerContext.CultureInfo,
                Scope                = ComposerContext.Scope,
                InventoryLocationIds = GetInventoryLocationIds()
            };

            searchCriteria.SelectedFacets.AddRange(SearchUrlProvider.BuildSelectedFacets(Request.QueryString));

            var param = new GetSearchQueryViewModelParams
            {
                Criteria             = searchCriteria,
                QueryName            = queryName,
                QueryType            = QueryType,
                InventoryLocationIds = GetInventoryLocationIds(),
            };

            return(param);
        }
Exemplo n.º 18
0
        public virtual async Task <IHttpActionResult> UpdateRecurringCartShippingMethod([FromBody] UpdateRecurringCartShippingMethodRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (request.ShippingProviderId == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (request.ShippingMethodName == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var results = await ShippingMethodViewService.UpdateRecurringOrderCartShippingMethodAsync(new UpdateRecurringOrderCartShippingMethodParam
            {
                CartName           = request.CartName,
                CultureInfo        = ComposerContext.CultureInfo,
                CustomerId         = ComposerContext.CustomerId,
                Scope              = ComposerContext.Scope,
                BaseUrl            = RequestUtils.GetBaseUrl(Request).ToString(),
                ShippingMethodName = request.ShippingMethodName,
                ShippingProviderId = request.ShippingProviderId
            }).ConfigureAwait(false);

            return(Ok(results));
        }
Exemplo n.º 19
0
        public virtual ActionResult LanguageSwitch(string storeNumber)
        {
            var baseUrl = RequestUtils.GetBaseUrl(Request).ToString();

            if (storeNumber == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var storeViewModel = StoreViewService.GetStoreViewModelAsync(new GetStoreByNumberParam
            {
                BaseUrl          = baseUrl,
                CultureInfo      = ComposerContext.CultureInfo,
                Scope            = ComposerContext.Scope,
                IncludeAddresses = false,
                IncludeSchedules = false,
                StoreNumber      = storeNumber
            }).Result;

            if (storeViewModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            var languageSwitchViewModel = LanguageSwitchService.GetViewModel(cultureInfo => BuildUrl(
                                                                                 baseUrl,
                                                                                 cultureInfo,
                                                                                 storeViewModel.LocalizedDisplayNames[cultureInfo.Name],
                                                                                 storeViewModel.Number),
                                                                             ComposerContext.CultureInfo);

            return(View("LanguageSwitch", languageSwitchViewModel));
        }
Exemplo n.º 20
0
        public virtual async Task <IHttpActionResult> UpdateRecurringCartPaymentMethod([FromBody] UpdateRecurringCartPaymentMethodRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Request cannot be null."));
            }

            var param = new GetPaymentProvidersParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo
            };

            var providers = await PaymentViewService.GetPaymentProvidersAsync(param).ConfigureAwait(false);

            var vm = await PaymentViewService.UpdateRecurringOrderCartPaymentMethodAsync(new UpdatePaymentMethodParam
            {
                CartName            = request.CartName,
                CultureInfo         = ComposerContext.CultureInfo,
                CustomerId          = ComposerContext.CustomerId,
                PaymentId           = request.PaymentId.GetValueOrDefault(),
                Scope               = ComposerContext.Scope,
                PaymentMethodId     = request.PaymentMethodId.GetValueOrDefault(),
                PaymentProviderName = request.PaymentProviderName,
                PaymentType         = request.PaymentType,
                ProviderNames       = providers.Select(p => p.ProviderName).ToList(),
                IsAuthenticated     = ComposerContext.IsAuthenticated
            }, RequestUtils.GetBaseUrl(Request).ToString());

            return(Ok(vm));
        }
Exemplo n.º 21
0
        public virtual async Task <CategoryBrowsingViewModel> GetViewModelAsync()
        {
            if (_viewModel != null)
            {
                return(_viewModel);
            }
            var categoryId = CategoryMetaContext.GetCategoryId();

            _viewModel = await CategoryBrowsingViewService.GetCategoryBrowsingViewModelAsync(new GetCategoryBrowsingViewModelParam
            {
                CategoryId           = categoryId,
                CategoryName         = await GetCategoryNameAsync(categoryId).ConfigureAwait(false),
                BaseUrl              = RequestUtils.GetBaseUrl(Request).ToString(),
                IsAllProducts        = CategoryMetaContext.GetIsAllProductPage(),
                NumberOfItemsPerPage = SearchConfiguration.MaxItemsPerPage,
                Page                 = CurrentPage,
                SortBy               = SortBy,
                SortDirection        = SortDirection,
                InventoryLocationIds = await InventoryLocationProvider.GetInventoryLocationIdsForSearchAsync().ConfigureAwait(false),
                SelectedFacets       = SearchUrlProvider.BuildSelectedFacets(Request.QueryString).ToList(),
                CultureInfo          = ComposerContext.CultureInfo,
            }).ConfigureAwait(false);

            return(_viewModel);
        }
        public virtual async Task <IHttpActionResult> UpdateRecurringOrderTemplateLineItem(UpdateRecurringOrderTemplateLineItemRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var results = await RecurringOrderTemplatesViewService.UpdateRecurringOrderTemplateLineItemAsync(new UpdateRecurringOrderTemplateLineItemParam {
                ScopeId     = ComposerContext.Scope,
                CustomerId  = ComposerContext.CustomerId,
                CultureInfo = ComposerContext.CultureInfo,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),

                BillingAddressId            = request.BillingAddressId,
                LineItemId                  = request.LineItemId,
                NextOccurence               = request.NextOccurence,
                PaymentMethodId             = request.PaymentMethodId,
                RecurringOrderFrequencyName = request.RecurringOrderFrequencyName,
                ShippingAddressId           = request.ShippingAddressId,
                ShippingMethodName          = request.ShippingMethodName,
                ShippingProviderId          = request.ShippingProviderId
            }).ConfigureAwait(false);

            return(Ok(results));
        }
        public virtual async Task <IHttpActionResult> ChangePasswordAsync(ChangePasswordRequest changePasswordRequest)
        {
            if (changePasswordRequest == null)
            {
                return(BadRequest("No body found in the request"));
            }
            if (!ComposerContext.IsAuthenticated)
            {
                return(Unauthorized());
            }

            var returnUrl = changePasswordRequest.ReturnUrl;

            if (!UrlFormatter.IsReturnUrlValid(RequestUtils.GetBaseUrl(Request).ToString(), returnUrl))
            {
                returnUrl = null;
            }

            var changePasswordViewModel = await MembershipViewService.ChangePasswordAsync(new ChangePasswordParam
            {
                CustomerId  = ComposerContext.CustomerId,
                NewPassword = changePasswordRequest.NewPassword,
                OldPassword = changePasswordRequest.OldPassword,
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                ReturnUrl   = returnUrl
            });

            return(Ok(changePasswordViewModel));
        }
        public virtual async Task <IHttpActionResult> GetRecurringOrderTemplateDetails(GetRecurringOrderTemplateDetailsRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (string.IsNullOrEmpty(request.RecurringOrderTemplateId))
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Guid guid;

            Guid.TryParse(request.RecurringOrderTemplateId, out guid);

            var vm = await RecurringOrderTemplatesViewService.GetRecurringOrderTemplateDetailViewModelAsync(new GetRecurringOrderTemplateDetailParam
            {
                RecurringOrderLineItemId = guid,
                Scope       = ComposerContext.Scope,
                CustomerId  = ComposerContext.CustomerId,
                CultureInfo = ComposerContext.CultureInfo,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            }).ConfigureAwait(false);

            return(Ok(vm));
        }
Exemplo n.º 25
0
        public virtual async Task <IHttpActionResult> UpdateLineItem(UpdateLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var vm = await CartService.UpdateLineItemAsync(new UpdateLineItemParam
            {
                ScopeId     = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                LineItemId  = new Guid(request.LineItemId),
                CartName    = CartConfiguration.ShoppingCartName,
                Quantity    = request.Quantity.GetValueOrDefault(),
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                RecurringOrderFrequencyName = request.RecurringOrderFrequencyName,
                RecurringOrderProgramName   = request.RecurringOrderProgramName
            });

            return(Ok(vm));
        }
        public virtual async Task <IHttpActionResult> UpdateRecurringOrderTemplateLineItemQuantity(UpdateRecurringOrderLineItemQuantityRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var param = new UpdateRecurringOrderTemplateLineItemQuantityParam
            {
                RecurringLineItemId = request.RecurringLineItemId,
                Quantity            = request.Quantity,
                ScopeId             = ComposerContext.Scope,
                CustomerId          = ComposerContext.CustomerId,
                CultureInfo         = ComposerContext.CultureInfo,
                BaseUrl             = RequestUtils.GetBaseUrl(Request).ToString()
            };

            var results = await RecurringOrderTemplatesViewService.UpdateRecurringOrderTemplateLineItemQuantityAsync(param).ConfigureAwait(false);

            return(Ok(results));
        }
Exemplo n.º 27
0
        public virtual async Task <IHttpActionResult> GetCategoryFacets(GetCategoryFacetsRequest request)
        {
            var param = new GetCategoryBrowsingViewModelParam
            {
                CategoryId           = request.CategoryId,
                CategoryName         = string.Empty,
                BaseUrl              = RequestUtils.GetBaseUrl(Request).ToString(),
                IsAllProducts        = false,
                NumberOfItemsPerPage = 0,
                Page                 = 1,
                SortBy               = "score",
                SortDirection        = "desc",
                InventoryLocationIds = await InventoryLocationProvider.GetInventoryLocationIdsForSearchAsync().ConfigureAwait(false),
                CultureInfo          = ComposerContext.CultureInfo
            };

            if (!string.IsNullOrEmpty(request.QueryString))
            {
                var queryString = HttpUtility.ParseQueryString(request.QueryString);
                param.SelectedFacets = SearchUrlProvider.BuildSelectedFacets(queryString).ToList();
            }

            var viewModel = await CategoryBrowsingViewService.GetCategoryBrowsingViewModelAsync(param).ConfigureAwait(false);

            viewModel.ProductSearchResults.Facets = viewModel.ProductSearchResults.Facets.Where(f => !f.FieldName.StartsWith(SearchConfiguration.CategoryFacetFiledNamePrefix)).ToList();

            return(Ok(viewModel));
        }
Exemplo n.º 28
0
        public virtual async Task <IHttpActionResult> GetSearchResults(GetQueryFacetsRequest request)
        {
            var queryString    = HttpUtility.ParseQueryString(request.QueryString ?? "");
            var SelectedFacets = SearchUrlProvider.BuildSelectedFacets(queryString).ToList();
            var CurrentPage    = int.TryParse(queryString[SearchRequestParams.Page], out int page) && page > 0 ? page : 1;
            var SortDirection  = queryString[SearchRequestParams.SortDirection] ?? SearchRequestParams.DefaultSortDirection;
            var SortBy         = queryString[SearchRequestParams.SortBy] ?? SearchRequestParams.DefaultSortBy;
            var BaseUrl        = RequestUtils.GetBaseUrl(Request).ToString();

            var searchCriteria = await BaseSearchCriteriaProvider.GetSearchCriteriaAsync(null, BaseUrl, true, CurrentPage).ConfigureAwait(false);

            searchCriteria.SortBy        = SortBy;
            searchCriteria.SortDirection = SortDirection;
            searchCriteria.SelectedFacets.AddRange(SelectedFacets);

            var param = new GetSearchQueryViewModelParams
            {
                QueryName            = request.QueryName,
                QueryType            = request.QueryType,
                Scope                = ComposerContext.Scope,
                CultureInfo          = ComposerContext.CultureInfo,
                Criteria             = searchCriteria,
                InventoryLocationIds = searchCriteria.InventoryLocationIds
            };

            var viewModel = await SearchQueryViewService.GetSearchQueryViewModelAsync(param).ConfigureAwait(false);

            viewModel.ProductSearchResults.Facets = viewModel.ProductSearchResults.Facets.Where(f => !f.FieldName.StartsWith(SearchConfiguration.CategoryFacetFiledNamePrefix)).ToList();
            return(Ok(viewModel));
        }
Exemplo n.º 29
0
        public virtual async Task <IHttpActionResult> AddLineItem(AddLineItemViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("Missing Request Body"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (!ComposerContext.IsAuthenticated)
            {
                return(BadRequest("Authorization required"));
            }

            var vm = await WishListViewService.AddLineItemAsync(new AddLineItemParam
            {
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CustomerId  = ComposerContext.CustomerId,
                CartName    = CartConfiguration.WishlistCartName,
                ProductId   = request.ProductId,
                VariantId   = request.VariantId,
                Quantity    = request.Quantity.GetValueOrDefault(),
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString(),
                RecurringOrderFrequencyName = request.RecurringOrderFrequencyName,
                RecurringOrderProgramName   = request.RecurringOrderProgramName
            });

            return(Ok(vm));
        }
Exemplo n.º 30
0
        public virtual ActionResult OrderDetails(string token)
        {
            var orderToken = string.IsNullOrWhiteSpace(token) ? null : GuestOrderTokenizer.DecypherOrderToken(token);

            var findMyOrderUrl = OrderUrlProvider.GetFindMyOrderUrl(ComposerContext.CultureInfo);

            OrderDetailViewModel orderDetailViewModel = null;

            if (IsOrderTokenValid(orderToken))
            {
                orderDetailViewModel = OrderHistoryViewService.GetOrderDetailViewModelForGuestAsync(new GetOrderForGuestParam
                {
                    OrderNumber = orderToken.OrderNumber,
                    Email       = orderToken.Email,
                    Scope       = ComposerContext.Scope,
                    CultureInfo = ComposerContext.CultureInfo,
                    CountryCode = ComposerContext.CountryCode,
                    BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
                }).Result;
            }

            if (orderDetailViewModel != null)
            {
                return(View("OrderDetailsContainer", orderDetailViewModel));
            }

            var findMyOrderUrlWithParams = UrlFormatter.AppendQueryString(findMyOrderUrl, new NameValueCollection
            {
                { "orderNotFound", "true" }
            });

            return(Redirect(findMyOrderUrlWithParams));
        }