Example #1
0
        public void ExcluirPessoaCsv(int PessoaID)
        {
            PessoaRepository Pessoas = new PessoaRepository();

            PessoasRepositorio = (List <Pessoa>)Pessoas.ObterPessoasCsv();

            PessoasRepositorio.Remove(PessoasRepositorio.First(x => x.PessoaID == PessoaID));

            Funcoes.ExcluirArquivoListaDeAniversariantes();
            string NomeArquivo = Funcoes.CriarArquivoSenaoExiste();

            using StreamWriter Escrever = new StreamWriter(NomeArquivo, true);
            {
                foreach (var Item in PessoasRepositorio)
                {
                    string IdPessoa       = Item.PessoaID.ToString();
                    string Nome           = Item.Nome;
                    string Sobrenome      = Item.Sobrenome;
                    string DataNascimento = Item.DataNascimento.ToString("dd/MM/yyyy");

                    Escrever.WriteLine(IdPessoa + ";" + Nome + ";" + Sobrenome + ";" + DataNascimento);
                }

                Escrever.Close();
                Escrever.Dispose();
            }
        }
Example #2
0
        public void ExcluirPessoaLst(int PessoaID)

        {
            PessoaRepository Pessoas = new PessoaRepository();

            PessoasRepositorio = (List <Pessoa>)Pessoas.ObterPessoasLst();

            PessoasRepositorio.Remove(PessoasRepositorio.First(x => x.PessoaID == PessoaID));
        }
        public string Excluir(Pessoas entity)
        {
            AppContext contexto = new AppContext();
            using (DbContextTransaction transacao = AppTransaction.CreateDbContextTransaction(contexto))
            {
                _mensagem = new PessoasRepositorio(contexto).Excluir(entity);

                if (_mensagem == "")
                    transacao.Commit();
                else
                    transacao.Rollback();
            }
            return _mensagem;
        }
        public ActionResult Pessoas()
        {
            ViewBag.pessoas = "active";

            ViewBag.contHomens   = PessoasRepositorio.NumeroHomens();
            ViewBag.contMulheres = PessoasRepositorio.NumeroMulheres();

            ViewBag.contHomensCriancas   = PessoasRepositorio.NumeroCriancasHomens();
            ViewBag.contMulheresCriancas = PessoasRepositorio.NumeroCriancasMulheres();

            ViewBag.contHomensAdultos   = PessoasRepositorio.NumeroAdultosHomens();
            ViewBag.contMulheresAdultos = PessoasRepositorio.NumeroAdultosMulheres();

            ViewBag.contHomensIdosos   = PessoasRepositorio.NumeroIdososHomens();
            ViewBag.contMulheresIdosos = PessoasRepositorio.NumeroIdososMulheres();

            ViewBag.contTotal = PessoasRepositorio.NumeroHomens() + PessoasRepositorio.NumeroMulheres();

            return(View());
        }