Example #1
0
        public static CollectionPage<MenuItem> GetMany(Expression<Func<MenuItem, bool>> where, int page, int itemsPerPage)
        {
            IQueryable<MenuItem> query = entities.MenuItems;

            if (where != null)
            {
               query = query.Where(where);
            }

            query = ((IOrderedQueryable<MenuItem>)query).OrderBy(item => (true));

            var pageOfResult = new CollectionPage<MenuItem>()
            {
                TotalItems = query.Count(),
                ItemsPerPage = itemsPerPage,
                Items = query.Skip(itemsPerPage * (page - 1)).Take(itemsPerPage).ToList()
            };
            return pageOfResult;
        }
        private async Task <List <TResource> > getList <TResource>(string uri) where TResource : DataContracts.Resource
        {
            List <TResource> resources = new List <TResource>();

            string pageUri = uri;

            do
            {
                CollectionPage <TResource> pageCollection = await fetchResources <TResource>(pageUri);

                if (pageCollection == null)
                {
                    break;
                }

                if (pageCollection.totalSize > 0)
                {
                    foreach (var p in pageCollection.page)
                    {
                        resources.Add(p);
                    }

                    if (pageCollection.nextPage != null)
                    {
                        pageUri = pageCollection.nextPage.AbsoluteUri;
                    }
                    else
                    {
                        pageUri = string.Empty;
                    }
                }
                else
                {
                    //no results so break out of loop
                    break;
                }
            } while (!string.IsNullOrEmpty(pageUri));
            return(resources);
        }
        /// <inheritdoc />
        ICollectionPage <TValue> IConverter <IResponse <ICollection <TDTO> >, ICollectionPage <TValue> > .Convert(IResponse <ICollection <TDTO> > value, object state)
        {
            if (value == null)
            {
                return(new CollectionPage <TValue>(0));
            }

            // MEMO: expect the page index as state argument, because we can't parse Link headers yet
            var pageIndex = state as int?;

            if (!pageIndex.HasValue)
            {
                throw new ArgumentException("Precondition: state is int", "state");
            }

            var dataContracts = value.Content;

            if (dataContracts == null)
            {
                return(new CollectionPage <TValue>(0));
            }

            var page = new CollectionPage <TValue>(dataContracts.Count)
            {
                PageSize      = value.GetPageSize(),
                PageCount     = value.GetPageTotal(),
                SubtotalCount = value.GetResultCount(),
                TotalCount    = value.GetResultTotal()
            };

            page.AddRange(dataContracts.Select(dataContract => this.dataContractConverter.Convert(dataContract, value)));

            // TODO: replace this code with an implementation of the Link header
            PageContextPatchUtility.Patch(page, pageIndex.Value);

            return(page);
        }
 public CollectionPageController <TItem> BuildController <TItem>(CollectionPageControllerMocks <TItem> mocks, CollectionPage <TItem> page)
     where TItem : class, IEntity
 {
     return(new CollectionPageController <TItem>
            (
                mocks.LrpNavigation.Object,
                mocks.CollectionPageViewModel.Object,
                page,
                mocks.ItemMvcBuilder.Object
            ));
 }
 public GetSiteDesignCollectionResponse()
 {
     this.Value = new CollectionPage <SiteDesignMetadata>();
 }
Example #6
0
 public GetCollectionResponse()
 {
     this.Value = new CollectionPage <T>();
 }
Example #7
0
 private void NagivateToSelectedPage()
 {
     this.eventAggregator.GetEvent <IsCollectionPageChanged>().Publish(
         new Tuple <SlideDirection, CollectionPage>(this.selectedPage >= this.previousPage ? SlideDirection.RightToLeft : SlideDirection.LeftToRight, this.selectedPage));
     previousPage = this.selectedPage;
 }
Example #8
0
        public void MergeFrom(AtlasInventoryItem other)
        {
            if (other == null)
            {
                return;
            }
            switch (other.TypeCase)
            {
            case TypeOneofCase.Profile:
                if (Profile == null)
                {
                    Profile = new global::WUProtos.Data.Player.PlayerProfile();
                }
                Profile.MergeFrom(other.Profile);
                break;

            case TypeOneofCase.VaultItem:
                if (VaultItem == null)
                {
                    VaultItem = new global::WUProtos.Inventory.InventoryVaultItem();
                }
                VaultItem.MergeFrom(other.VaultItem);
                break;

            case TypeOneofCase.CollectionItem:
                if (CollectionItem == null)
                {
                    CollectionItem = new global::WUProtos.Inventory.InventoryCollectionItem();
                }
                CollectionItem.MergeFrom(other.CollectionItem);
                break;

            case TypeOneofCase.CollectionFamily:
                if (CollectionFamily == null)
                {
                    CollectionFamily = new global::WUProtos.Inventory.InventoryCollectionFamily();
                }
                CollectionFamily.MergeFrom(other.CollectionFamily);
                break;

            case TypeOneofCase.Walkbox:
                if (Walkbox == null)
                {
                    Walkbox = new global::WUProtos.Inventory.InventoryWalkboxItem();
                }
                Walkbox.MergeFrom(other.Walkbox);
                break;

            case TypeOneofCase.PlayerFlags:
                if (PlayerFlags == null)
                {
                    PlayerFlags = new global::WUProtos.Inventory.InventoryFeatureFlags();
                }
                PlayerFlags.MergeFrom(other.PlayerFlags);
                break;

            case TypeOneofCase.Portkey:
                if (Portkey == null)
                {
                    Portkey = new global::WUProtos.Inventory.InventoryPortkeyItem();
                }
                Portkey.MergeFrom(other.Portkey);
                break;

            case TypeOneofCase.PlayerActiveBuffList:
                if (PlayerActiveBuffList == null)
                {
                    PlayerActiveBuffList = new global::WUProtos.Data.Buff.ActiveBuffList();
                }
                PlayerActiveBuffList.MergeFrom(other.PlayerActiveBuffList);
                break;

            case TypeOneofCase.CollectionPage:
                if (CollectionPage == null)
                {
                    CollectionPage = new global::WUProtos.Inventory.InventoryCollectionPage();
                }
                CollectionPage.MergeFrom(other.CollectionPage);
                break;

            case TypeOneofCase.VaultCapacity:
                if (VaultCapacity == null)
                {
                    VaultCapacity = new global::WUProtos.Inventory.InventoryVaultCapacity();
                }
                VaultCapacity.MergeFrom(other.VaultCapacity);
                break;

            case TypeOneofCase.Cauldron:
                if (Cauldron == null)
                {
                    Cauldron = new global::WUProtos.Inventory.InventoryCauldron();
                }
                Cauldron.MergeFrom(other.Cauldron);
                break;

            case TypeOneofCase.EscrowedRewards:
                if (EscrowedRewards == null)
                {
                    EscrowedRewards = new global::WUProtos.Inventory.InventoryEscrowedRewards();
                }
                EscrowedRewards.MergeFrom(other.EscrowedRewards);
                break;

            case TypeOneofCase.ProfessionsProgressV3:
                if (ProfessionsProgressV3 == null)
                {
                    ProfessionsProgressV3 = new global::WUProtos.Data.Player.PlayerProfessionsProgressV3();
                }
                ProfessionsProgressV3.MergeFrom(other.ProfessionsProgressV3);
                break;

            case TypeOneofCase.QuestLog:
                if (QuestLog == null)
                {
                    QuestLog = new global::WUProtos.Inventory.InventoryQuestLog();
                }
                QuestLog.MergeFrom(other.QuestLog);
                break;

            case TypeOneofCase.Achievement:
                if (Achievement == null)
                {
                    Achievement = new global::WUProtos.Data.Player.PlayerAchievement();
                }
                Achievement.MergeFrom(other.Achievement);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Example #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (typeCase_ == TypeOneofCase.Profile)
            {
                hash ^= Profile.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.VaultItem)
            {
                hash ^= VaultItem.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.CollectionItem)
            {
                hash ^= CollectionItem.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.CollectionFamily)
            {
                hash ^= CollectionFamily.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Walkbox)
            {
                hash ^= Walkbox.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.PlayerFlags)
            {
                hash ^= PlayerFlags.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Portkey)
            {
                hash ^= Portkey.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.PlayerActiveBuffList)
            {
                hash ^= PlayerActiveBuffList.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.CollectionPage)
            {
                hash ^= CollectionPage.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.VaultCapacity)
            {
                hash ^= VaultCapacity.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Cauldron)
            {
                hash ^= Cauldron.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.EscrowedRewards)
            {
                hash ^= EscrowedRewards.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.ProfessionsProgressV3)
            {
                hash ^= ProfessionsProgressV3.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.QuestLog)
            {
                hash ^= QuestLog.GetHashCode();
            }
            if (typeCase_ == TypeOneofCase.Achievement)
            {
                hash ^= Achievement.GetHashCode();
            }
            hash ^= (int)typeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #10
0
 /// <summary>
 /// Retrieves a collection of blog posts by page.
 /// </summary>
 /// <param name="page">The desired page.</param>
 /// <param name="itemsPerPage">The number of blog posts to display per page.</param>
 /// <returns>A collection of blog posts.</returns>
 public CollectionPage<BlogPost> GetBlogPosts(int page, int itemsPerPage)
 {
     var result = _dataContext.BlogPosts
         .OrderByDescending(x => x.PostedDate)
         .Skip((page - 1) * itemsPerPage)
         .Take(itemsPerPage);
     var collectionPage = new CollectionPage<BlogPost>
     {
         Items = result,
         TotalItems = _dataContext.BlogPosts.Count()
     };
     return collectionPage;
 }
Example #11
0
 /// <summary>
 /// Retrieves a collection of blog posts related to the supplied search term.
 /// </summary>
 /// <param name="query">The search query.</param>
 /// <param name="page">The desired page.</param>
 /// <param name="itemsPerPage">The number of blog posts to display per page.</param>
 /// <returns>A collection of blog posts.</returns>
 public CollectionPage<BlogPost> SearchBlogPosts(string query, int page, int itemsPerPage)
 {
     var result = _dataContext.BlogPosts
         .Where(BlogPostContains(query));
     var collectionPage = new CollectionPage<BlogPost>
     {
         Items = result
             .OrderByDescending(x => x.PostedDate)
             .Skip((page - 1) * itemsPerPage)
             .Take(itemsPerPage),
         TotalItems = result.Count()
     };
     return collectionPage;
 }
Example #12
0
 public GetSiteDesignRunCollectionResponse()
 {
     this.Value = new CollectionPage <SiteDesignRun>();
 }
Example #13
0
 public GetSiteScriptCollectionResponse()
 {
     this.Value = new CollectionPage <SiteScriptMetadata>();
 }