Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pageId"></param>
        /// <returns></returns>
        public ResponseModel SavePageToClientMenu(int pageId)
        {
            var page       = _pageRepository.GetById(pageId);
            var clientMenu = FetchFirst(c => c.PageId == pageId);

            if (clientMenu != null)
            {
                clientMenu.Name   = page.Title;
                clientMenu.PageId = page.Id;
                clientMenu.Url    = page.FriendlyUrl;
                if (page.ParentId.HasValue && page.Page1.ClientMenus.Any())
                {
                    clientMenu.ParentId = page.Page1.ClientMenus.First().Id;
                }
                else
                {
                    clientMenu.ParentId = null;
                }
                clientMenu.IncludeInSiteNavigation = page.IncludeInSiteNavigation;
                clientMenu.StartPublishingDate     = page.StartPublishingDate;
                clientMenu.EndPublishingDate       = page.EndPublishingDate;
                if (page.RecordOrder * 10 != clientMenu.RecordOrder)
                {
                    var relativePages = _pageRepository.Fetch(p => (page.ParentId.HasValue ? p.ParentId == page.ParentId : !p.ParentId.HasValue) && p.Id != page.Id);
                    foreach (var relativePage in relativePages)
                    {
                        var relativeMenu = relativePage.ClientMenus.First();
                        relativeMenu.RecordOrder = relativePage.RecordOrder * 10;
                        Update(relativeMenu);
                    }
                    clientMenu.RecordOrder = page.RecordOrder * 10;
                }
                clientMenu.RecordActive = page.RecordActive;
                return(HierarchyUpdate(clientMenu));
            }
            clientMenu = new ClientMenu(page);
            return(HierarchyInsert(clientMenu));
        }
Exemplo n.º 2
0
 public IQueryable <Page> Fetch(Expression <Func <Page, bool> > expression)
 {
     return(_pageRepository.Fetch(expression));
 }