private void AddUrlsToArticleSearchResults(int affiliateId, ref List <ArticleSearchResultArticle> articles)
        {
            var articlePictureTemplates = ArticlePictureTemplates.Where(x => x.AffiliateId == affiliateId);

            if (articlePictureTemplates.Count() == 0)
            {
                return;
            }
            else
            {
                Dictionary <int, string> w = ShopProductUrls;
                Dictionary <int, string> e = ShopProductPictureUrls;

                ArticlePictureTemplate apt = articlePictureTemplates.OrderByDescending(x => x.Height).First();

                foreach (ArticleSearchResultArticle article in articles)
                {
                    StringBuilder sb = new StringBuilder(apt.TargetFile);
                    sb.Replace("{pzn}", article.PZN.ToString(System.Globalization.CultureInfo.InvariantCulture).PadLeft(8, '0'));
                    sb.Replace("{urlname}", article.BaseUrl);
                    sb.Replace("{rang}", "1");
                    sb.Insert(0, "/");
                    sb.Insert(0, ShopProductPictureUrls[affiliateId]);
                    sb.Replace("//", "/");
                    sb.Insert(0, "https://");
                    sb.Replace("--", "-");

                    article.PictureUrl = sb.ToString();

                    article.WebsiteUrl = string.Concat("https://", ShopProductUrls[affiliateId].TrimEnd('/'), "/", article.PZN.ToString(System.Globalization.CultureInfo.InvariantCulture).PadLeft(8, '0'), "-", article.BaseUrl.TrimStart('/'), ".html");
                }
            }
        }
        public ActionResult <List <ArticlePictureTemplate> > GetArticlePictureTemplates()
        {
            var templates = (from x in MAINDBContext.AffiliateArtikelstammBildvorgabe
                             select x);

            List <ArticlePictureTemplate> returnValue = new List <ArticlePictureTemplate>();

            foreach (var template in templates)
            {
                ArticlePictureTemplate apt = new ArticlePictureTemplate();

                dynamic parameter = JObject.Parse(template.Parameter);

                apt.Id                 = template.Id;
                apt.Key                = template.Schluessel;
                apt.AffiliateId        = template.AffiliateId;
                apt.Width              = parameter.width;
                apt.Height             = parameter.height;
                apt.Filter             = parameter.filter;
                apt.Blur               = parameter.blur;
                apt.BestFit            = parameter.bestfit;
                apt.CompressionQuality = parameter.compressionquality;
                apt.SourceBucket       = parameter.sourceBucket;
                apt.TargetBucket       = parameter.targetBucket;
                apt.TargetFile         = parameter.targetFile;

                returnValue.Add(apt);
            }

            return(returnValue);
        }