Example #1
0
        public JsonResult Get(int id)
        {
            var    Pessoa = _PessoaService.FindById(id);
            string json   = JsonConvert.SerializeObject(Pessoa);

            return(Json(json));
        }
Example #2
0
        //[Authorize("Bearer")]
        public IActionResult Get(string id)
        {
            var pessoa = _pessoaService.FindById(id);

            if (pessoa == null)
            {
                return(NotFound());
            }
            return(Ok(pessoa));
        }
Example #3
0
        private void btBusca_Click(object sender, EventArgs e)
        {
            if (txtTermo.Text.Trim().Equals(""))
            {
                MessageBox.Show("Nome para busca deve ser preenchido.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtTermo.Focus();
                return;
            }

            cobResultado.ComboBox.DataSource = null;
            cobResultado.SelectedItem        = null;
            switch ((TipoBusca)cobBusca.SelectedItem)
            {
            case TipoBusca.NOME:
                cobResultado.ComboBox.DataSource = _ps.FindByNome(txtTermo.Text);
                break;

            case TipoBusca.ID:
                if (!ValidaDados.SoNumeros(txtTermo.Text))
                {
                    MessageBox.Show(
                        "Para buscar pelo id deve ser informado somente nĂºmeros, positivos e maiores que zero.",
                        Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtTermo.Focus();
                    return;
                }
                Int64 id = Int64.Parse(txtTermo.Text);
                if (id <= 0)
                {
                    MessageBox.Show(
                        "Para buscar pelo id deve ser informado somente nĂºmeros, positivos e maiores que zero.",
                        Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtTermo.Focus();
                    return;
                }

                cobResultado.ComboBox.DataSource = new List <Pessoa>()
                {
                    _ps.FindById(Int64.Parse(txtTermo.Text))
                };
                break;
            }

            cobResultado.ComboBox.SelectedItem = null;
            barraBusca.Visible = true;
            barraBusca.Enabled = true;
            cobResultado.Focus();
        }
        public IActionResult Get(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var person = _pessoaService.FindById(id.Value);

            if (person == null)
            {
                return(NotFound());
            }

            return(Ok(person));
        }
Example #5
0
        public IActionResult Detalhes(string id)
        {
            PessoaModel pessoa = pessoaService.FindById(id);

            return(View(pessoa));
        }