public virtual async Task <IHttpActionResult> UpdateAccountAsync(EditAccountRequest request) { var param = new UpdateAccountParam { CustomerId = ComposerContext.CustomerId, Scope = ComposerContext.Scope, PreferredLanguage = request.PreferredLanguage, Email = request.Email, FirstName = request.FirstName, LastName = request.LastName, CultureInfo = ComposerContext.CultureInfo, }; var urlParam = new BaseUrlParameter { CultureInfo = param.CultureInfo }; var addressListUrl = MyAccountUrlProvider.GetAddressListUrl(urlParam); var changePasswordUrl = MyAccountUrlProvider.GetChangePasswordUrl(urlParam); var viewModel = await CustomerViewService.UpdateAccountAsync(param); if (viewModel == null) { return(Unauthorized()); } viewModel.AddressListUrl = addressListUrl; viewModel.ChangePasswordUrl = changePasswordUrl; return(Ok(viewModel)); }
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)); }
//TODO: Change the method name for GetAdressListAsync or something similar because it confuse people public virtual async Task <IHttpActionResult> GetShippingAddressAsync() { var checkoutAddressStepUrl = CartUrlProvider.GetCheckoutStepUrl(new GetCheckoutStepUrlParam { CultureInfo = ComposerContext.CultureInfo, StepNumber = 1, }); var urlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo, ReturnUrl = checkoutAddressStepUrl }; var addressListUrl = MyAccountUrlProvider.GetAddressListUrl(urlParam); var addAddressUrl = CartUrlProvider.GetCheckoutAddAddressUrl(urlParam); var editAddressBaseUrl = CartUrlProvider.GetCheckoutUpdateAddressBaseUrl(urlParam); var viewModel = await CustomerAddressViewService.GetAddressListViewModelAsync(new GetAddressListViewModelParam { CustomerId = ComposerContext.CustomerId, CultureInfo = ComposerContext.CultureInfo, Scope = ComposerContext.Scope, AddAddressUrl = addAddressUrl, EditAddressBaseUrl = editAddressBaseUrl, CountryCode = ComposerContext.CountryCode }); return(Ok(viewModel)); }
public virtual string GetCheckoutSignInUrl(BaseUrlParameter parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(parameters.CultureInfo)), nameof(parameters)); } var pagesConfiguration = SiteConfiguration.GetPagesConfiguration(parameters.CultureInfo, WebsiteContext.WebsiteId); var signInPath = PageService.GetPageUrl(pagesConfiguration.CheckoutSignInPageId, parameters.CultureInfo); if (string.IsNullOrWhiteSpace(parameters.ReturnUrl)) { return(signInPath); } var urlBuilder = new UrlBuilder(signInPath); urlBuilder["ReturnUrl"] = GetReturnUrl(parameters); // url builder will encode the query string value return(urlBuilder.ToString()); }
private static string GetReturnUrl(BaseUrlParameter parameters) { var returnUrl = Uri.IsWellFormedUriString(parameters.ReturnUrl, UriKind.Relative) ? new Uri(parameters.ReturnUrl, UriKind.Relative) : new Uri(parameters.ReturnUrl); return(returnUrl.ToString()); }
protected void SetEditCartUrl(CartViewModel cartViewModel, BaseUrlParameter getUrlParam) { if (cartViewModel.OrderSummary != null) { var cartUrl = CartUrlProvider.GetCartUrl(getUrlParam); cartViewModel.OrderSummary.EditCartUrlTarget = cartUrl; } }
protected virtual void SetCheckoutUrl(CartViewModel cartViewModel, BaseUrlParameter getUrlParam) { if (cartViewModel.OrderSummary != null) { var checkoutUrl = CartUrlProvider.GetCheckoutPageUrl(getUrlParam); cartViewModel.OrderSummary.CheckoutUrlTarget = checkoutUrl; } }
protected virtual void SetHomepageUrl(CartViewModel cartViewModel, BaseUrlParameter getUrlParam) { if (cartViewModel != null) { var homepageUrl = CartUrlProvider.GetHomepageUrl(getUrlParam); cartViewModel.HomepageUrl = homepageUrl; } }
protected virtual string GetCartUrl() { var getCartUrlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; return(CartUrlProvider.GetCartUrl(getCartUrlParam)); }
/// <summary> /// Url to the Terms and conditions page /// </summary> /// <returns>localized url</returns> public virtual string GetTermsAndConditionsUrl(BaseUrlParameter param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } var pagesConfiguration = SiteConfiguration.GetPagesConfiguration(param.CultureInfo, WebsiteContext.WebsiteId); var url = PageService.GetPageUrl(pagesConfiguration.TermsAndConditionsPageId, param.CultureInfo); return(UrlProviderHelper.BuildUrlWithParams(url, param.ReturnUrl)); }
public virtual string GetCheckoutUpdateAddressBaseUrl(BaseUrlParameter param) { if (param == null) { throw new ArgumentNullException("param"); } var pagesConfiguration = SiteConfiguration.GetPagesConfiguration(param.CultureInfo, WebsiteContext.WebsiteId); var url = PageService.GetPageUrl(pagesConfiguration.CheckoutUpdateAddressPageId, param.CultureInfo); return(UrlProviderHelper.BuildUrlWithParams(url, param.ReturnUrl)); }
protected void SetEditCartUrl(CartViewModel cartViewModel) { if (cartViewModel.OrderSummary != null) { var getCartUrlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; var cartUrl = CartUrlProvider.GetCartUrl(getCartUrlParam); cartViewModel.OrderSummary.EditCartUrlTarget = cartUrl; } }
public virtual string GetCartUrl(BaseUrlParameter parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(parameters.CultureInfo)), nameof(parameters)); } var pagesConfiguration = SiteConfiguration.GetPagesConfiguration(parameters.CultureInfo, WebsiteContext.WebsiteId); return(PageService.GetPageUrl(pagesConfiguration.CartPageId, parameters.CultureInfo)); }
public virtual string GetCheckoutConfirmationPageUrl(BaseUrlParameter parameters) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.CultureInfo == null) { throw new ArgumentException($"{nameof(parameters.CultureInfo)} is required", nameof(parameters)); } var pagesConfiguration = SiteConfiguration.GetPagesConfiguration(parameters.CultureInfo, WebsiteContext.WebsiteId); return(PageService.GetPageUrl(pagesConfiguration.CheckoutConfirmationPageId, parameters.CultureInfo)); }
public string GetForgotPasswordPageUrl(BaseUrlParameter param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException($"{nameof(param.CultureInfo)} is required", nameof(param)); } var pagesConfiguration = SiteConfiguration.GetPagesConfiguration(param.CultureInfo, WebsiteContext.WebsiteId); return(PageService.GetPageUrl(pagesConfiguration.ForgotPasswordPageId, param.CultureInfo)); }
public string GetHomepageUrl(BaseUrlParameter param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } var url = PageService.GetPageUrl(WebsiteContext.WebsiteId, param.CultureInfo); ///TODO - fix this if (string.IsNullOrWhiteSpace(url)) { return(url); } return(UrlProviderHelper.BuildUrlWithParams(url, param.ReturnUrl)); }
/// <summary> /// Url to the My Addresses url page /// </summary> /// <returns>localized url</returns> public string GetAddressListUrl(BaseUrlParameter param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } var pagesConfiguration = SiteConfiguration.GetPagesConfiguration(param.CultureInfo, WebsiteContext.WebsiteId); if (pagesConfiguration == null) { return(null); } var url = PageService.GetPageUrl(pagesConfiguration.AddressListPageId, param.CultureInfo); return(UrlProviderHelper.BuildUrlWithParams(url, param.ReturnUrl)); }
protected virtual string GetCheckoutUrl() { var getCartUrlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; var checkoutStepInfos = CartUrlProvider.GetCheckoutStepPageInfos(getCartUrlParam); var checkoutSignInUrl = CartUrlProvider.GetCheckoutSignInUrl(new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo, ReturnUrl = ComposerContext.IsAuthenticated ? null : checkoutStepInfos[1].Url }); var checkoutUrlTarget = ComposerContext.IsAuthenticated ? checkoutStepInfos[1].Url : checkoutSignInUrl; return(checkoutUrlTarget); }
/// <summary> /// Get the view Model to display User information /// </summary> /// <returns> /// The view model to display the User information /// </returns> public virtual async Task <UserMetadataViewModel> GetUserMetadataModel(GetUserMetadataParam param) { var urlParam = new BaseUrlParameter { CultureInfo = param.CultureInfo }; var customer = await CustomerRepository.GetCustomerByIdAsync(new GetCustomerByIdParam { CultureInfo = param.CultureInfo, CustomerId = param.CustomerId, Scope = param.Scope }).ConfigureAwait(false); var viewModel = ViewModelMapper.MapTo <UserMetadataViewModel>(customer, param.CultureInfo) ?? new UserMetadataViewModel(); viewModel.IsAuthenticated = param.IsAuthenticated; viewModel.EncryptedCustomerId = param.EncryptedCustomerId; viewModel.Url = viewModel.IsAuthenticated ? MyAccountUrlProvider.GetMyAccountUrl(urlParam) : MyAccountUrlProvider.GetLoginUrl(urlParam); viewModel.RegisterUrl = MyAccountUrlProvider.GetCreateAccountUrl(urlParam); return(viewModel); }
public virtual ActionResult AddressList() { var urlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; var addAddressUrl = MyAccountUrlProvider.GetAddAddressUrl(urlParam); var editAddressBaseUrl = MyAccountUrlProvider.GetUpdateAddressBaseUrl(urlParam); var viewModel = CustomerAddressViewService.GetAddressListViewModelAsync(new GetAddressListViewModelParam { CustomerId = ComposerContext.CustomerId, CultureInfo = ComposerContext.CultureInfo, Scope = ComposerContext.Scope, AddAddressUrl = addAddressUrl, EditAddressBaseUrl = editAddressBaseUrl, CountryCode = ComposerContext.CountryCode }).Result; return(View("AddressListBlade", viewModel)); }
public virtual ActionResult UpdateAccount() { var urlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; var changePasswordUrl = MyAccountUrlProvider.GetChangePasswordUrl(urlParam); var addressListUrl = MyAccountUrlProvider.GetAddressListUrl(urlParam); var param = new GetUpdateAccountViewModelParam { Scope = ComposerContext.Scope, CultureInfo = ComposerContext.CultureInfo, CustomerId = ComposerContext.CustomerId }; var viewModel = CustomerViewService.GetUpdateAccountViewModelAsync(param).Result; viewModel.ChangePasswordUrl = changePasswordUrl; viewModel.AddressListUrl = addressListUrl; return(View("UpdateAccountBlade", viewModel)); }
/// <summary> /// Gets the <see cref="AddressListViewModel"/> to display a list of addresses in MyAddresses Form or Form result /// </summary> /// <param name="param"></param> /// <param name="customer"></param> /// <param name="addresses"></param> /// <param name="regions"></param> /// <returns></returns> protected virtual AddressListViewModel GetAddressListViewModel( GetAddressListViewModelParam param, Customer customer, IEnumerable <Address> addresses, IEnumerable <RegionViewModel> regions) { var viewModel = ViewModelMapper.MapTo <AddressListViewModel>(customer, param.CultureInfo); var urlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; var addAddressUrl = MyAccountUrlProvider.GetAddAddressUrl(urlParam); var editAddressBaseUrl = MyAccountUrlProvider.GetUpdateAddressBaseUrl(urlParam); viewModel.AddAddressUrl = addAddressUrl; viewModel.Addresses = addresses.Select(address => { var addressVm = ViewModelMapper.MapTo <AddressListItemViewModel>(address, param.CultureInfo); if (!string.IsNullOrWhiteSpace(editAddressBaseUrl)) { var editUrlWithParam = UrlFormatter.AppendQueryString(editAddressBaseUrl, new NameValueCollection { { "addressId", address.Id.ToString() } }); addressVm.UpdateAddressUrl = editUrlWithParam; } var region = regions.FirstOrDefault(x => x.IsoCode == address.RegionCode); addressVm.RegionName = region != null ? region.Name : string.Empty; return(addressVm); }).ToList(); return(viewModel); }
protected virtual void SetForgotPasswordPageUrl(CartViewModel cartViewModel, BaseUrlParameter getUrlParam) { cartViewModel.ForgotPasswordUrl = CartUrlProvider.GetForgotPasswordPageUrl(getUrlParam); }
public virtual CartViewModel CreateCartViewModel(CreateCartViewModelParam param) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (param.CultureInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param)); } if (param.ProductImageInfo == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.ProductImageInfo)), nameof(param)); } if (param.ProductImageInfo.ImageUrls == null) { throw new ArgumentException(GetMessageOfNull(nameof(param.ProductImageInfo.ImageUrls)), nameof(param)); } if (string.IsNullOrWhiteSpace(param.BaseUrl)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.BaseUrl)), nameof(param)); } Helper.LineItemsHelper.PrepareGiftLineItems(param.Cart); var vm = ViewModelMapper.MapTo <CartViewModel>(param.Cart, param.CultureInfo); if (vm == null) { return(null); } vm.OrderSummary = GetOrderSummaryViewModel(param.Cart, param.CultureInfo); MapShipmentsAndPayments(param.Cart, param.CultureInfo, param.ProductImageInfo, param.BaseUrl, param.PaymentMethodDisplayNames, vm, param.Cart.Payments); MapCustomer(param.Cart.Customer, param.CultureInfo, vm); vm.Coupons = GetCouponsViewModel(param.Cart, param.CultureInfo, param.IncludeInvalidCouponsMessages); vm.OrderSummary.AdditionalFeeSummaryList = GetAdditionalFeesSummary(vm.LineItemDetailViewModels, param.CultureInfo); SetDefaultCountryCode(vm); SetDefaultShippingAddressNames(vm); SetPostalCodeRegexPattern(vm); SetPhoneNumberRegexPattern(vm); var getUrlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; SetHomepageUrl(vm, getUrlParam); SetEditCartUrl(vm, getUrlParam); SetCheckoutUrl(vm, getUrlParam); SetForgotPasswordPageUrl(vm, getUrlParam); // Reverse the items order in the Cart so the last added item will be the first in the list if (vm.LineItemDetailViewModels != null) { vm.LineItemDetailViewModels.Reverse(); } vm.IsAuthenticated = ComposerContext.IsAuthenticated; return(vm); }
public virtual Dictionary <int, CheckoutStepPageInfo> GetCheckoutStepPageInfos(BaseUrlParameter parameters) { CacheKey cacheKey = new CacheKey(CacheConfigurationCategoryNames.CheckoutStepUrls) { CultureInfo = parameters.CultureInfo }; cacheKey.AppendKeyParts(WebsiteContext.WebsiteId.ToString()); Dictionary <int, CheckoutStepPageInfo> stepUrls = CacheProvider.Get <Dictionary <int, CheckoutStepPageInfo> >(cacheKey); if (stepUrls != null) { return(stepUrls); } stepUrls = new Dictionary <int, CheckoutStepPageInfo>(); var items = PageService.GetCheckoutStepPages(WebsiteContext.WebsiteId, parameters.CultureInfo); var navItems = PageService.GetCheckoutNavigationPages(WebsiteContext.WebsiteId, parameters.CultureInfo); var index = 0; foreach (var checkoutStepItem in items) { var pageGuid = Guid.Parse(checkoutStepItem); stepUrls.Add(index, new CheckoutStepPageInfo { Url = PageService.GetPageUrl(pageGuid, parameters.CultureInfo), IsDisplayedInHeader = navItems != null && navItems.Contains(checkoutStepItem), Title = PageService.GetPage(pageGuid, parameters.CultureInfo).MenuTitle, PageId = pageGuid }); index++; } stepUrls = stepUrls.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value); CacheProvider.Set(cacheKey, stepUrls); return(stepUrls); }
public virtual MenuViewModel CreateMenu(string currentUrl) { var urlParam = new BaseUrlParameter { CultureInfo = ComposerContext.CultureInfo }; bool recurringOrderConfigEnabled = RecurringOrdersSettings.Enabled; var myAccountUrl = MyAccountUrlProvider.GetMyAccountUrl(urlParam); var addressListUrl = MyAccountUrlProvider.GetAddressListUrl(urlParam); var myOrderHistoryUrl = OrderUrlProvider.GetOrderHistoryUrl(new GetOrderUrlParameter { CultureInfo = ComposerContext.CultureInfo }); var myWishListUrl = WishListUrlProvider.GetWishListUrl(new GetWishListUrlParam { CultureInfo = ComposerContext.CultureInfo }); var myRecurringScheduleUrl = RecurringScheduleUrlProvider.GetRecurringScheduleUrl(new GetRecurringScheduleUrlParam { CultureInfo = ComposerContext.CultureInfo }); var currentPageId = new Guid(currentUrl); var menu = new MenuViewModel { MenuItems = new List <MenuItemViewModel>() }; var pageConfiguration = SiteConfiguration.GetPagesConfiguration(ComposerContext.CultureInfo, WebsiteContext.WebsiteId); var myAccountPage = PageService.GetPage(pageConfiguration.MyAccountPageId, ComposerContext.CultureInfo); var myAddressPage = PageService.GetPage(pageConfiguration.AddressListPageId, ComposerContext.CultureInfo); var myOrderHistoryPage = PageService.GetPage(pageConfiguration.OrderHistoryPageId, ComposerContext.CultureInfo); var myWishListage = PageService.GetPage(pageConfiguration.MyWishListPageId, ComposerContext.CultureInfo); var myRecurringSchedulePage = PageService.GetPage(RecurringOrdersSettings.RecurringSchedulePageId, ComposerContext.CultureInfo); var myAccountMenuItem = new MenuItemViewModel { Name = myAccountPage.MenuTitle, Url = myAccountUrl, IsActive = currentPageId == pageConfiguration.MyAccountPageId || currentPageId == pageConfiguration.ChangePasswordPageId }; var myAdressesMenuItem = new MenuItemViewModel { Name = myAddressPage.MenuTitle, Url = addressListUrl, IsActive = currentPageId == pageConfiguration.AddressListPageId || currentPageId == pageConfiguration.AddAddressPageId || currentPageId == pageConfiguration.UpdateAddressPageId }; var myWishListMenuItem = new MenuItemViewModel { Name = myWishListage.MenuTitle, Url = myWishListUrl, IsActive = currentPageId == pageConfiguration.MyWishListPageId }; var myOrderHistoryMenuItem = new MenuItemViewModel { Name = myOrderHistoryPage.MenuTitle, Url = myOrderHistoryUrl, IsActive = currentPageId == pageConfiguration.OrderHistoryPageId || currentPageId == pageConfiguration.OrderDetailsPageId || currentPageId == RecurringOrdersSettings.RecurringCartDetailsPageId }; var myRecurringScheduleMenuItem = new MenuItemViewModel { Name = myRecurringSchedulePage.MenuTitle, Url = myRecurringScheduleUrl, IsActive = currentPageId == RecurringOrdersSettings.RecurringSchedulePageId || currentPageId == RecurringOrdersSettings.RecurringScheduleDetailsPageId }; menu.MenuItems.AddRange(new List <MenuItemViewModel> { myAccountMenuItem, myWishListMenuItem, myAdressesMenuItem, myOrderHistoryMenuItem }); if (recurringOrderConfigEnabled) { menu.MenuItems.Add(myRecurringScheduleMenuItem); } return(menu); }