Example #1
0
        public async Task <IActionResult> GetAsync([FromQuery] GetBooksParameters parameters)
        {
            var booksQuery = _booksReader.Query();

            var result = await _pagingService.GetPagedQuery(booksQuery, new PagingParameters(parameters.PageNumber, parameters.PageSize)).ToListAsync();

            return(Ok(result));
        }
Example #2
0
        public IEnumerable <GetBooksResult> GetBooks(GetBooksParameters parameters)
        {
            return(new SqlQuery(Settings).ExecuteObjectArray(
                       query: "GetBooks",
                       parameters: _ =>
            {
                if (parameters == null)
                {
                    return;
                }

                _.AddWithValue("@AppUserId", parameters.AppUserId);
            },
                       mapping: reader => new GetBooksResult()
            {
                AppUserId = reader["AppUserId"] as Int32?,
                BookId = reader["BookId"] as Int32?,
                Title = reader["Title"] as String,
                Author = reader["Author"] as String,
                Comment = reader["Comment"] as String
            }
                       ));
        }