/// <summary> /// Creates a <see cref="WishListModel"/>. /// </summary> /// <param name="model"> /// The model. /// </param> /// <returns> /// The <see cref="WishListModel"/>. /// </returns> public WishListModel CreateWishList(RenderModel model) { if (_currentCustomer.IsAnonymous) { var badOperation = new InvalidOperationException("Wish lists cannot be created for anonymous customers"); LogHelper.Error <ViewModelFactory>("Attempted to create a wish list for an anonymous customer", badOperation); throw badOperation; } var viewModel = this.Build <WishListModel>(model); //// this is a protected page - so the customer has to be an ICustomer var customer = (ICustomer)viewModel.CurrentCustomer; var wishList = customer.WishList(); viewModel.WishListTable = new WishListTableModel() { Items = wishList.Items.Select(_basketLineItemFactory.Value.Build).ToArray(), Currency = viewModel.Currency, WishListPageId = BazaarContentHelper.GetWishListContent().Id, BasketPageId = BazaarContentHelper.GetBasketContent().Id, ContinueShoppingPage = BazaarContentHelper.GetContinueShoppingContent() }; return(viewModel); }
/// <summary> /// The index. /// </summary> /// <param name="model"> /// The model. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public override ActionResult Index(RenderModel model) { var theme = BazaarContentHelper.GetStoreTheme(); ((IProductContent)model.Content).SpecifyCulture(UmbracoContext.PublishedContentRequest.Culture); return(this.View(PathHelper.GetThemeViewPath(theme, "ProductContent"), model.Content)); }
/// <summary> /// The index <see cref="ActionResult"/>. /// </summary> /// <param name="model"> /// The current render model. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public override ActionResult Index(RenderModel model) { if (CurrentCustomer.IsAnonymous) { var error = new Exception("Current customer cannot be Anonymous"); LogHelper.Error <BazaarAccountController>("Anonymous customers should not be allowed to access the Account section.", error); return(this.RedirectToUmbracoPage(BazaarContentHelper.GetStoreRoot())); } var viewModel = ViewModelFactory.CreateAccount(model, AllCountries, AllowedShipCountries); return(this.View(viewModel.ThemeAccountPath("Account"), viewModel)); }
public ActionResult RenderAddToBasket(ProductModel model) { var addItemModel = new AddItemModel() { Product = model.ProductData, ContentId = model.Id, BasketPageId = BazaarContentHelper.GetBasketContent().Id, ShowWishList = model.ShowWishList, WishListPageId = BazaarContentHelper.GetWishListContent().Id, Currency = model.Currency }; return(RenderAddItem(addItemModel)); }
/// <summary> /// Gets the list of recently viewed items. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="siteAlias"> /// The site alias. /// </param> /// <returns> /// The <see> /// <cref>IEnumerable</cref> /// </see> /// . /// </returns> internal static IEnumerable <ProductBoxModel> GetRecentlyViewedProducts(this ICustomerContext context, string siteAlias = "Bazaar") { var keys = context.DeserializeRecentlyViewed().Keys; // Get the Merchello helper var merchelloHelper = new MerchelloHelper(); // Get the products as IProductContent var listOfIProductContent = keys.Select( x => merchelloHelper.TypedProductContent(x)) .Reverse(); return(BazaarContentHelper.GetProductBoxModels(listOfIProductContent)); }
/// <summary> /// The index. /// </summary> /// <param name="model"> /// The model. /// </param> /// <returns> /// The <see cref="ActionResult"/>. /// </returns> public override ActionResult Index(RenderModel model) { var theme = BazaarContentHelper.GetStoreTheme(); // Get the product as IProductContent var product = model.Content as IProductContent; // Specify Culture product.SpecifyCulture(UmbracoContext.PublishedContentRequest.Culture); // Add a recently viewed key this.CustomerContext.AddRecentKey(product); return(this.View(PathHelper.GetThemeViewPath(theme, "ProductContent"), model.Content)); }
/// <summary> /// Creates a <see cref="RegistrationModel"/>. /// </summary> /// <param name="model"> /// The model. /// </param> /// <returns> /// The <see cref="RegistrationModel"/>. /// </returns> public RegistrationModel CreateRegistration(RenderModel model) { var viewModel = this.Build <RegistrationModel>(model); viewModel.RegistrationLogin = new CombinedRegisterLoginModel() { Login = new CustomerLoginModel(), Registration = new CustomerRegistrationModel { MemberTypeName = viewModel.CustomerMemberTypeName.EncryptWithMachineKey(), }, AccountPageId = BazaarContentHelper.GetAccountContent().Id }; return(viewModel); }
/// <summary> /// Creates a <see cref="BasketModel"/>. /// </summary> /// <param name="model"> /// The model. /// </param> /// <param name="basket"> /// The <see cref="IBasket"/> /// </param> /// <returns> /// The <see cref="BasketModel"/>. /// </returns> public BasketModel CreateBasket(RenderModel model, IBasket basket) { var viewModel = this.Build <BasketModel>(model); viewModel.BasketTable = new BasketTableModel { Items = basket.Items.Select(_basketLineItemFactory.Value.Build).ToArray(), TotalPrice = basket.Items.Sum(x => x.TotalPrice), Currency = viewModel.Currency, CheckoutPage = BazaarContentHelper.GetCheckoutPageContent(), ContinueShoppingPage = BazaarContentHelper.GetContinueShoppingContent(), ShowWishList = viewModel.ShowWishList && !_currentCustomer.IsAnonymous, WishListPageId = BazaarContentHelper.GetWishListContent().Id, BasketPageId = BazaarContentHelper.GetBasketContent().Id }; return(viewModel); }
/// <summary> /// Initializes the model. /// </summary> private void Initialize() { _receiptPage = new Lazy <IPublishedContent>(() => BazaarContentHelper.GetStoreRoot().Descendant("BazaarReceipt")); }
/// <summary> /// Initializes the controller. /// </summary> private void Initialize() { _currency = BazaarContentHelper.GetStoreCurrency(); _viewModelFactory = new Lazy <IViewModelFactory>(() => new ViewModelFactory(Umbraco, CurrentCustomer, _currency)); }
public ActionResult RecentlyViewed() { var boxes = this.CustomerContext.GetRecentlyViewedProducts(); return(this.PartialView(PathHelper.GetThemePartialViewPath(BazaarContentHelper.GetStoreTheme(), "RecentlyViewed"), boxes)); }
public ActionResult RenderPayPalSetupJs() { return(this.PartialView(PathHelper.GetThemePartialViewPath(BazaarContentHelper.GetStoreTheme(), "BraintreePayPalSetupJs"), this.GetToken())); }
public override ActionResult RenderForm(CheckoutConfirmationForm model) { return(this.PartialView(PathHelper.GetThemePartialViewPath(BazaarContentHelper.GetStoreTheme(), "BraintreePayPalOneTime"), model)); }
public ActionResult RenderAddItem(AddItemModel model) { var theme = BazaarContentHelper.GetStoreTheme(); return(this.PartialView(PathHelper.GetThemePartialViewPath(theme, "AddToCart"), model)); }