public ActionResult Representantes(PesquisaRepresentantesViewModel model)
        {
            using (var ctx = new DalutexContext())
            {
                model.Representantes = ctx.REPRESENTANTES.Where(x => x.NOME.Contains(model.Filtro.ToUpper())).OrderBy(x => x.NOME).ToList();
            }

            return(View(model));
        }
        public ActionResult Representantes()
        {
            PesquisaRepresentantesViewModel model = new PesquisaRepresentantesViewModel();

            model.Representantes = new List <REPRESENTANTES>();
            int IDRepresentante = 0;

            if (base.Session_Carrinho.Representante != null && base.Session_Carrinho.Representante.IDREPRESENTANTE > default(int))
            {
                IDRepresentante = base.Session_Carrinho.Representante.IDREPRESENTANTE;
            }
            else
            {
                if (base.Session_Usuario.ID_REPRES > default(int))
                {
                    IDRepresentante = base.Session_Usuario.ID_REPRES.GetValueOrDefault();
                }
            }

            if (IDRepresentante > default(int))
            {
                using (var ctx = new DalutexContext())
                {
                    REPRESENTANTES objRepresentante = ctx.REPRESENTANTES.Find(IDRepresentante);
                    COML_CONTATOS  contato          = ctx.COML_CONTATOS.Where(x => x.IDPESSOAFJ == objRepresentante.IDREPRESENTANTE && x.EMAIL.Trim() != "").FirstOrDefault();
                    if (contato != null)
                    {
                        contato.EMAIL.Trim();
                        objRepresentante.CONTATO = contato;
                    }

                    model.Representantes.Add(objRepresentante);
                }
            }

            return(View(model));
        }