public PagedSearchDTO <Curso> FindWithPagedSearch(string name, string sortDirection, int pageSize, int page)
        {
            page = page > 0 ? page - 1 : 0;
            string query = @"select * from Cursos p where 1 = 1 ";

            if (!string.IsNullOrEmpty(name))
            {
                query = query + $" and p.firstName like '%{name}%'";
            }

            query = query + $" order by p.firstName {sortDirection} limit {pageSize} offset {page}";

            string countQuery = @"select count(*) from Cursos p where 1 = 1 ";

            if (!string.IsNullOrEmpty(name))
            {
                countQuery = countQuery + $" and p.firstName like '%{name}%'";
            }

            var pessoas = _repository.FindWithPagedSearch(query);

            int totalResults = _repository.GetCount(countQuery);

            return(new PagedSearchDTO <Curso>
            {
                CurrentPage = page + 1,
                List = _mapper.Map <List <Curso>, List <Curso> >(pessoas),
                PageSize = pageSize,
                SortDirections = sortDirection,
                TotalResults = totalResults
            });
        }