Exemplo n.º 1
0
        public async Task <NavigationModel <AuthorModel> > GetAsync(AuthorFiltrPagingSortModel model)
        {
            var authorFiltrPagingSortModelDAL = _mapper.Map <AuthorFiltrPagingSortModelDAL>(model);

            (IEnumerable <Author> authors, int count)authorsWithCount = await _authorRepository.GetAsync(authorFiltrPagingSortModelDAL);

            if (!authorsWithCount.authors.Any())
            {
                throw new CustomExeption(Constants.Error.NO_ANY_AUTHOR_IN_DB_WITH_THIS_CONDITIONS,
                                         StatusCodes.Status400BadRequest);
            }
            var authorModels = _mapper.Map <IEnumerable <AuthorModel> >(authorsWithCount.authors);

            PaginatedPageModel            paginatedPage = new PaginatedPageModel(authorsWithCount.count, model.CurrentPage, model.PageSize);
            NavigationModel <AuthorModel> result        = new NavigationModel <AuthorModel>
            {
                PageModel    = paginatedPage,
                EntityModels = authorModels
            };

            return(result);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get(AuthorFiltrPagingSortModel model)
        {
            var result = await _authorService.GetAsync(model);

            return(Ok(result));
        }