Exemplo n.º 1
0
def bookDelete(id):
    book = Book.query.get(id)

    db.session.delete(book)
    db.session.commit()

    return bookSchema.jsonify(book)
Exemplo n.º 2
0
def bookUpdate(id):
    book = Book.query.get(id)
    title = request.json["name"]

    book.Title = title

    db.session.commit()

    return bookSchema.jsonify(book)
Exemplo n.º 3
0
def bookDelete(id):

    try:

        book = Book.query.get(id)

        db.session.delete(book)
        db.session.commit()

        return bookSchema.jsonify(book)
    except:
        print("error")
Exemplo n.º 4
0
def addBook():

    bookID = request.json["BookID"]
    Title = request.json["Title"]
    Author = request.json["Author"]
    PublisherDate = request.json["PublisherDate"]

    newBook = Book(BookID = bookID, Title = Title, Author = Author, PublisherDate = PublisherDate)

    db.session.add(newBook)
    db.session.commit()

    return bookSchema.jsonify(newBook)
Exemplo n.º 5
0
def addBook():

    if request.method == 'POST' and form.vaidate():

        form = EditBookForm()

        bookID = form.BookID.data
        Title = form.Title.data
        Author = form.Author.data
        PublisherDate = form.PublisherDate.data
        ISBN = form.ISBN.data

        newBook = Book(BookID=bookID,
                       Title=Title,
                       Author=Author,
                       PublisherDate=PublisherDate,
                       ISBN=ISBN)

        db.session.add(newBook)
        db.session.commit()

        return bookSchema.jsonify(newBook)
Exemplo n.º 6
0
def getBook(id):
    book = Book.query.get(id)

    return bookSchema.jsonify(book)