Ejemplo n.º 1
0
 public EnviarEmailSolicitacaoAdocao(PatinhasContext context, Adotante adotante, AnimaisAdocao animal, IntermediadorAdocao intermediador)
 {
     this.adotante      = adotante;
     this.animal        = animal;
     this.intermediador = intermediador;
     this.context       = context;
 }
Ejemplo n.º 2
0
        public ActionResult Create(AdotanteViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                vm.Adotantes = _context.Adotantes.ToList();
                vm.Especies  = _context.Especies.ToList();
                vm.Portes    = _context.Portes.ToList();
                vm.Heading   = "Adicionar Adotante";
                vm.Botao     = "Adicionar";
                return(View("AdotanteForm", vm));
            }


            var adotante = new Adotante
            {
                Nome      = vm.Nome,
                Endereco  = vm.Endereco,
                Telefone  = vm.Telefone,
                EspecieId = vm.Especie,
                PorteId   = vm.Porte
            };

            _context.Adotantes.Add(adotante);
            _context.SaveChanges();

            return(RedirectToAction("Create", "Adotante"));
        }
Ejemplo n.º 3
0
        public bool Add(Adotante adotante)
        {
            if (adotante.IsValid)
            {
                return(_adotanteRepository.Insert(adotante));
            }

            return(false);
        }
Ejemplo n.º 4
0
        // GET: Adotante/Details/5
        public ActionResult Details(int id)
        {
            Adotante adotante = _adotanteService.GetAdotante(id);

            if (adotante == null)
            {
                return(HttpNotFound());
            }
            return(View(adotante));
        }
Ejemplo n.º 5
0
        public bool Update(Adotante adotante)
        {
            if (adotante.IsValid)
            {
                GetAdotante(adotante.Id).Update(adotante);

                return(_adotanteRepository.SaveChanges());
            }

            return(false);
        }
Ejemplo n.º 6
0
        // GET: Adotante/Edit/5
        public ActionResult Edit(int id)
        {
            Adotante adotante = _adotanteService.GetAdotante(id);

            if (adotante == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AnimalId = new SelectList(_animalService.GetAll(), "Id", "Nome");
            ViewBag.PessoaId = new SelectList(_pessoaService.GetAll(), "Id", "Nome");
            return(View(adotante));
        }
Ejemplo n.º 7
0
        public ActionResult Edit([Bind(Include = "Id,PessoaId,AnimalId,DataAdocao")] Adotante adotante)
        {
            if (ModelState.IsValid)
            {
                _adotanteService.Update(adotante);

                return(RedirectToAction("Index"));
            }
            ViewBag.AnimalId = new SelectList(_animalService.GetAll(), "Id", "Nome");
            ViewBag.PessoaId = new SelectList(_pessoaService.GetAll(), "Id", "Nome");
            return(View(adotante));
        }
Ejemplo n.º 8
0
 public static bool RemoverAdotante(Adotante a)
 {
     try
     {
         ctx.Adotante.Remove(a);
         ctx.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 9
0
 public static bool AlterarAdotante(Adotante a)
 {
     try
     {
         ctx.Entry(a).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return true;
     }
 }
Ejemplo n.º 10
0
 public static bool AdicionarAdotante(Adotante a)
 {
     try
     {
         ctx.Adotante.Add(a);
         ctx.SaveChanges();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 11
0
        private void createAdotante()
        {
            Adotante adotante = this._context.adotante.Where(w => w.CPF == this.formulario.CPF).FirstOrDefault();

            if (adotante == null)
            {
                this.adotante = this._mapper.Map <Adotante>(this.formulario);
                this._context.adotante.Add(this.adotante);
                this._context.SaveChanges();
            }
            else
            {
                this.adotante = adotante;
            }
        }
Ejemplo n.º 12
0
 public IActionResult Edit(Adotante adotante)
 {
     repositorio.Edit(adotante);
     return(RedirectToAction("List"));
 }
Ejemplo n.º 13
0
 public static Adotante VerificarAdotantePorCPF(Adotante a)
 {
     return ctx.Adotante.FirstOrDefault(x => x.AdotanteCpf.Equals(a.AdotanteCpf));
 }
Ejemplo n.º 14
0
        public void Remover(int id)
        {
            Adotante adotante = _adotanteRepository.ObterPorId(id);

            _adotanteRepository.Excluir(adotante);
        }
Ejemplo n.º 15
0
 public IActionResult Delete(Adotante adotante)
 {
     repositorio.Delete(adotante);
     return(RedirectToAction("List"));
 }
Ejemplo n.º 16
0
 private void btnBuscarAdotantePorCpf_Click(object sender, RoutedEventArgs e)
 {
     a = new Adotante();
     if (!string.IsNullOrEmpty(txtBuscarAdotantePorCpf.Text))
     {
         a.AdotanteCpf = txtBuscarAdotantePorCpf.Text;
         a = AdotanteDAO.VerificarAdotantePorCPF(a);
         if (a != null)
         {
             txtNomeAdotante.Text = a.AdotanteNome;
             txtCPFAdotante.Text = a.AdotanteCpf;
             txtTelefoneAdotante.Text = a.AdotanteTelefone;
             txtDataNascimento.Text = a.AdotanteIdade;
             txtEndereço.Text = a.AdotanteEndereço;
             HabilitarBotoes();
         }
         else
         {
             MessageBox.Show("Adotante não encontrado!", "Cadastro de Adotante",
             MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
     else
     {
         MessageBox.Show("Favor preencher o campo da busca", "Cadastro de Adotante",
         MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
Ejemplo n.º 17
0
        private void btnGravar_Click(object sender, RoutedEventArgs e)
        {
            a = new Adotante();
            a.AdotanteNome = txtNomeAdotante.Text;
            a.AdotanteCpf = txtCPFAdotante.Text;
            a.AdotanteIdade = txtDataNascimento.Text;
            a.AdotanteTelefone = txtTelefoneAdotante.Text;
            a.AdotanteEndereço = txtEndereço.Text;
            if (AdotanteDAO.AdicionarAdotante(a))
            {
                MessageBox.Show("Gravado com sucesso!", "Cadastro de Adotante",
                MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("Não foi possível gravar!", "Cadastro de Adotante",
                MessageBoxButton.OK, MessageBoxImage.Error);
            }

            txtNomeAdotante.Clear();
            txtCPFAdotante.Clear();
            txtDataNascimento.Text ="";
            txtTelefoneAdotante.Clear();
            txtEndereço.Clear();
            txtNomeAdotante.Focus();
        }
Ejemplo n.º 18
0
        public static void Main(string[] args)
        {
            int Cadastrar;

            StreamWriter DataSet;
            StreamWriter Doador;
            StreamWriter Adotante;

            List <string> contaAdocao = new List <string>();
            List <string> contaDoacao = new List <string>();

            dataPets CadPets = new dataPets("ESPECIE", "RAÇA", "CIDADE", "PORTE");
            dataUser CadUser = new dataUser("Nome", "Telefone", "cidade", "Email");


            Console.WriteLine("Olá! Seja bem vindo ao MyPet! \n");

            Console.WriteLine("Já possui cadastro? ");
            Console.WriteLine("Digite \n 1 - NÃO \n 2 - SIM");
            Cadastrar = int.Parse(Console.ReadLine());

            switch (Cadastrar)
            {
            case 1:
                DataSet = File.AppendText("usuarios.txt");
                Console.WriteLine("Digite seu Nome: \n");
                CadUser.Nome = Console.ReadLine().ToUpper();
                DataSet.WriteLine(CadUser.Nome);

                Console.WriteLine("Telefone para contato: \n");
                CadUser.Telefone = Console.ReadLine();
                DataSet.WriteLine(CadUser.Telefone);

                Console.WriteLine("Digite o nome da sua cidade: \n");
                CadUser.Localidade = Console.ReadLine().ToUpper();
                DataSet.WriteLine(CadUser.Localidade);

                Console.WriteLine("E-mail: \n");
                CadUser.Email = Console.ReadLine().ToUpper();
                DataSet.WriteLine(CadUser.Email);

                Console.WriteLine("Obrigado por se Cadastrar! ");


                DataSet.Close();
                break;

            case 2:
                string x;

                Console.WriteLine("Confirme seu telefone cadastrado: \n");
                x = Console.ReadLine();

                if (verifTel(x))
                {
                    Console.WriteLine("Telefone encontrado");
                }
                else
                {
                    Console.WriteLine("Telefone não encontrado");
                    while (verifTel(x) == false)
                    {
                        Console.WriteLine("Digite novamente: ");
                        x = Console.ReadLine();
                    }
                }

                break;
            }


            int s;

            Console.WriteLine("Gostaria de Adotar ou Doar um Pet? \n Digite: 1 - DOAR  2 - ADOTAR");
            s = int.Parse(Console.ReadLine());

            switch (s)
            {
            case 1:

                Doador = File.AppendText("doador.txt");

                Console.WriteLine("Digite a espécie? GATO ou CACHORRO: ");
                CadPets.Especie = Console.ReadLine().ToUpper();
                contaDoacao.Add(CadPets.Especie);
                Doador.WriteLine(CadPets.Especie);

                Console.WriteLine("Qual a raça? ");
                CadPets.Raca = Console.ReadLine().ToUpper();
                contaDoacao.Add(CadPets.Raca);
                Doador.WriteLine(CadPets.Raca);

                Console.WriteLine("Cidade do Doador");
                CadPets.Localidade = Console.ReadLine().ToUpper();
                contaDoacao.Add(CadPets.Localidade);
                Doador.WriteLine(CadPets.Localidade);

                Console.WriteLine("Qual o porte? \n PEQUENO \n MEDIO \n GRANDE");
                CadPets.Porte = Console.ReadLine().ToUpper();
                contaDoacao.Add(CadPets.Porte);
                Doador.WriteLine(CadPets.Porte);

                Console.WriteLine("Pet Cadastrado. Daremos ao PET o melhor cuidador! ");

                Doador.Close();

                break;

            case 2:

                Adotante = File.AppendText("adotante.txt");

                Console.WriteLine("Prefere GATO ou CACHORRO? - Digite sua escolha");
                CadPets.Especie = Console.ReadLine().ToUpper();
                contaAdocao.Add(CadPets.Especie);
                Adotante.WriteLine(CadPets.Especie);

                Console.WriteLine("Raça preferida: ");
                CadPets.Raca = Console.ReadLine().ToUpper();
                Adotante.WriteLine(CadPets.Raca);
                contaAdocao.Add(CadPets.Raca);

                Console.WriteLine("Nome da Cidade que procura o Pet: ");
                CadPets.Localidade = Console.ReadLine().ToUpper();
                Adotante.WriteLine(CadPets.Localidade);
                contaAdocao.Add(CadPets.Localidade);

                Console.WriteLine("Porte: PEQUENO - MEDIO - GRANDE ? ");
                CadPets.Porte = Console.ReadLine().ToUpper();
                Adotante.WriteLine(CadPets.Porte);
                contaAdocao.Add(CadPets.Porte);

                Console.WriteLine("Obrigado por Adotar! Cuide bem do seu Pet");

                Adotante.Close();
                break;
            }

            if (CadUser.Telefone == "27999959595")
            {
                int opcao;

                Console.WriteLine("Deseja acessar o banco de dados? ");
                Console.WriteLine("1 - SIM \n 2 - NÃO");

                opcao = int.Parse(Console.ReadLine());

                switch (opcao)
                {
                case 1:

                    int filter;

                    Console.WriteLine("Abrir:  1 - LISTA DE ADOÇÃO \n 2 - DOAÇÃO ");
                    filter = int.Parse(Console.ReadLine());

                    if (filter == 1)
                    {
                        int Count = 0;

                        foreach (var i in contaAdocao)
                        {
                            Console.WriteLine("Filtrar qtd por espécie: 1 - GATO 2 - CACHORRO");
                            CadPets.Especie = Console.ReadLine().ToUpper();
                            if (i == CadPets.Especie)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");

                            Console.WriteLine("Filtrar qtd por Raça: ");
                            CadPets.Raca = Console.ReadLine().ToUpper();
                            if (i == CadPets.Raca)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");

                            Console.WriteLine("Filtrar qtd por Cidade: ");
                            CadPets.Localidade = Console.ReadLine().ToUpper();
                            if (i == CadPets.Localidade)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");



                            Console.WriteLine("Filtrar qtd por Porte: ");
                            CadPets.Porte = Console.ReadLine().ToUpper();
                            if (i == CadPets.Localidade)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");
                        }
                    }
                    break;

                    if (filter == 2)
                    {
                        int Count = 0;

                        foreach (var i in contaAdocao)
                        {
                            Console.WriteLine("Filtrar qtd por espécie: 1 - GATO 2 - CACHORRO");
                            CadPets.Especie = Console.ReadLine().ToUpper();
                            if (i == CadPets.Especie)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");

                            Console.WriteLine("Filtrar qtd por Raça: ");
                            CadPets.Raca = Console.ReadLine().ToUpper();
                            if (i == CadPets.Raca)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");

                            Console.WriteLine("Filtrar qtd por Cidade: ");
                            CadPets.Localidade = Console.ReadLine().ToUpper();
                            if (i == CadPets.Localidade)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");



                            Console.WriteLine("Filtrar qtd por Porte: ");
                            CadPets.Porte = Console.ReadLine().ToUpper();
                            if (i == CadPets.Localidade)
                            {
                                Count++;
                            }

                            Console.WriteLine(Count + " encontrados");
                        }
                    }
                    break;


                case 2:
                    Console.Clear();

                    Console.WriteLine("Obrigado por usar nosso sistema!");
                    Console.WriteLine("Até logo! ");

                    break;
                }
            }
        }
Ejemplo n.º 19
0
 public IActionResult New(Adotante adotante)
 {
     repositorio.Create(adotante);
     return(RedirectToAction("Details"));
 }
Ejemplo n.º 20
0
        public void Adicionar(AdotanteViewModel adotanteViewModel)
        {
            Adotante adotante = _mapper.Map <Adotante>(adotanteViewModel);

            _adotanteRepository.Inserir(adotante);
        }