From 6df47aa73e9cfaeae1ea0adae53613e0e4b616a5 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 27 Apr 2020 16:42:56 +0200 Subject: [PATCH] fix import for IProduct --- Book.cs | 2 +- Catalogue.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Book.cs b/Book.cs index 9079476..64f5814 100644 --- a/Book.cs +++ b/Book.cs @@ -27,7 +27,7 @@ namespace Bücherwurm [JsonIgnore] public int ProductId { get; set; } [JsonIgnore] - public string Category { get; } + public string Category { get; set; } [JsonPropertyName("imageLink")] public string ImageLink { get; set; } diff --git a/Catalogue.cs b/Catalogue.cs index d4ef2cb..f456320 100644 --- a/Catalogue.cs +++ b/Catalogue.cs @@ -19,13 +19,14 @@ namespace Bücherwurm public void Import(string JsonString) { - var IntermediateBooks = JsonSerializer.Deserialize>(JsonString); + var IntermediateBooks = JsonSerializer.Deserialize>(JsonString); foreach (var Ibook in IntermediateBooks) { Ibook.OverwriteNullId(NextId); + Ibook.Category = "book"; NextId += 1; } - Products = IntermediateBooks; + Products = new List(IntermediateBooks); } public void AddBook(string Title, string Author,