diff --git a/Models/KatalogModel.cs b/Models/KatalogModel.cs index f5e5823..b8a794d 100644 --- a/Models/KatalogModel.cs +++ b/Models/KatalogModel.cs @@ -91,7 +91,20 @@ namespace BuecherwurmAPI.Models { // funktioniert das so? command.CommandText = @"INSERT INTO Books (Name, Author, Country, Link, Language, Pages, Year, ProductId, Category, ImageLink, LendTime, LendType) VALUES (book.Name, book.Author, book.Contry, book.Link, book.Language, book.Pages, book.Year, book.ProductId, book.Category, book.ImageLink, book.LendTime, book.LendType)"; - var dataReader = command.ExecuteReader(); + + command.Parameters.Add(new SqliteParameter("@itemId", lend.ItemId)); + command.Parameters.Add(new SqliteParameter("@returnDate", lend.ReturnDate)); + command.Parameters.Add(new SqliteParameter("@customer", lend.Customer)); + + var success = command.ExecuteNonQuery(); + + if (success == 1) + { + command.CommandText = @"SELECT last_insert_rowid()"; + return (long)command.ExecuteScalar(); + } + + return -1; } }