public ActionResult <string> GetNFeFromDataBase(string id)
        {
            try
            {
                DAOBase <NotaFiscal> dao = new DAOBase <NotaFiscal>();

                NotaFiscal nf = null;

                nf = dao.Get(w => w.access_key == id);
                if (nf != null)
                {
                    string sTotalValue = nf.total_nota.ToString();
                    return("Nota: \"" + id + "\"\nValor: " + sTotalValue);
                }
                else
                {
                    throw new Exception("Nota: \"" + id + "\" nao encontrada");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Erro: {0}", e);
                return(e.Message);
            }
        }
        private ApiResponse ValidateEmpresa(Empresa empresa)
        {
            ApiResponse resp = new ApiResponse();

            if (empresa == null)
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Conteudo vazio");
                return(resp);
            }

            if (string.IsNullOrEmpty(empresa.s_nomefantasia))
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("Nome fantasia nao informado");
                return(resp);
            }

            if (string.IsNullOrEmpty(empresa.s_cnpj))
            {
                resp.Success   = false;
                resp.ErrorList = new List <string>();
                resp.ErrorList.Add("CNPJ nao informado");
                return(resp);
            }

            if (empresa.id_empresa_pai != null)
            {
                if ((int)empresa.id_empresa_pai <= 0)
                {
                    resp.Success   = false;
                    resp.ErrorList = new List <string>();
                    resp.ErrorList.Add("Empresa pai invalida");
                    return(resp);
                }

                DAOBase <Empresa> dao = new DAOBase <Empresa>();
                Empresa           n   = dao.GetById((int)empresa.id_empresa_pai);
                if (n == null)
                {
                    resp.Success   = false;
                    resp.ErrorList = new List <string>();
                    resp.ErrorList.Add("Empresa pai: " + empresa.id_empresa_pai + " informado inexistente");
                    return(resp);
                }
            }

            if (empresa.id_tipo_empresa_pai != null)
            {
                if ((int)empresa.id_tipo_empresa_pai <= 0)
                {
                    resp.Success   = false;
                    resp.ErrorList = new List <string>();
                    resp.ErrorList.Add("Empresa pai invalida");
                    return(resp);
                }

                DAOBase <TipoEmpresaPai> dao = new DAOBase <TipoEmpresaPai>();
                TipoEmpresaPai           n   = dao.GetById((int)empresa.id_tipo_empresa_pai);
                if (n == null)
                {
                    resp.Success   = false;
                    resp.ErrorList = new List <string>();
                    resp.ErrorList.Add("Tipo empresa pai: " + empresa.id_tipo_empresa_pai + " informado inexistente");
                    return(resp);
                }
            }

            if (empresa.id_usuario_participante != null)
            {
                if ((int)empresa.id_usuario_participante <= 0)
                {
                    resp.Success   = false;
                    resp.ErrorList = new List <string>();
                    resp.ErrorList.Add("Participante invalido");
                    return(resp);
                }

                DAOBase <Usuario> dao = new DAOBase <Usuario>();
                Usuario           n   = dao.GetById((int)empresa.id_usuario_participante);
                if (n == null)
                {
                    resp.Success   = false;
                    resp.ErrorList = new List <string>();
                    resp.ErrorList.Add("Participante: " + empresa.id_usuario_participante + " informado inexistente");
                    return(resp);
                }
                else
                {
                    DAOBase <TipoUsuario> daoTU   = new DAOBase <TipoUsuario>();
                    TipoUsuario           tuParti = daoTU.Get(w => w.s_codigo == "PAR");
                    if (tuParti != null)
                    {
                        if (n.id_tipo_usuario != tuParti.id)
                        {
                            resp.Success   = false;
                            resp.ErrorList = new List <string>();
                            resp.ErrorList.Add("Usuario informado não é um participante");
                            return(resp);
                        }
                    }
                    else
                    {
                        resp.Success   = false;
                        resp.ErrorList = new List <string>();
                        resp.ErrorList.Add("Entidade Participante não encontrado no sistema");
                        return(resp);
                    }
                }
            }

            resp.Success = true;
            return(resp);
        }