private void AdicionaLivro(Livro livro)
 {
     using (var ld = new BibliotecaDatabase())
     {
         Debug.WriteLine(ld.Database.Connection.ConnectionString);
         ld.Livros.Add(livro);
         ld.SaveChanges();
     }
 }
Esempio n. 2
0
        public bool Equals(Livro outro)
            {
                // If parameter is null, return false. 
                if (Object.ReferenceEquals(outro, null))
                {
                    return false;
                }

                // Optimization for a common success case. 
                if (Object.ReferenceEquals(this, outro))
                {
                    return true;
                }

                // If run-time types are not exactly the same, return false. 
                if (this.GetType() != outro.GetType())
                    return false;

                // Return true if the fields match. 
                // Note that the base class is not invoked because it is 
                // System.Object, which defines Equals as reference equality. 
                return (outro.LivroId == this.LivroId);
            }
 public ActionResult Novo(Livro livro)
 {
     AdicionaLivro(livro);
     return RedirectToAction("index");
 }