Пример #1
0
        public IActionResult PesquisarEstabelecimento(string tpEstabelecimento, string numCep, string CNES)
        {
            try
            {
                A20TipoEstabelecimento tipoEstabelecimento = null;
                if (tpEstabelecimento != "0")
                {
                    tipoEstabelecimento = new A20TipoEstabelecimentoBusiness(_tipoEstabelecimentoRepositorio)
                                          .RetornarTiposEstabelecimento().Where(c => c.A20TipoEstabelecimentoId == Convert.ToInt32(tpEstabelecimento)).FirstOrDefault();
                }

                var estabelecimentos = new A21EstabelecimentoBusiness(_estabelecimentoRepositorio, _tipoEstabelecimentoRepositorio).BuscarEstabelecimento(tipoEstabelecimento, numCep, CNES);

                if (estabelecimentos != null && estabelecimentos.Count > 0)
                {
                    string jsonEstabelecimentos = JsonConvert.SerializeObject(estabelecimentos, Formatting.Indented, new JsonSerializerSettings {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    });
                    estabelecimentos = JsonConvert.DeserializeObject <List <A21Estabelecimento> >(jsonEstabelecimentos);
                    return(Json(new { Estabelecimentos = estabelecimentos, MensagemErro = "", MensagemAlerta = "", MensagemSucesso = "" }));
                }
                else
                {
                    return(Json(new { Estabelecimentos = "", MensagemErro = "", MensagemAlerta = Common.MensagensSistema.MsgsSistema.MsgEstabelecimentosNaoEncontrado, MensagemSucesso = "" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Estabelecimentos = "", MensagemErro = ex.Message, MensagemAlerta = "", MensagemSucesso = "" }));
            }
        }
Пример #2
0
        public void CadastrarTipoEstabelecimentoTest()
        {
            A20TipoEstabelecimento tipoEstabelecimento = new A20TipoEstabelecimento();

            tipoEstabelecimento.A20TipoEstabelecimentoCodigo    = "0";
            tipoEstabelecimento.A20TipoEstabelecimentoDescricao = "OUTROS";

            A20TipoEstabelecimento tipoEstabelecimento2 = new A20TipoEstabelecimento();

            tipoEstabelecimento2.A20TipoEstabelecimentoCodigo    = "1";
            tipoEstabelecimento2.A20TipoEstabelecimentoDescricao = "UNIDADE BASICA DE SAUDE";

            var resultado1 = new A20TipoEstabelecimentoBusiness(_tipoEstabelecimentoRepositorio).CadastrarTipoEstabelecimento(tipoEstabelecimento);
            var resultado2 = new A20TipoEstabelecimentoBusiness(_tipoEstabelecimentoRepositorio).CadastrarTipoEstabelecimento(tipoEstabelecimento2);

            Assert.True(resultado1 && resultado2);
        }
Пример #3
0
        public void RetornarTiposEstabelecimentoTest()
        {
            var tiposEstabelecimento = new A20TipoEstabelecimentoBusiness(_tipoEstabelecimentoRepositorio).RetornarTiposEstabelecimento();

            Assert.True(tiposEstabelecimento.Count > 0);
        }