diff --git a/Book.cs b/Book.cs index 12f40cd..3033f69 100644 --- a/Book.cs +++ b/Book.cs @@ -2,7 +2,7 @@ using System.Text.Json.Serialization; namespace Bücherwurm { - class Book : IProduct + public class Book : IProduct { [JsonPropertyName("title")] public string Name {get; set;} diff --git a/Catalogue.cs b/Catalogue.cs index 9011290..56d2559 100644 --- a/Catalogue.cs +++ b/Catalogue.cs @@ -26,8 +26,18 @@ namespace Bücherwurm NextId += 1; } Products.AddRange(new List(IntermediateBooks)); + var eBooks = new List(); + foreach (var book in IntermediateBooks) + { + var ebook = new EBook(book); + ebook.OverwriteNullId(NextId); + eBooks.Add(ebook); + NextId += 1; + } + Products.AddRange(new List(eBooks)); + } - }public void ImportMagazines(string JsonString) + public void ImportMagazines(string JsonString) { var IntermediateBooks = JsonSerializer.Deserialize>(JsonString); foreach (var Ibook in IntermediateBooks) @@ -36,6 +46,7 @@ namespace Bücherwurm NextId += 1; } Products.AddRange(new List(IntermediateBooks)); + } public void AddBook(string Title, string Author, diff --git a/EBook.cs b/EBook.cs new file mode 100644 index 0000000..36e1c7f --- /dev/null +++ b/EBook.cs @@ -0,0 +1,26 @@ +namespace Bücherwurm +{ + public class EBook : Book, IProduct + { + public EBook() { + Category = CategoryEnum.EBook; + LendTime = 30; + LendType = LendTypeEnum.Virtual; + } + + public EBook(Book Parent) + { + Category = CategoryEnum.EBook; + LendTime = 30; + LendType = LendTypeEnum.Virtual; + Name = Parent.Name; + Author = Parent.Author; + Country = Parent.Country; + Link = Parent.Link; + Language = Parent.Language; + Pages = Parent.Pages; + Year = Parent.Pages; + ImageLink = Parent.ImageLink; + } + } +} \ No newline at end of file