public PagedResponse <PersonDTO> GetAll(PaginationQuery paginationQuery = null) { var paginationFilter = _mapper.Map <PaginationFilter>(paginationQuery); var persons = _servicePerson.GetAll(paginationFilter); var paginationResponse = _mapper.Map <IEnumerable <PersonDTO> >(persons); if (paginationFilter == null || paginationFilter.PageNumber < 1 || paginationFilter.PageSize < 1) { return(new PagedResponse <PersonDTO>(paginationResponse)); } var nextPage = paginationFilter.PageNumber >= 1 ? _serviceUri.GetAllRequestsUri(new PaginationQuery(paginationFilter.PageNumber + 1, paginationFilter.PageSize)).ToString() : null; var previousPage = paginationFilter.PageNumber - 1 >= 1 ? _serviceUri.GetAllRequestsUri(new PaginationQuery(paginationFilter.PageNumber - 1, paginationFilter.PageSize)).ToString() : null; return(new PagedResponse <PersonDTO> { Data = paginationResponse, PageNumber = paginationFilter.PageNumber >= 1 ? paginationFilter.PageNumber : (int?)null, PageSize = paginationFilter.PageSize >= 1 ? paginationFilter.PageSize : (int?)null, NextPage = paginationResponse.Any() ? nextPage : null, PreviousPage = previousPage }); }
protected override IEnumerable <PersonReadDto> Handle(PersonGetAllQuery request) { var personList = _personService.GetAll(); if (personList != null) { return(_mapper.Map <IEnumerable <Person>, IEnumerable <PersonReadDto> >(personList)); } else { return(null); } }
public IEnumerable <PersonDTO> GetAll() { var person = _servicePerson.GetAll(); return(_mapper.Map <IEnumerable <PersonDTO> >(person)); }