Exemple #1
0
        public ActionResult AttachSectionToTemplate(int id)
        {
            var model = new AttachSectionTemplateViewData();

            model.Section   = this._sectionService.GetSectionById(id);
            model.Templates = this._templateService.GetAllTemplatesBySite(CuyahogaContext.CurrentSite);
            foreach (var template in model.Templates)
            {
                // read placeholders
                string virtualTemplatePath = VirtualPathUtility.Combine(CuyahogaContext.CurrentSite.SiteDataDirectory, template.Path);
                model.PlaceHoldersByTemplate[template] = ViewUtil.GetPlaceholdersFromVirtualPath(virtualTemplatePath).Select(p => p.Key).ToArray();
                // add sectiontemplate viewdata
                var sectionTemplate = new SectionTemplateViewData();
                sectionTemplate.TemplateId = template.Id;
                if (template.Sections.Any(s => s.Value == model.Section))
                {
                    KeyValuePair <string, Section> templateSection = template.Sections.Where(s => s.Value == model.Section).Single();
                    sectionTemplate.Placeholder = templateSection.Key;
                    sectionTemplate.IsAttached  = true;
                }
                model.SectionTemplates.Add(template.Id, sectionTemplate);
            }
            return(View(model));
        }
 public ActionResult AttachSectionToTemplate(int id)
 {
     var model = new AttachSectionTemplateViewData();
     model.Section = this._sectionService.GetSectionById(id);
     model.Templates = this._templateService.GetAllTemplatesBySite(CuyahogaContext.CurrentSite);
     foreach (var template in model.Templates)
     {
         // read placeholders
         string virtualTemplatePath = VirtualPathUtility.Combine(CuyahogaContext.CurrentSite.SiteDataDirectory, template.Path);
         model.PlaceHoldersByTemplate[template] = ViewUtil.GetPlaceholdersFromVirtualPath(virtualTemplatePath).Select(p => p.Key).ToArray();
         // add sectiontemplate viewdata
         var sectionTemplate = new SectionTemplateViewData();
         sectionTemplate.TemplateId = template.Id;
         if (template.Sections.Any(s => s.Value == model.Section))
         {
             KeyValuePair<string, Section> templateSection = template.Sections.Where(s => s.Value == model.Section).Single();
             sectionTemplate.Placeholder = templateSection.Key;
             sectionTemplate.IsAttached = true;
         }
         model.SectionTemplates.Add(template.Id, sectionTemplate);
     }
     return View(model);
 }