void IPageCollection.SetSortModel(PageSortMode sortMode)
 {
     SortMode = sortMode;
 }
Esempio n. 2
0
        public async Task <IPageCollection> CreateCollectionAsync(string webSiteId, string title, string pageTypeName, PageSortMode sortMode, Guid?pageId = null)
        {
            if (webSiteId == null)
            {
                throw new ArgumentNullException(nameof(webSiteId));
            }
            if (title == null)
            {
                throw new ArgumentNullException(nameof(title));
            }
            if (pageTypeName == null)
            {
                throw new ArgumentNullException(nameof(pageTypeName));
            }

            var collection = new PageCollectionDocument
            {
                Id           = Guid.NewGuid(),
                CreatedDate  = DateTime.UtcNow,
                WebsiteId    = webSiteId,
                Version      = 1,
                Title        = title,
                PageTypeName = pageTypeName,
                SortMode     = sortMode,
                PageId       = pageId
            };

            await documents.InsertOneAsync(collection);

            return(collection);
        }
        public async Task <Result <IPageCollection> > CreateCollectionAsync(string title, string pageTypeName, PageSortMode sortMode, Guid?pageId)
        {
            if (pageId.HasValue)
            {
                var page = await pageRepositiry.FindPageByIdAsync(pageId.Value);

                if (page == null)
                {
                    throw new ArgumentException();
                }

                if (!page.IsPublished)
                {
                    return(Result <IPageCollection> .Failed("Нельзя создать коллекцию страниц для страницы, которая не опубликована."));
                }
            }

            var collection = await repositiry.CreateCollectionAsync(websiteContext.Website.Id, title, pageTypeName, sortMode, pageId);

            return(Result <IPageCollection> .Success(collection));
        }
        public Task <IPageCollection> CreateCollectionAsync(string webSiteId, string title, string pageTypeName, PageSortMode sortMode, Guid?pageId)
        {
            var pageCollectionId = Guid.NewGuid();
            var pageCollection   = new PageCollection(pageCollectionId, webSiteId, title, pageTypeName, pageId)
            {
                SortMode = sortMode
            };

            collectionIndex++;
            var index = collectionIndex;

            collections.Add(index, pageCollection);
            collectionIds.Add(pageCollectionId, index);

            pageHierarhy.OnAddCollection(pageId, pageCollection);

            return(Task.FromResult <IPageCollection>(pageCollection));
        }