generate ebooks from imports

This commit is contained in:
nek0 2020-06-05 11:55:29 +02:00
parent f94d8b2c65
commit f04f7f4892

View file

@ -41,15 +41,24 @@ 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()
{ {