protected void InitializeTemplate(Request Request, WebTemplate Template, ResultPage Content, string[] Parts, WebUrl Url) { foreach (WebSection section in Template.Sections) { var sectionJson = Content.Sections.Add(); sectionJson.Name = section.Name; foreach (WebMap map in section.Maps.OrderBy(x => x.SortNumber)) { if (map.Url != null && map.Url.GetObjectID() != Url.GetObjectID()) { continue; } string url = FormatUrl(map.ForeignUrl, Parts.Last()); ContainerPage json = Self.GET<ContainerPage>(url, () => { return new ContainerPage() { Key = url }; }); sectionJson.Rows.Add(json); } if (section.Default && Url == null) { ContainerPage json = Self.GET<ContainerPage>(Request.Uri, () => { return new ContainerPage() { Key = Request.Uri }; }); sectionJson.Rows.Add(json); } } }
protected void UpdateTemplate(Request Request, WebTemplate Template, ResultPage Content, string[] UrlParts, WebUrl Url) { foreach (WebSection section in Template.Sections) { var sectionJson = Content.Sections.FirstOrDefault(x => x.Name == section.Name); var maps = section.Maps.Where(x => x.Url == null || x.Url.GetObjectID() == Url.GetObjectID()).OrderBy(x => x.SortNumber).ToList(); int index = 0; if (sectionJson.Rows.Count == maps.Count) { foreach (WebMap map in maps) { string url = FormatUrl(map.ForeignUrl, UrlParts.Last()); if ((sectionJson.Rows[index] as ContainerPage).Key != url) { sectionJson.Rows[index] = Self.GET<ContainerPage>(url, () => { return new ContainerPage() { Key = url }; }); } index++; } } else { sectionJson.Rows.Clear(); foreach (WebMap map in maps) { string url = FormatUrl(map.ForeignUrl, UrlParts.Last()); sectionJson.Rows.Add(Self.GET<ContainerPage>(url, () => { return new ContainerPage() { Key = url }; })); index++; } } if (section.Default && Url == null && (sectionJson.Rows[index] as ContainerPage).Key != Request.Uri) { sectionJson.Rows[index] = Self.GET<ContainerPage>(Request.Uri, () => { return new ContainerPage() { Key = Request.Uri }; }); } } }