Rename Table Books to Products to reflect magazines

This commit is contained in:
nek0 2020-06-04 09:39:27 +02:00
parent b3057362be
commit 27392c9799
2 changed files with 8 additions and 8 deletions

View file

@ -27,14 +27,14 @@ namespace BuecherwurmAPI.Models
using (var command = _dbConnection.CreateCommand())
{
command.CommandText = @"SELECT * FROM Books";
command.CommandText = @"SELECT * FROM Products";
var dataReader = command.ExecuteReader();
while (dataReader.Read())
{
books.Add(new Book
{
Name = (string) dataReader["Books"],
Name = (string) dataReader["Name"],
Author = (string) dataReader["Author"],
Country = (string) dataReader["Country"],
Link = (string) dataReader["Link"],
@ -57,12 +57,12 @@ namespace BuecherwurmAPI.Models
using (var command = _dbConnection.CreateCommand())
{
command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id;
command.CommandText = @"SELECT * FROM Books WHERE ProductId = @id";
command.CommandText = @"SELECT * FROM Products WHERE ProductId = @id";
var dataReader = command.ExecuteReader();
var book = new Book
{
Name = (string) dataReader["Books"],
Name = (string) dataReader["Name"],
Author = (string) dataReader["Author"],
Country = (string) dataReader["Country"],
Link = (string) dataReader["Link"],
@ -83,7 +83,7 @@ namespace BuecherwurmAPI.Models
using (var command = _dbConnection.CreateCommand())
{
command.Parameters.Add(new SqliteParameter("@id", SqliteType.Integer)).Value = id;
command.CommandText = @"DELETE * FROM Books WHERE ProductId= @id";
command.CommandText = @"DELETE * FROM Produkts WHERE ProductId= @id";
var dataReader = command.ExecuteReader();
}
}
@ -94,7 +94,7 @@ namespace BuecherwurmAPI.Models
{
// funktioniert das so?
//muss ProduktId übergeben werden?
command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, NULL, @Category, @ImageLink, @LendTime, @LendType )";
command.CommandText = @"INSERT INTO Products (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, NULL, @Category, @ImageLink, @LendTime, @LendType )";
command.Parameters.Add(new SqliteParameter("@Name", book.Name));
command.Parameters.Add(new SqliteParameter("@Author", book.Author));
@ -126,7 +126,7 @@ namespace BuecherwurmAPI.Models
{
// funktioniert das so?
command.Parameters.Add(new SqliteParameter("@id", id));
command.CommandText = @"UPDATE Books SET (Name, Author, Country, Link, Language, Pages, Year, Category, ImageLink, LendTime, LendType) = (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, @Category, @ImageLink, @LendTime, @LendType ) WHERE ProductId = @id";
command.CommandText = @"UPDATE Products SET (Name, Author, Country, Link, Language, Pages, Year, Category, ImageLink, LendTime, LendType) = (@Name, @Author, @Country, @Link, @Language, @Pages, @Year, @Category, @ImageLink, @LendTime, @LendType ) WHERE ProductId = @id";
command.Parameters.Add(new SqliteParameter("@Name", book.Name));
command.Parameters.Add(new SqliteParameter("@Author", book.Author));

View file

@ -40,7 +40,7 @@ namespace BuecherwurmAPI
command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE Items (ItemId INTEGER NOT NULL PRIMARY KEY, BookId INTEGER NOT NULL)";
command.ExecuteNonQuery();
command.CommandText = "CREATE TABLE Books (ProductId INTEGER PRIMARY KEY, Name TEXT, Author TEXT, Country TEXT, Link TEXT, Language TEXT, Pages INTEGER, Year INTEGER, Category INTEGER, ImageLink TEXT, LendTime INTEGER, LendType INTEGER)";
command.CommandText = "CREATE TABLE Products (ProductId INTEGER PRIMARY KEY, Name TEXT, Author TEXT, Country TEXT, Link TEXT, Language TEXT, Pages INTEGER, Year INTEGER, Category INTEGER, ImageLink TEXT, LendTime INTEGER, LendType INTEGER)";
command.ExecuteNonQuery();
}
}