Esempio n. 1
0
        public static void Try1()
        {
            var repository = new AnotherProductsRepository();
            var products   = repository.GetAll();

            int offset = 0, limit = 10;
            var subset = OffsetLimitEnumerable.Create(products, offset, limit);

            var all  = PagedEnumerable.Create(products, 2, 10);
            var all2 = all.CastMetadataEnumerable(p => new ProductWrapper(p));
            var dto  = all2.ToMetadataObject();
        }
Esempio n. 2
0
        public void Given_builder_which_is_null_When_a_PagedEnumerable_is_created_Then_an_ArgumentNullException_should_be_thrown()
        {
            // Given.
            PagedEnumerableBuilder <object> builder = null;

            // When.
            Action testCode = () => PagedEnumerable <object> .Create(builder);

            // Then.
            testCode.Should()
            .Throw <ArgumentNullException>()
            .WithMessage("*cannot be null*builder*");
        }
Esempio n. 3
0
        /// <summary>
        /// Get user's projects.
        /// </summary>
        /// <param name="userId">User id the projects related to.</param>
        /// <param name="page">Page number.</param>
        /// <param name="pageSize">Page size, default is 10.</param>
        /// <returns>Projects paged enumerable.</returns>
        public PagedEnumerable <ProjectDto> GetByUser(string userId, int page, int pageSize = 10)
        {
            var query = uow.ProjectRepository.Find(p => p.User.Id == userId).Select(p => new ProjectDto(p));

            return(PagedEnumerable.Create(query, page, pageSize));
        }