impelement ebooks

This commit is contained in:
nek0 2020-04-28 15:58:27 +02:00
parent bb1a0b05ba
commit 2811aa4e71
3 changed files with 39 additions and 2 deletions

View file

@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
namespace Bücherwurm namespace Bücherwurm
{ {
class Book : IProduct public class Book : IProduct
{ {
[JsonPropertyName("title")] [JsonPropertyName("title")]
public string Name {get; set;} public string Name {get; set;}

View file

@ -26,8 +26,18 @@ namespace Bücherwurm
NextId += 1; NextId += 1;
} }
Products.AddRange(new List<IProduct>(IntermediateBooks)); Products.AddRange(new List<IProduct>(IntermediateBooks));
var eBooks = new List<EBook>();
foreach (var book in IntermediateBooks)
{
var ebook = new EBook(book);
ebook.OverwriteNullId(NextId);
eBooks.Add(ebook);
NextId += 1;
}
Products.AddRange(new List<IProduct>(eBooks));
}
}public void ImportMagazines(string JsonString) public void ImportMagazines(string JsonString)
{ {
var IntermediateBooks = JsonSerializer.Deserialize<List<Magazine>>(JsonString); var IntermediateBooks = JsonSerializer.Deserialize<List<Magazine>>(JsonString);
foreach (var Ibook in IntermediateBooks) foreach (var Ibook in IntermediateBooks)
@ -36,6 +46,7 @@ namespace Bücherwurm
NextId += 1; NextId += 1;
} }
Products.AddRange(new List<IProduct>(IntermediateBooks)); Products.AddRange(new List<IProduct>(IntermediateBooks));
} }
public void AddBook(string Title, string Author, public void AddBook(string Title, string Author,

26
EBook.cs Normal file
View file

@ -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;
}
}
}