public QuickBuyViewModel Build(QuickBuyBlock currentBlock, QuickBuyViewModel model) { model.CurrentBlock = currentBlock; var productInfo = currentBlock != null ? (currentBlock.CampaignProducts != null ? (currentBlock.CampaignProducts.Items != null ? currentBlock.CampaignProducts.Items.Select(x => _contentLoader.Get <VariationContent>(x.ContentLink)) : null) : null) : null; model.Products = productInfo != null? productInfo.Select(x => new ProductInfo() { Sku = x.Code, Name = x.DisplayName }) : new List <ProductInfo>(); if (currentBlock != null && currentBlock.Image != null) { model.ImageContent = new ImageViewModel(_contentLoader.Get <ImageFile>(currentBlock.Image), "en"); } if (currentBlock != null) { model.ActionLabel = currentBlock.ButtonLabel ?? string.Empty; } if (string.IsNullOrEmpty(model.ActionLabel)) { model.ActionLabel = _localizationService.GetString("/common/quickbuy/form/buy"); } return(model); }
public ActionResult Index(QuickBuyBlock currentBlock) { var tag = ControllerContext.ParentActionViewContext.ViewData["tag"] as string; _logger.Warning("Tag = " + (tag ?? "Tag is empty")); var cookieModel = _cookieService.GetFromCookie(); QuickBuyViewModel model = new QuickBuyViewModel(cookieModel); model = _modelBuilder.Build(currentBlock, model); if (string.IsNullOrEmpty(currentBlock.PromotionId) == false || string.IsNullOrEmpty(currentBlock.PromotionName) == false) { _googleAnalyticsTracker.TrackPromotionImpression(currentBlock.PromotionId, currentBlock.PromotionName, currentBlock.PromotionBannerName); } if (tag == WebGlobal.ContentAreaTags.FullWidth) { return(PartialView("FullWidth", model)); } if (tag == WebGlobal.ContentAreaTags.HalfWidth || tag == WebGlobal.ContentAreaTags.OneThirdWidth) { return(PartialView("Narrow", model)); } return(PartialView(model)); }
public ActionResult PlaceOrder(QuickBuyBlock currentBlock, QuickBuyViewModel model) { try { model = _modelBuilder.Build(currentBlock, model); var page = _contentLoader.Get <PageData>(new ContentReference(model.SuccessUrl)); _logger.Debug("Saving information"); _cookieService.SaveCookie(model); model.Sku = model.SelectedSku; var order = _orderService.QuickBuyOrder(model, CustomerContext.Current.CurrentContactId); model.Success = true; model.OrderNumber = order.TrackingNumber; var url = _urlResolver.GetUrl(page.ContentLink) + "?order=" + order.TrackingNumber; return(Json(url)); } catch (Exception ex) { return(Content(GetErrorMarkup(ex))); } }