public async Task <PrintingEditionPageDataModel> GetPageAsync( PageModel <PrintingEditionFilterModel> pageModel) { var printingEditions = await _printingEditionRepository.GetPageAsync(new PageOptions <PrintingEditionFilter> { Filter = pageModel.Filter == null ? null : new PrintingEditionFilter { Title = pageModel.Filter.Title, Description = pageModel.Filter.Description, Currency = pageModel.Filter.Currency, MinPrice = pageModel.Filter.MinPrice, MaxPrice = pageModel.Filter.MaxPrice, Types = pageModel.Filter.Types, CreationDate = pageModel.Filter.CreationDate, SearchString = pageModel.Filter.SearchString }, Page = pageModel.Page, PageSize = pageModel.PageSize, SortField = pageModel.SortField, SortOrder = pageModel.SortOrder }); List <PrintingEditionModel> printingEditionModels = _printingEditionMapper.Map(printingEditions); PriceRange priceRange = await _printingEditionRepository.GetPriceRangeAsync(pageModel.Filter.Currency); return(new PrintingEditionPageDataModel { Data = printingEditionModels, Length = printingEditions.TotalItemCount, MinPrice = priceRange.MinPrice, MaxPrice = priceRange.MaxPrice }); }
public async Task <PagedResponse <PrintingEditionModel> > GetPageAsync(PaginationRequest <PrintingEditionFilter> page) { var printingEditions = await _printingEditionRepository.GetPageAsync(page); var mapped = _mapper.Map <IEnumerable <PrintingEditionModel> >(printingEditions); var response = new PagedResponse <PrintingEditionModel> { Data = mapped, PageNumber = page.PageNumber, PageSize = page.PageSize, HasNextPage = printingEditions.HasNextPage, HasPreviousPage = printingEditions.HasPreviousPage }; if (page.Filter is null || page.Filter.Currency is null) { return(response); } foreach (var item in mapped) { item.Price = _converter.Convert(item.Price, item.Currency, page.Filter.Currency); item.Currency = (CurrencyType)page.Filter.Currency; } return(response); }