private static void Adicionar()
        {
            using (var contato = new ContatoRepositorio())
            {
                new List <Contato>
                {
                    new Contato {
                        Nome = "Joao", Ativo = true, SobreNome = "Munarim", Telefone = "123456789"
                    },
                    new Contato {
                        Nome = "Maria", Ativo = true, SobreNome = "Munarim", Telefone = "89456123"
                    }
                }.ForEach(contato.Adicionar);

                contato.SalvarTodos();

                System.Console.WriteLine("Contatos adicionadas com sucesso.");

                System.Console.WriteLine("=======  contatos cadastrados ===========");
                foreach (var c in contato.GetAll())
                {
                    System.Console.WriteLine("{0} - {1}", c.ContatoID, c.Nome);
                }

                System.Console.ReadKey();
            }
        }
Example #2
0
        // GET: Contato
        public ActionResult Index()
        {
            // Validamos o token
            if (!ValidarToken((Token)Session["token"]))
            {
                return(Redirect("Login/Login"));
            }

            return(View(contato.GetAll().ToList()));
        }
 public ActionResult Delete(int id)
 {
     try
     {
         repo.DeleteById(id);
         return(Json(repo.GetAll()));
     }
     catch
     {
         return(View());
     }
 }