public List <Page> GetCatalogPages(int catalogId)
        {
            var pageRepository = new PageRepository(_appDbContext);
            var pages          = new List <Page>();

            //Add front- and backpage
            var frontPage = new Page {
                Type = Enums.pageTypes.FrontPage, Title = "Forsiden", Moniker = "Forside", SortNumber = 1
            };
            var backPage = new Page {
                Type = Enums.pageTypes.BackPage, Title = "Bagsiden", Moniker = "Bagside", SortNumber = 99
            };

            pages.Add(frontPage);
            pages.Add(backPage);

            foreach (var item in _appDbContext.CatalogPages)
            {
                if (item.CatalogId == catalogId)
                {
                    var page = pageRepository.GetPageById(item.PageId).Page;

                    if (page.Status == Enums.pageStatus.Active)
                    {
                        pages.Add(page);
                    }
                }
            }

            pages = pages.OrderBy(p => p.SortNumber).ToList();

            return(pages);
        }
        public void AddPageToCatalog(int catalogId, int pageId)
        {
            var pageRepository = new PageRepository(_appDbContext);
            var catalog        = GetCatalogById(catalogId);
            var page           = pageRepository.GetPageById(pageId).Page;

            _appDbContext.Add(new CatalogPages {
                Catalog = catalog.Catalog, Page = page
            });
            _appDbContext.SaveChanges();
        }
예제 #3
0
        public void AddTagToPage(int tagId, int pageId)
        {
            var pageRepository = new PageRepository(_appDbContext);
            var tag            = GetTagById(tagId);
            var page           = pageRepository.GetPageById(pageId).Page;

            _appDbContext.Add(new TagPages {
                Page = page, Tag = tag
            });
            _appDbContext.SaveChanges();
        }
예제 #4
0
        public IEnumerable <Page> GetPagesForTag(int tagId)
        {
            var pageRepository = new PageRepository(_appDbContext);
            var pages          = new List <Page>();

            foreach (var item in _appDbContext.TagPages)
            {
                if (item.TagId == tagId)
                {
                    pages.Add(pageRepository.GetPageById(item.PageId).Page);
                }
            }

            return(pages);
        }