Exemplo n.º 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 pages    = GetAll();
            int?parentId = null;
            var page     = GetById(id);

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

            return(_pageRepository.BuildSelectList(data));
        }