internal override async Task <IList <IEmpresa> > GetsAsync(int paginaIndex, string filtro, int registroPorPagina)
        {
            var connection = this.repositorio.Contexto.Database.GetDbConnection();

            if (connection.State == ConnectionState.Closed)
            {
                this.repositorio.Contexto.Database.GetDbConnection().Open();
            }


            if (paginaIndex < 0)
            {
                paginaIndex = 0;
            }
            if (!string.IsNullOrEmpty(filtro) &&
                !string.IsNullOrWhiteSpace(filtro))
            {
                this.repositorio.createTransacao();
                IQueryable <Empresa> query = (from q in this.repositorio.Contexto.Set <Empresa>()
                                              where q.Status != "INA" &&
                                              q.CnpjCpf.ToUpper().Contains(filtro.ToUpper()) &&
                                              q.Nome.ToUpper().Contains(filtro.ToUpper()) &&
                                              q.NomeFantasia.ToUpper().Contains(filtro.ToUpper()) &&
                                              q.Status.ToUpper().Contains(filtro.ToUpper())
                                              select q
                                              );
                _totalRegistro = repositorio.Set(query).Get().Count();

                query = (from q in this.repositorio.Contexto.Set <Empresa>()
                         where q.Status != "INA" &&
                         q.CnpjCpf.ToUpper().Contains(filtro.ToUpper()) &&
                         q.Nome.ToUpper().Contains(filtro.ToUpper()) &&
                         q.NomeFantasia.ToUpper().Contains(filtro.ToUpper()) &&
                         q.Status.ToUpper().Contains(filtro.ToUpper())
                         select q
                         ).Skip(paginaIndex).Distinct();
            }
            else
            {
                this.repositorio.createTransacao();
                IQueryable <Empresa> query = (from q in this.repositorio.Contexto.Set <Empresa>()
                                              where q.Status != "INA"
                                              select q
                                              );
                _totalRegistro = repositorio.Set(query).Get().Count();

                query = (from q in this.repositorio.Contexto.Set <Empresa>()
                         where q.Status != "INA"
                         select q
                         ).Skip(paginaIndex).Distinct();
            }
            List <Empresa> empresas = await repositorio.Get().ToListAsync();

            IList <IEmpresa> IEmpresas = empresas.ConvertAll(new Converter <Empresa, IEmpresa>(ConverterEmpresa.converterEmpresaParaIEmpresa));

            return(IEmpresas);
        }
        public Empresas GetEmpresa(int id)
        {
            Empresas item = repositorio.Get(id);

            if (item == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(item);
        }