impelement ebooks
This commit is contained in:
parent
bb1a0b05ba
commit
2811aa4e71
3 changed files with 39 additions and 2 deletions
2
Book.cs
2
Book.cs
|
@ -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;}
|
||||||
|
|
13
Catalogue.cs
13
Catalogue.cs
|
@ -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
26
EBook.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue