public void Setup() { var template = new NewsletterTemplate { Name = "Default Newsletter Template", BaseTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\NewsletterBaseTemplate.txt")), Divider = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath(@"\Apps\Ecommerce\Installation\Content\NewsletterDivider.txt")), }; _newsletterTemplateAdminService.Add(template); var productListTemplate = _getContentItemTemplateData.Get <ProductListTemplateData>(template); productListTemplate.ProductGridTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\NewsletterProductGridTemplate.txt")); productListTemplate.ProductRowTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\NewsletterProductRowTemplate.txt")); productListTemplate.ProductTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\NewsletterProductTemplate.txt")); _templateDataAdminService.Update(productListTemplate); var freeTextTemplate = _getContentItemTemplateData.Get <FreeTextTemplateData>(template); freeTextTemplate.FreeTextTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\NewsletterFreeTextTemplate.txt")); _templateDataAdminService.Update(freeTextTemplate); var bannerTemplate = _getContentItemTemplateData.Get <BannerTemplateData>(template); bannerTemplate.BannerTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\NewsletterBannerTemplate.txt")); _templateDataAdminService.Update(bannerTemplate); var imageLeftTextRightTemplateData = _getContentItemTemplateData.Get <ImageLeftAndTextRightTemplateData>(template); imageLeftTextRightTemplateData.ImageLeftAndTextRightTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\ImageLeftAndTextRightTemplate.txt")); _templateDataAdminService.Update(imageLeftTextRightTemplateData); var imageRightTextLeftTemplateData = _getContentItemTemplateData.Get <ImageRightAndTextLeftTemplateData>(template); imageRightTextLeftTemplateData.ImageRightAndTextLeftTemplate = System.IO.File.ReadAllText( HttpContext.Current.Server.MapPath( @"\Apps\Ecommerce\Installation\Content\ImageRightAndTextLeftTemplate.txt")); _templateDataAdminService.Update(imageRightTextLeftTemplateData); }
public string Parse(NewsletterTemplate template, FreeText item) { var freeTextTemplateData = _getContentItemTemplateData.Get <FreeTextTemplateData>(template); if (freeTextTemplateData == null) { return(string.Empty); } string output = freeTextTemplateData.FreeTextTemplate; if (string.IsNullOrWhiteSpace(output)) { return(output); } output = TextRegex.Replace(output, item.Text ?? string.Empty); return(output); }
public string Parse(NewsletterTemplate template, Banner item) { var bannerTemplateData = _getContentItemTemplateData.Get <BannerTemplateData>(template); if (bannerTemplateData == null) { return(string.Empty); } string output = bannerTemplateData.BannerTemplate; if (string.IsNullOrWhiteSpace(output)) { return(string.Empty); } output = ImageRegex.Replace(output, _urlHelper.ToAbsolute(item.ImageUrl)); output = LinkRegex.Replace(output, _urlHelper.ToAbsolute(item.LinkUrl)); return(output); }
public string Parse(NewsletterTemplate template, ProductList item) { var templateData = _getContentItemTemplateData.Get <ProductListTemplateData>(template); if (templateData == null) { return(string.Empty); } string output = templateData.ProductGridTemplate; if (string.IsNullOrWhiteSpace(output)) { return(string.Empty); } Product[] products = GetProducts(item); output = RowRegex.Replace(output, match => ParseRows(templateData, products)); return(output); }
public string Parse(NewsletterTemplate template, ImageRightAndTextLeft item) { var templateData = _getContentItemTemplateData.Get <ImageRightAndTextLeftTemplateData>(template); if (templateData == null) { return(string.Empty); } string output = templateData.ImageRightAndTextLeftTemplate; if (string.IsNullOrWhiteSpace(output)) { return(string.Empty); } var resizedImageUrl = _newsletterBuilderHelperService.GetResizedImage(item.ImageUrl, new Size { Width = 151 }); output = ImageRegex.Replace(output, _urlHelper.ToAbsolute(resizedImageUrl)); output = TextRegex.Replace(output, item.Text ?? string.Empty); return(output); }