change category from string to enum

This commit is contained in:
nek0 2020-04-28 15:29:20 +02:00
parent d4dc0d8f77
commit faf6f66f04
4 changed files with 16 additions and 6 deletions

View File

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

10
CategoryEnum.cs Normal file
View File

@ -0,0 +1,10 @@
namespace Bücherwurm
{
public enum CategoryEnum
{
Book,
Magazine,
EBook,
EPaper
}
}

View File

@ -4,7 +4,7 @@ namespace Bücherwurm
{
int ProductId {get; set;}
string Category {get; set; }
CategoryEnum Category {get; set; }
int LendTime {get; set;}

View File

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