public void AddAuthor(Author newAuthor) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO authors_books (author_id, book_id) VALUES (@AuthorId, @BookId);"; MySqlParameter author_id = new MySqlParameter(); author_id.ParameterName = "@AuthorId"; author_id.Value = newAuthor.GetId(); cmd.Parameters.Add(author_id); MySqlParameter book_id = new MySqlParameter(); book_id.ParameterName = "@BookId"; book_id.Value = _id; cmd.Parameters.Add(book_id); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public void AddAuthor(Author newAuthor) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO books_authors (book_id, author_id) VALUES (@bookId, @authorId);"; MySqlParameter bookId = new MySqlParameter(); bookId.ParameterName = "@bookId"; bookId.Value = this._id; cmd.Parameters.Add(bookId); MySqlParameter authorId = new MySqlParameter(); authorId.ParameterName = "@authorId"; authorId.Value = newAuthor.GetId(); cmd.Parameters.Add(authorId); cmd.ExecuteNonQuery(); _id = (int)cmd.LastInsertedId; conn.Close(); if (conn != null) { conn.Dispose(); } }
public void DeleteAuthor(Author authorToDelete) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"DELETE FROM authors_books WHERE author_id = @authorId AND book_id = @thisId;"; MySqlParameter authorId = new MySqlParameter(); authorId.ParameterName = "@authorId"; authorId.Value = authorToDelete.GetId(); cmd.Parameters.Add(authorId); MySqlParameter idParameter = new MySqlParameter(); idParameter.ParameterName = "@thisId"; idParameter.Value = _id; cmd.Parameters.Add(idParameter); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public override bool Equals(System.Object otherAuthor) { if (!(otherAuthor is Author)) { return(false); } else { Author newAuthor = (Author)otherAuthor; return(this.GetId().Equals(newAuthor.GetId())); } }
public override bool Equals(System.Object otherAuthor) { if (!(otherAuthor is Author)) { return(false); } else { Author newAuthor = (Author)otherAuthor; bool idEquality = this.GetId() == newAuthor.GetId(); bool nameEquality = this.GetName() == newAuthor.GetName(); return(idEquality && nameEquality); } }
public override bool Equals(System.Object otherAuthor) { if (!(otherAuthor is Author)) { return(false); } else { Author newAuthor = (Author)otherAuthor; bool areIdsEqual = (this.GetId() == newAuthor.GetId()); bool areNameEqual = (this.GetName() == newAuthor.GetName()); return(areIdsEqual && areNameEqual); } }
public override bool Equals(System.Object otherAuthor) { if (!(otherAuthor is Author)) { return(false); } else { Author newAuthor = (Author)otherAuthor; bool idEquality = (this.GetId() == newAuthor.GetId()); bool firstEq = (this.GetFirst() == newAuthor.GetFirst()); bool lastEq = (this.GetLast() == newAuthor.GetLast()); return(idEquality && firstEq && lastEq); } }
public override bool Equals(System.Object otherAuthor) { if (!(otherAuthor is Author)) { return(false); } else { Author newAuthor = (Author)otherAuthor; bool authorIdEquality = (this.GetId() == newAuthor.GetId()); bool authorFirstNameEquality = (this.GetFirstName() == newAuthor.GetFirstName()); bool authorLastNameEquality = (this.GetLastName() == newAuthor.GetLastName()); return(authorIdEquality && authorFirstNameEquality && authorLastNameEquality); } }
public override bool Equals(System.Object otherAuthor) { if (!(otherAuthor is Author)) { return(false); } else { Author newAuthor = (Author)otherAuthor; bool idEquality = (this.GetId() == newAuthor.GetId()); bool firstNameEquality = (this.GetFirstName() == newAuthor.GetFirstName()); bool lastNameEquality = (this.GetLastName() == newAuthor.GetLastName()); // return _id == newBook._id && _title == newBook._title && _callNumber == newBook._callNumber && _tagNumber == newBook._tagNumber && _checkoutDate == newBook._checkoutDate && _dueDate == newBook._dueDate && _status == newBook._status; return(idEquality && firstNameEquality && lastNameEquality); } }
public void AddAuthor(Author author) { MySqlConnection conn = DB.Connection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = @"INSERT INTO authors_books (author_id, book_id) VALUES (@AuthorId, @BookId)"; cmd.Parameters.Add(new MySqlParameter("@AuthorId", author.GetId())); cmd.Parameters.Add(new MySqlParameter("@BookId", _id)); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }
public void AddAuthor(Author newAuthor) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"INSERT INTO books_authors (book_id, author_id) VALUES (@bookId, @authorId);"; cmd.Parameters.Add(new MySqlParameter("@bookId", _id)); cmd.Parameters.Add(new MySqlParameter("@authorId", newAuthor.GetId())); cmd.ExecuteNonQuery(); conn.Close(); if (conn != null) { conn.Dispose(); } }