Пример #1
0
        public PagingResource <BookResource> GetCutoffUnmetBooks(bool includeAuthor = false)
        {
            var pagingResource = Request.ReadPagingResourceFromRequest <BookResource>();
            var pagingSpec     = new PagingSpec <Book>
            {
                Page          = pagingResource.Page,
                PageSize      = pagingResource.PageSize,
                SortKey       = pagingResource.SortKey,
                SortDirection = pagingResource.SortDirection
            };

            var filter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");

            if (filter != null && filter.Value == "false")
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Author.Value.Monitored == false);
            }
            else
            {
                pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true);
            }

            return(pagingSpec.ApplyToPage(_bookCutoffService.BooksWhereCutoffUnmet, v => MapToResource(v, includeAuthor)));
        }