Example #1
0
        public override bool Equals(System.Object otherBooks)
        {
            if (!(otherBooks is Books))
            {
                return(false);
            }
            else
            {
                Books newBooks      = (Books)otherBooks;
                bool  titleEquality = this.GetTitle() == newBooks.GetTitle();
                bool  idEquality    = this.GetId() == newBooks.GetId();

                return(titleEquality && idEquality);
            }
        }
Example #2
0
        public void AddBooks(Books newBooks)
        {
            SqlConnection conn = DB.Connection();

            conn.Open();

            SqlCommand cmd = new SqlCommand("INSERT INTO book_authors (book_id, authors_id) OUTPUT INSERTED.id VALUES (@BooksId, @CopiesId);", conn);

            SqlParameter booksIdParam   = new SqlParameter("@BooksId", newBooks.GetId());
            SqlParameter authorsIdParam = new SqlParameter("@CopiesId", this.GetId());

            cmd.Parameters.Add(booksIdParam);
            cmd.Parameters.Add(authorsIdParam);
            cmd.ExecuteNonQuery();

            if (conn != null)
            {
                conn.Close();
            }
        }