Esempio n. 1
0
        public async Task <NavigationModel <PrintingEditionModel> > GetAsync(EditionFiltrPaginSortModel model)
        {
            var editionFiltrPagingSortModelDAL = _mapper.Map <EditionFiltrPagingSortModelDAL>(model);

            (IEnumerable <PrintingEdition> editions, int count)editionsCount = await _printingEditionRepository.GetAsync(editionFiltrPagingSortModelDAL);

            if (!editionsCount.editions.Any())
            {
                throw new CustomExeption(Constants.Error.NO_ANY_EDITIONS_IN_DB_WITH_THIS_CONDITIONS,
                                         StatusCodes.Status400BadRequest);
            }

            var editionModels = _mapper.Map <IEnumerable <PrintingEditionModel> > (editionsCount.count);

            PaginatedPageModel paginatedPage = new PaginatedPageModel(editionsCount.count, model.CurrentPage, model.PageSize);
            NavigationModel <PrintingEditionModel> navigation = new NavigationModel <PrintingEditionModel>
            {
                PageModel    = paginatedPage,
                EntityModels = editionModels
            };

            return(navigation);
        }
        public async Task <IActionResult> GetEditions(EditionFiltrPaginSortModel model)
        {
            var result = await _editionService.GetAsync(model);

            return(Ok(result));
        }