Respect for your body and our planet

Certified Danish skin care for the entire family

0% unnecessary chemicals
100% respect for your body and our planet

Read more about our promise

Follow us on instagram

@derma_official
Exception in template (Designs/derma-iris-2019-01/Paragraph/Derma_InstagramFeed.cshtml): System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadString(Uri address)
   at CompiledRazorTemplates.Dynamic.bacacfe.InstagramProgram.GetInstagramData(String myUri)
   at CompiledRazorTemplates.Dynamic.bacacfe.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@using System.Net; @using Newtonsoft.Json; @using Newtonsoft.Json.Linq; @using System.Runtime.Caching; @{ init(); } @functions { private string currentGroupType { get; set; } public void init() { string isFirst = GetString("ParagraphContainerIsFirst"); string groupStart = GetString("Item.BreakoutSettings.StartGroup"); if (isFirst == "True" && groupStart == "False"){ currentGroupType = Dynamicweb.Core.Converter.ToString(System.Web.HttpContext.Current.Items["currentGroupType"]); } if (groupStart == "True"){ currentGroupType = Dynamicweb.Core.Converter.ToString(System.Web.HttpContext.Current.Items["currentGroupType"]); string newGroupType = GetString("Item.BreakoutSettings.GroupType.Value"); System.Web.HttpContext.Current.Items["currentGroupType"] = newGroupType; } else { currentGroupType = Dynamicweb.Core.Converter.ToString(System.Web.HttpContext.Current.Items["currentGroupType"]); System.Web.HttpContext.Current.Items["currentGroupType"] = currentGroupType; } } public string NewGroup(string theGroupClass) { string itemType = Dynamicweb.Core.Converter.ToString(Dynamicweb.Frontend.PageView.Current().Item.SystemName); string rowAddHorizontalMargin = ""; if (GetBoolean("Item.Layout.ShowAsBox") == true && GetBoolean("Item.Layout.RemoveHorizontalMargin") != true) { rowAddHorizontalMargin = " row-add-hor-margin"; } string groupTextColorTheme = " dark-text"; if (GetString("Item.BreakoutSettings.GroupTextColorTheme") == "bright") { groupTextColorTheme = " bright-text"; } string groupPadding = " no-margins"; if (!string.IsNullOrWhiteSpace(GetString("Item.BreakoutSettings.Margin"))) { groupPadding = " " + GetString("Item.BreakoutSettings.Margin").Replace(","," "); } string groupClass = theGroupClass + groupTextColorTheme + groupPadding; string isFirst = GetString("ParagraphContainerIsFirst"); string groupStart = GetString("Item.BreakoutSettings.StartGroup"); string contentPlaceholder = GetString("ParagraphContainer"); if (isFirst == "True" && groupStart == "False" && contentPlaceholder != "menuwrap"){ System.Web.HttpContext.Current.Items["currentGroupType"] = "full"; return "<div class=\"container-fluid\"><div class=\"row\">"; } if (isFirst == "True" && groupStart == "False" && contentPlaceholder == "menuwrap"){ System.Web.HttpContext.Current.Items["currentGroupType"] = "constrained"; return "<div class=\"container-fluid\"><div class=\"container\"><div class=\"row\">"; } string groupStyles = ""; string groupBgColor = ""; string groupBgImg = ""; if (!string.IsNullOrWhiteSpace(GetString("Item.BreakoutSettings.BackgroundColor"))) { groupBgColor = "background-color:" + GetString("Item.BreakoutSettings.BackgroundColor") + ";"; } if (!string.IsNullOrWhiteSpace(GetString("Item.BreakoutSettings.BackgroundImage"))) { groupBgImg = "background-image: url('" + GetString("Item.BreakoutSettings.BackgroundImage") + "');"; } groupStyles = " style=\"" + groupBgColor + groupBgImg + "\""; if (isFirst == "True" && groupStart == "True" && contentPlaceholder != "menuwrap"){ string newGroup = GetString("Item.BreakoutSettings.GroupType.Value"); currentGroupType = newGroup; if (currentGroupType == "full") { if (newGroup == "full") { return "<div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"row\">"; } if (newGroup == "constrained") { return "<div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"container\"><div class=\"row" + rowAddHorizontalMargin + "\">"; } else { return string.Empty; } } if (currentGroupType == "constrained") { if (newGroup == "full") { return "<div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"row\">"; } if (newGroup == "constrained") { return "<div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"container\"><div class=\"row" + rowAddHorizontalMargin + "\">"; } else { return string.Empty; } } else { return string.Empty; } } if (isFirst == "False" && groupStart == "True" && contentPlaceholder != "menuwrap"){ string newGroup = GetString("Item.BreakoutSettings.GroupType.Value"); if (currentGroupType == "full") { if (newGroup == "full") { return "</div></div><div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"row\">"; } if (newGroup == "constrained") { return "</div></div><div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"container\"><div class=\"row" + rowAddHorizontalMargin + "\">"; } else { return string.Empty; } } if (currentGroupType == "constrained") { if (newGroup == "full") { return "</div></div></div><div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"row\">"; } if (newGroup == "constrained") { return "</div></div></div><div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"container\"><div class=\"row" + rowAddHorizontalMargin + "\">"; } else { return string.Empty; } } else { return string.Empty; } } if (isFirst == "True" && groupStart == "True" && contentPlaceholder == "menuwrap"){ string newGroup = "constrained"; System.Web.HttpContext.Current.Items["currentGroupType"] = "constrained"; currentGroupType = "constrained"; if (currentGroupType == "constrained") { if (newGroup == "constrained") { string navAlign = Dynamicweb.Core.Converter.ToString(Dynamicweb.Frontend.PageView.Current().Area.Item["ShowSideNav"]); string blogByline = ""; if (itemType == "Derma_BlogCategory" || itemType == "Derma_BlogPost"){ navAlign = "right"; } if (itemType == "Derma_BlogPost"){ string author = Dynamicweb.Core.Converter.ToString(Dynamicweb.Frontend.PageView.Current().Item["Author"]) != "" ? Dynamicweb.Core.Converter.ToString(Dynamicweb.Frontend.PageView.Current().Item["Author"]) + ", " : ""; string date = Dynamicweb.Core.Converter.ToDateTime(Dynamicweb.Frontend.PageView.Current().Item["Date"]).ToLongDateString(); blogByline = "<div class=\"col-xs-12 blog-byline\">" + author + date + "</div>"; } int navCols = Dynamicweb.Core.Converter.ToInt32(Dynamicweb.Frontend.PageView.Current().Area.Item["SideNavCols"]); int contentCols = 12 - navCols; if (navAlign == "left"){ navAlign = " col-md-push-" + Dynamicweb.Core.Converter.ToString(navCols); } else { navAlign = ""; } return "<div class=\"container-fluid " + @groupClass + "\"" + @groupStyles + "><div class=\"container\"><div class=\"row\"><div class=\"col-xs-12 col-md-" + Dynamicweb.Core.Converter.ToString(contentCols) + @navAlign + "\"><div class=\"row" + rowAddHorizontalMargin + "\">" + @blogByline; } else { return string.Empty; } } else { return string.Empty; } } else { return string.Empty; } } public string LastGroup() { string isLast = GetString("ParagraphContainerIsLast"); string itemType = Dynamicweb.Core.Converter.ToString(Dynamicweb.Frontend.PageView.Current().Item.SystemName); currentGroupType = Dynamicweb.Core.Converter.ToString(System.Web.HttpContext.Current.Items["currentGroupType"]); if (isLast == "True"){ string contentPlaceholder = GetString("ParagraphContainer"); if (currentGroupType == "full" && contentPlaceholder != "menuwrap") { return "</div></div>"; } if (currentGroupType == "constrained" && contentPlaceholder != "menuwrap") { return "</div></div></div>"; } if (contentPlaceholder == "menuwrap") { string navAlign = Dynamicweb.Core.Converter.ToString(Dynamicweb.Frontend.PageView.Current().Area.Item["ShowSideNav"]); if (itemType == "Derma_BlogCategory" || itemType == "Derma_BlogPost"){ navAlign = "right"; } int navCols = Dynamicweb.Core.Converter.ToInt32(Dynamicweb.Frontend.PageView.Current().Area.Item["SideNavCols"]); int contentCols = 12 - navCols; string navClass = " right-nav"; if (navAlign == "left"){ navClass = " left-nav"; navAlign = " col-md-pull-" + Dynamicweb.Core.Converter.ToString(contentCols); } else { navAlign = ""; } return "</div></div><div class=\"col-md-" + Dynamicweb.Core.Converter.ToString(navCols) + @navClass + " hidden-xs hidden-sm" + @navAlign + " sidenav\">" + @RenderSnippet("sidenavheader") + @RenderSnippet("sidenav") + "<div id=\"sidenav-append\">" + @RenderSnippet("sidetags") + "</div>" + "</div></div></div></div>"; } else { return string.Empty; } } else { return string.Empty; } } public string ColumnClass() { string mobile = GetString("Item.WidthSettings.WidthMobile") + " "; string portrait = GetString("Item.WidthSettings.WidthTabletPortrait") + " "; string landscape = GetString("Item.WidthSettings.WidthTabletLandscape") + " "; string desktop = GetString("Item.WidthSettings.WidthDesktop"); if (string.IsNullOrWhiteSpace(mobile)) { mobile = "col-xs-12 "; } if (string.IsNullOrWhiteSpace(portrait)) { portrait = ""; } if (string.IsNullOrWhiteSpace(landscape)) { landscape = ""; } return mobile + portrait + landscape + desktop; } public string CenterBlock() { string centerBlock = ""; if (GetString("Item.WidthSettings.CenterBlock") == "True") { centerBlock = " center-col"; } return centerBlock; } } @NewGroup("instagram-group") @{ string userid = GetString("Item.InstagramUserId"); string token = GetString("Item.InstagramAccessToken"); string quantity = GetString("Item.ImageQuantity"); string cols = GetString("Item.ImagesPerRow"); string myUri = "http://api.instagram.com/v1/users/" + userid + "/media/recent/?access_token=" + token + "&count=" + quantity; Rootobject root = JsonConvert.DeserializeObject<Rootobject>(InstagramProgram.GetInstagramData(myUri).ToString()); int i = 0; foreach (var data in root.data) { @:<div class="instacol col-xs-4 [email protected]"> var imgurl = data.images.standard_resolution.url; var imglink = data.link; var imgid = "instagram" + i; <a href="@imglink" target="_blank" title="Se pÃ¥ instagram" class="instagramimg @imgid lazy-normal" data-src="@imgurl"></a> @:</div> ++i; } } @LastGroup() @functions { public class InstagramProgram { public static object GetInstagramData(string myUri) { //string fromWhere = ""; var cachedDataString = MemoryCache.Default["InstagramDataDerma"]; if (cachedDataString == null) { //fromWhere = "Slooooow web"; WebClient client = new WebClient(); cachedDataString = client.DownloadString(myUri); MemoryCache.Default.Add("InstagramDataDerma", cachedDataString, DateTime.Now.AddMinutes(60)); } else { //fromWhere = "From cache..."; } return cachedDataString; } } public class Rootobject { public Pagination pagination { get; set; } public Datum[] data { get; set; } public Meta meta { get; set; } } public class Pagination { public string next_max_id { get; set; } public string next_url { get; set; } } public class Meta { public int code { get; set; } } public class Datum { public string id { get; set; } public User user { get; set; } public Images images { get; set; } public string created_time { get; set; } public object caption { get; set; } public bool user_has_liked { get; set; } public Likes likes { get; set; } public object[] tags { get; set; } public string filter { get; set; } public Comments comments { get; set; } public string type { get; set; } public string link { get; set; } public object location { get; set; } public object attribution { get; set; } public object[] users_in_photo { get; set; } } public class User { public string id { get; set; } public string full_name { get; set; } public string profile_picture { get; set; } public string username { get; set; } } public class Images { public Thumbnail thumbnail { get; set; } public Low_Resolution low_resolution { get; set; } public Standard_Resolution standard_resolution { get; set; } } public class Thumbnail { public int width { get; set; } public int height { get; set; } public string url { get; set; } } public class Low_Resolution { public int width { get; set; } public int height { get; set; } public string url { get; set; } } public class Standard_Resolution { public int width { get; set; } public int height { get; set; } public string url { get; set; } } public class Likes { public int count { get; set; } } public class Comments { public int count { get; set; } } }