예제 #1
0
        /// <summary>
        /// Get possible parent menu
        /// </summary>
        /// <param name="id">the current menu id</param>
        /// <returns></returns>
        public IEnumerable <SelectListItem> GetPossibleParents(int?id = null)
        {
            var pageTemplates = GetAll();
            int?parentId      = null;
            var template      = GetById(id);

            if (template != null)
            {
                parentId      = template.ParentId;
                pageTemplates = _pageTemplateRepository.GetPossibleParents(template);
            }
            var data = pageTemplates.Select(m => new HierarchyModel
            {
                Id          = m.Id,
                Name        = m.Name,
                Hierarchy   = m.Hierarchy,
                RecordOrder = m.RecordOrder,
                Selected    = parentId.HasValue && parentId.Value == m.Id
            }).ToList();

            return(_pageTemplateRepository.BuildSelectList(data, false));
        }