Buecherwurm/Book.cs

67 lines
No EOL
1.7 KiB
C#

using System.Text.Json.Serialization;
namespace Bücherwurm
{
class Book : IProduct
{
[JsonPropertyName("title")]
public string Name {get; set;}
[JsonPropertyName("author")]
public string Author {get; set;}
[JsonPropertyName("country")]
public string Country {get; set;}
[JsonPropertyName("link")]
public string Link {get; set;}
[JsonPropertyName("language")]
public string Language {get; set;}
[JsonPropertyName("pages")]
public int Pages {get; set;}
[JsonPropertyName("year")]
public int Year {get; set;}
[JsonIgnore]
public int ProductId { get; set; }
[JsonIgnore]
public CategoryEnum Category { get; set; }
[JsonPropertyName("imageLink")]
public string ImageLink { get; set; }
[JsonIgnore]
public int LendTime {get; set;}
public Book(int Id, string Title, string Author,
string Country, string ILink, string Link, string Language,
int Pages, int Year)
{
ProductId = Id;
Category = CategoryEnum.Book;
LendTime = 30;
this.Name = Title;
this.Author = Author;
this.Country = Country;
ImageLink = ILink;
this.Link = Link;
this.Language = Language;
this.Pages = Pages;
this.Year = Year;
}
public Book()
{
Category = CategoryEnum.Book;
LendTime = 30;
}
public void OverwriteNullId(int id)
{
if (ProductId == 0)
{
ProductId = id;
}
}
}
}