Compare commits

..

No commits in common. "master" and "Felix" have entirely different histories.

3 changed files with 4 additions and 13 deletions

2
.gitignore vendored
View file

@ -11,8 +11,6 @@
*.userosscache *.userosscache
*.sln.docstates *.sln.docstates
*.db
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs

View file

@ -121,7 +121,7 @@ namespace BuecherwurmAPI.Models
using (var command = _dbConnection.CreateCommand()) using (var command = _dbConnection.CreateCommand())
{ {
command.Parameters.Add(new SqliteParameter("@id", id)); command.Parameters.Add(new SqliteParameter("@id", id));
command.CommandText = @"DELETE FROM Products WHERE ProductId= @id"; command.CommandText = @"DELETE FROM Books WHERE ProductId= @id";
var dataReader = command.ExecuteReader(); var dataReader = command.ExecuteReader();
} }
} }
@ -130,6 +130,8 @@ namespace BuecherwurmAPI.Models
{ {
using (var command = _dbConnection.CreateCommand()) using (var command = _dbConnection.CreateCommand())
{ {
// funktioniert das so?
//muss ProduktId übergeben werden? -> ProductId wird weiter hinten mit 'NULL' befüllt, damit die ID automatisch vergeben wird.
command.CommandText = @"INSERT INTO Products (ProductId, Title, Author, Country, Link, Language, Pages, Year, Category, ImageLink, LendTime, LendType, Run, Audience, Topic) VALUES (NULL, @Title, @Author, @Country, @Link, @Language, @Pages, @Year, @Category, @ImageLink, @LendTime, @LendType, @Run, @Audience, @Topic)"; command.CommandText = @"INSERT INTO Products (ProductId, Title, Author, Country, Link, Language, Pages, Year, Category, ImageLink, LendTime, LendType, Run, Audience, Topic) VALUES (NULL, @Title, @Author, @Country, @Link, @Language, @Pages, @Year, @Category, @ImageLink, @LendTime, @LendType, @Run, @Audience, @Topic)";
command.Parameters.Add(new SqliteParameter("@Title", book.Title)); command.Parameters.Add(new SqliteParameter("@Title", book.Title));

View file

@ -41,24 +41,15 @@ namespace BuecherwurmAPI
//var importedMags = JsonSerializer.Deserialize<List<Models.BookPost>>(magazinesJson); //var importedMags = JsonSerializer.Deserialize<List<Models.BookPost>>(magazinesJson);
List<Models.IProductPost> imports = new List<Models.IProductPost>(); List<Models.IProductPost> imports = new List<Models.IProductPost>();
imports.AddRange(importedBooks); imports.AddRange(importedBooks);
foreach (var item in importedBooks)
{
item.LendType = LendTypeEnum.Virtual;
item.Category = Models.CategoryEnum.EBook;
imports.Add(item);
}
//imports.AddRange(importedMags); //imports.AddRange(importedMags);
foreach (var item in imports) foreach (var item in imports)
{ {
var id = catalogue.AddProduct(item); var id = catalogue.AddProduct(item);
items.NewItem(new Models.ItemPost{ BookId = (int)id}); items.NewItem(new Models.ItemPost{ BookId = (int)id});
if (item.LendType != LendTypeEnum.Virtual)
{
items.NewItem(new Models.ItemPost{ BookId = (int)id}); items.NewItem(new Models.ItemPost{ BookId = (int)id});
} }
} }
}
private static void CreateNewEmptyDB() private static void CreateNewEmptyDB()
{ {