Browse Source

Katalog fix

Felix
Naumann 2 years ago
parent
commit
bb3f2f3fd0
  1. BIN
      LongWormMemory.db
  2. 23
      Models/KatalogModel.cs

BIN
LongWormMemory.db

Binary file not shown.

23
Models/KatalogModel.cs

@ -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();
}
}

Loading…
Cancel
Save