From faf6f66f04f31fb442f198efef14b586dc0a2dd8 Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 28 Apr 2020 15:29:20 +0200 Subject: [PATCH] change category from string to enum --- Book.cs | 6 +++--- CategoryEnum.cs | 10 ++++++++++ IProduct.cs | 2 +- Magazine.cs | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 CategoryEnum.cs diff --git a/Book.cs b/Book.cs index 42f016d..d318bc8 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; set; } + public CategoryEnum Category { get; set; } [JsonPropertyName("imageLink")] public string ImageLink { get; set; } [JsonIgnore] @@ -38,7 +38,7 @@ namespace Bücherwurm int Pages, int Year) { ProductId = Id; - Category = "book"; + Category = CategoryEnum.Book; LendTime = 30; this.Name = Title; this.Author = Author; @@ -52,7 +52,7 @@ namespace Bücherwurm public Book() { - Category = "book"; + Category = CategoryEnum.Book; LendTime = 30; } diff --git a/CategoryEnum.cs b/CategoryEnum.cs new file mode 100644 index 0000000..580177b --- /dev/null +++ b/CategoryEnum.cs @@ -0,0 +1,10 @@ +namespace Bücherwurm +{ + public enum CategoryEnum + { + Book, + Magazine, + EBook, + EPaper + } +} \ No newline at end of file diff --git a/IProduct.cs b/IProduct.cs index 77bbae8..41baec6 100644 --- a/IProduct.cs +++ b/IProduct.cs @@ -4,7 +4,7 @@ namespace Bücherwurm { int ProductId {get; set;} - string Category {get; set; } + CategoryEnum Category {get; set; } int LendTime {get; set;} diff --git a/Magazine.cs b/Magazine.cs index c764d92..8ffc42e 100644 --- a/Magazine.cs +++ b/Magazine.cs @@ -8,7 +8,7 @@ namespace Bücherwurm public int ProductId {get; set;} [JsonIgnore] - public string Category {get; set;} + public CategoryEnum Category {get; set;} [JsonIgnore] public int LendTime {get; set;} @@ -35,7 +35,7 @@ namespace Bücherwurm public Magazine() { - Category = "magazine"; + Category = CategoryEnum.Magazine; LendTime = 2; } }