Katalog fix

This commit is contained in:
Naumann 2020-06-04 11:38:01 +02:00
parent b1f62f89e7
commit bb3f2f3fd0
2 changed files with 16 additions and 7 deletions

Binary file not shown.

View File

@ -52,17 +52,22 @@ namespace BuecherwurmAPI.Models
return books;
}
public Book GetBookById(long id)
{
Book book = new Book{};
using (var command = _dbConnection.CreateCommand())
{
command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id;
command.Parameters.Add(new SqliteParameter("@id", id));
command.CommandText = @"SELECT * FROM Books WHERE ProductId = @id";
var dataReader = command.ExecuteReader();
var book = new Book
while (dataReader.Read())
{
book =new Book
{
Name = (string) dataReader["Books"],
Name = (string) dataReader["Name"],
Author = (string) dataReader["Author"],
Country = (string) dataReader["Country"],
Link = (string) dataReader["Link"],
@ -75,15 +80,19 @@ namespace BuecherwurmAPI.Models
LendTime = (long) dataReader["LendTime"],
LendType = (long) dataReader["LendType"]
};
return book;
return book;
}
return null;
}
}
public void DeleteBook(long id)
{
using (var command = _dbConnection.CreateCommand())
{
command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id;
command.CommandText = @"DELETE * FROM Books WHERE ProductId= @id";
command.Parameters.Add(new SqliteParameter("@id", id));
command.CommandText = @"DELETE FROM Books WHERE ProductId= @id";
var dataReader = command.ExecuteReader();
}
}