Exemple #1
0
        public ActionResult FiltroEmpresa(EmpresaFiltroListagemDto filtro)
        {
            try
            {
                var modelo = new EmpresaLista();
                if (filtro.DataCadastro == null && filtro.CNPJ == null && filtro.NomeFantasia == null)
                {
                    modelo.EmpresaList = _empresaApp.BuscarTodos().Result.Objeto;
                }
                else
                {
                    var retornoBusca = _empresaApp.BuscarFiltroListagem(filtro).Result.Objeto;

                    if (retornoBusca.Count > 0)
                    {
                        modelo.EmpresaList = retornoBusca;
                        modelo.EmpresaList = modelo.EmpresaList.OrderByDescending(x => x.Codigo).ToList();
                    }
                    else
                    {
                        modelo.EmpresaList = _empresaApp.BuscarTodos().Result.Objeto;
                    }
                }

                return(View("ConsultaEmpresaView", modelo));
            }
            catch (Exception ex)
            {
                return(View("ErrorHandler", new ErrorHandler()
                {
                    Erro = ex.Message, DetalhamentoErro = ex.StackTrace
                }));
            }
        }
Exemple #2
0
        public ActionResult Index()
        {
            try
            {
                var modelo       = new EmpresaLista();
                var retornoBusca = _empresaApp.BuscarTodos().Result.Objeto;

                if (retornoBusca.Count > 0)
                {
                    modelo.EmpresaList = retornoBusca;
                    modelo.EmpresaList = modelo.EmpresaList.OrderByDescending(x => x.Codigo).ToList();
                }
                else
                {
                    modelo.EmpresaList = new List <Empresa>();
                }

                return(View("ConsultaEmpresaView", modelo));
            }
            catch (Exception ex)
            {
                return(View("ErrorHandler", new ErrorHandler()
                {
                    Erro = ex.Message, DetalhamentoErro = ex.StackTrace
                }));
            }
        }