Esempio n. 1
0
        public async Task <IPaginatedEnumerable <PublisherDto> > GetByFilter(PublisherFilter filter)
        {
            var searchText = (filter.Search ?? string.Empty).ToLower();

            var query = await this.GetAll();

            if (!string.IsNullOrEmpty(searchText))
            {
                query = query.Where(g => g.Name.ToLower().Contains(searchText));
            }

            query = query.OrderBy(g => g.Id);

            var totalCount = query.Count();

            query = query.Skip(filter.Skip);
            query = query.Take(filter.Take);
            var collection = await query.ToListAsync();

            return(new PaginatedEnumerable <PublisherDto>(collection.Select(g => g.ToDto()), totalCount));
        }
Esempio n. 2
0
        public void Check_That_PublisherFilter_Returns_Right_Delegate()
        {
            // Arrange
            var container = new GameFilterContainer
            {
                Model = new GamesFilterModel
                {
                    Publishers = new List <int> {
                        1, 2
                    }
                }
            };

            var filter = new PublisherFilter();

            var list = new List <Game>
            {
                new Game
                {
                    PublisherId = 1,
                },
                new Game
                {
                    PublisherId = 2,
                },
                new Game
                {
                    PublisherId = 3,
                },
            };

            // Act
            filter.Execute(container);
            Func <Game, bool> resultCondition = CombinePredicate <Game> .CombineWithAnd(container.Conditions);

            IEnumerable <Game> result = list.Where(x => (resultCondition(x)));

            // Assert
            Assert.IsTrue(result.Count() == 2);
        }
Esempio n. 3
0
        public CrayonApiClientResult <ApiCollection <Publisher> > Get(string token, PublisherFilter filter = null)
        {
            var uri = "/api/v1/publishers/".Append(filter);

            return(_client.Get <ApiCollection <Publisher> >(token, uri));
        }
Esempio n. 4
0
 public PublishersController(IUnitOfWork uow)
 {
     this.uow = uow;
     pf       = new PublisherFilter(uow);
 }
Esempio n. 5
0
 public async Task <IHttpActionResult> Get([FromUri] PublisherFilter filter)
 {
     return(this.Ok(await this._publisherRepository.GetByFilter(filter)));
 }