Created entities for database

This commit is contained in:
2026-05-23 16:22:52 +02:00
parent 6a83de1f5d
commit 400faa2fc3
25 changed files with 694 additions and 0 deletions
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OakArchive.Entities.Cards;
namespace OakArchive.Entities.CardMarket;
public class CardMarketSetInfo
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
public string ExpansionId { get; set; } = string.Empty;
[ForeignKey(nameof(Set))] public Guid SetId { get; set; }
public virtual Set.Set Set { get; set; } = null!;
}
+21
View File
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
namespace OakArchive.Entities.Cards;
public class Attack
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
public List<string> Cost { get; set; } = [];
public string Name { get; set; } = string.Empty;
public int? Damage { get; set; }
public string Effect { get; set; } = string.Empty;
[ForeignKey(nameof(Card))] public Guid CardId { get; set; }
public virtual Card Card { get; set; } = null!;
}
+57
View File
@@ -0,0 +1,57 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OakArchive.Entities.CardMarket;
using OakArchive.Entities.Enums;
using OakArchive.Entities.Set;
using OakArchive.Entities.TCGdex;
namespace OakArchive.Entities.Cards;
public class Card
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
[Required] public string Name { get; set; } = string.Empty;
public string Image { get; set; } = string.Empty;
public int CardNumber { get; set; } = 0;
public ulong PHash { get; set; } = 0;
public int? Hp { get; set; }
public int? Retreat { get; set; }
public string? TrainerType { get; set; }
public string? EnergyType { get; set; }
public string? Illustrator { get; set; }
public string? EvolveFrom { get; set; }
public string? Description { get; set; }
public string? RegulationMark { get; set; }
public Rarity? Rarity { get; set; }
public Category? Category { get; set; }
[Column(TypeName = "jsonb")]
public List<Variant>? Variants { get; set; }
[Column(TypeName = "jsonb")] public List<string>? Types { get; set; }
[ForeignKey(nameof(Set))] public Guid SetId { get; set; }
public virtual Set.Set Set { get; set; } = null!;
public virtual TcgDexCardInfo TcgDexCardInfo { get; set; } = null!;
public virtual Legal? Legal { get; set; }
public virtual ICollection<Attack> Attacks { get; set; } = new List<Attack>();
public virtual ICollection<Weakness> Weaknesses { get; set; } = new List<Weakness>();
}
@@ -0,0 +1,32 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OakArchive.Entities.Enums;
using OakArchive.Entities.User;
namespace OakArchive.Entities.Cards;
public class CollectedCard
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
public Variant Variant { get; set; } = Variant.Normal;
public Condition Condition { get; set; } = Condition.Mint;
public int Count { get; set; } = 1;
public Language Language { get; set; } = Language.En;
public DateTime ScannedAt { get; set; } = DateTime.UtcNow;
[ForeignKey(nameof(ScannedBy))] public Guid ScannedById { get; set; }
public ApplicationUser ScannedBy { get; set; } = null!;
[ForeignKey(nameof(Collection))] public Guid CollectionId { get; set; }
public virtual Collection.Collection Collection { get; set; } = null!;
[ForeignKey(nameof(Card))] public Guid CardId { get; set; }
public virtual Card Card { get; set; } = null!;
public virtual Grading.Grading? Grading { get; set; }
}
+16
View File
@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace OakArchive.Entities.Cards;
public class Weakness
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
public string Type { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
[ForeignKey(nameof(Card))] public Guid CardId { get; set; }
public virtual Card Card { get; set; } = null!;
}
@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using OakArchive.Entities.Cards;
using OakArchive.Entities.User;
namespace OakArchive.Entities.Collection;
public class Collection
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public Guid CreatedBy { get; set; } = Guid.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public string InviteCode { get; set; } = string.Empty;
public bool IsPublic { get; set; } = false;
public virtual ICollection<ApplicationUser> Members { get; set; } = [];
public virtual ICollection<CollectedCard> Cards { get; set; } = [];
}
+16
View File
@@ -0,0 +1,16 @@
using System.Text.Json.Serialization;
namespace OakArchive.Entities.Enums;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Category
{
[JsonPropertyName("Energy")]
Energy,
[JsonPropertyName("Pokemon")]
Pokemon,
[JsonPropertyName("Trainer")]
Trainer
}
+12
View File
@@ -0,0 +1,12 @@
namespace OakArchive.Entities.Enums;
public enum Condition
{
Mint = 0,
NearMint = 1,
Excellent = 2,
Good = 3,
LightPlayed = 4,
Played = 5,
Poor = 6
}
@@ -0,0 +1,14 @@
namespace OakArchive.Entities.Enums;
public enum GradingCompany
{
PSA,
BGS,
CGC,
APGrading,
EGS,
AOG,
PCA,
GSG,
Other
}
+25
View File
@@ -0,0 +1,25 @@
using System.ComponentModel;
namespace OakArchive.Entities.Enums;
public enum Language
{
En,
Fr,
Es,
Es_Mx,
It,
Pt,
Pt_Br,
Pt_Pt,
De,
Nl,
Pl,
Ru,
Ja,
Ko,
Zh_Tw,
Id,
Th,
Zh_Cn
}
+124
View File
@@ -0,0 +1,124 @@
using System.Text.Json.Serialization;
namespace OakArchive.Entities.Enums;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Rarity
{
[JsonPropertyName("ACE SPEC Rare")]
AceSpecRare,
[JsonPropertyName("Amazing Rare")]
AmazingRare,
[JsonPropertyName("Black White Rare")]
BlackWhiteRare,
[JsonPropertyName("Classic Collection")]
ClassicCollection,
[JsonPropertyName("Common")]
Common,
[JsonPropertyName("Crown")]
Crown,
[JsonPropertyName("Double rare")]
DoubleRare,
[JsonPropertyName("Four Diamond")]
FourDiamond,
[JsonPropertyName("Full Art Trainer")]
FullArtTrainer,
[JsonPropertyName("Holo Rare")]
HoloRare,
[JsonPropertyName("Holo Rare V")]
HoloRareV,
[JsonPropertyName("Holo Rare VMAX")]
HoloRareVmax,
[JsonPropertyName("Holo Rare VSTAR")]
HoloRareVstar,
[JsonPropertyName("Hyper rare")]
HyperRare,
[JsonPropertyName("Illustration rare")]
IllustrationRare,
[JsonPropertyName("LEGEND")]
Legend,
[JsonPropertyName("Mega Hyper Rare")]
MegaHyperRare,
[JsonPropertyName("None")]
None,
[JsonPropertyName("One Diamond")]
OneDiamond,
[JsonPropertyName("One Shiny")]
OneShiny,
[JsonPropertyName("One Star")]
OneStar,
[JsonPropertyName("Radiant Rare")]
RadiantRare,
[JsonPropertyName("Rare")]
Rare,
[JsonPropertyName("Rare Holo")]
RareHolo,
[JsonPropertyName("Rare Holo LV.X")]
RareHoloLvX,
[JsonPropertyName("Rare PRIME")]
RarePrime,
[JsonPropertyName("Secret Rare")]
SecretRare,
[JsonPropertyName("Shiny Ultra Rare")]
ShinyUltraRare,
[JsonPropertyName("Shiny rare")]
ShinyRare,
[JsonPropertyName("Shiny rare V")]
ShinyRareV,
[JsonPropertyName("Shiny rare VMAX")]
ShinyRareVmax,
[JsonPropertyName("Special illustration rare")]
SpecialIllustrationRare,
[JsonPropertyName("Three Diamond")]
ThreeDiamond,
[JsonPropertyName("Three Star")]
ThreeStar,
[JsonPropertyName("Two Diamond")]
TwoDiamond,
[JsonPropertyName("Two Shiny")]
TwoShiny,
[JsonPropertyName("Two Star")]
TwoStar,
[JsonPropertyName("Ultra Rare")]
UltraRare,
[JsonPropertyName("Uncommon")]
Uncommon
}
+37
View File
@@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
namespace OakArchive.Entities.Enums;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Stage
{
[JsonPropertyName("BREAK")]
Break,
[JsonPropertyName("Basic")]
Basic,
[JsonPropertyName("LEVEL-UP")]
LevelUp,
[JsonPropertyName("MEGA")]
Mega,
[JsonPropertyName("RESTORED")]
Restored,
[JsonPropertyName("Stage1")]
Stage1,
[JsonPropertyName("Stage2")]
Stage2,
[JsonPropertyName("V-UNION")]
VUnion,
[JsonPropertyName("VMAX")]
VMax,
[JsonPropertyName("VSTAR")]
VStar
}
+22
View File
@@ -0,0 +1,22 @@
using System.Text.Json.Serialization;
namespace OakArchive.Entities.Enums;
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Variant
{
[JsonPropertyName("firstEdition")]
FirstEdition,
[JsonPropertyName("holo")]
Holo,
[JsonPropertyName("normal")]
Normal,
[JsonPropertyName("reverse")]
Reverse,
[JsonPropertyName("wPromo")]
WPromo
}
+28
View File
@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OakArchive.Entities.Cards;
using OakArchive.Entities.Enums;
namespace OakArchive.Entities.Grading;
public class Grading
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
[Required] public GradingCompany Company { get; set; } = GradingCompany.PSA;
[Required] public string CertificateNumber { get; set; } = string.Empty;
public double Grade { get; set; }
public double? Centering { get; set; }
public double? Corners { get; set; }
public double? Edges { get; set; }
public double? Surface { get; set; }
public string? GraderNotes { get; set; }
public DateTime GradedAt { get; set; }
[ForeignKey(nameof(CollectedCard))] public Guid CollectedCardId { get; set; }
public virtual CollectedCard CollectedCard { get; set; } = null!;
}
+24
View File
@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
using OakArchive.Entities.Enums;
using OakArchive.Entities.TCGdex;
namespace OakArchive.Entities.Serie;
public class Serie
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
public string Name { get; set; } = string.Empty;
public string? Logo { get; set; }
public Language? Language { get; set; }
//public DateTime? ReleaseDate { get; set; }
public virtual ICollection<Set.Set> Sets { get; set; } = new List<Set.Set>();
public virtual TcgDexSeriesInfo TcgDexSeriesInfo { get; set; } = null!;
}
+26
View File
@@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace OakArchive.Entities.Set;
public class CardCount
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
public int Total { get; set; } = 0;
public int Official { get; set; } = 0;
public int Normal { get; set; } = 0;
public int Reverse { get; set; } = 0;
public int Holo { get; set; } = 0;
public int FirstEd { get; set; } = 0;
[ForeignKey(nameof(Set))]
public Guid SetId { get; set; }
public virtual Set Set { get; set; } = null!;
}
+22
View File
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OakArchive.Entities.Cards;
namespace OakArchive.Entities.Set;
public class Legal
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
public bool Expanded { get; set; } = false;
public bool Standard { get; set; } = false;
[ForeignKey(nameof(Set))]
public Guid? SetId { get; set; }
public virtual Set? Set { get; set; }
[ForeignKey(nameof(Card))]
public Guid? CardId { get; set; }
public virtual Card? Card { get; set; }
}
+36
View File
@@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OakArchive.Entities.CardMarket;
using OakArchive.Entities.Cards;
using OakArchive.Entities.Enums;
using OakArchive.Entities.TCGdex;
namespace OakArchive.Entities.Set;
public class Set
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
[Required] public string Name { get; set; } = string.Empty;
public string? Symbol { get; set; }
public string? Logo { get; set; }
public Language Language { get; set; } = Language.En;
public DateTime? ReleaseDate { get; set; }
public ICollection<Card> Cards { get; set; } = new List<Card>();
public virtual TcgDexSetInfo SetInfo { get; set; } = null!;
public virtual CardMarketSetInfo CardMarketSetInfo { get; set; } = null!;
[ForeignKey(nameof(Serie))] public Guid SerieId { get; set; }
public virtual Serie.Serie Serie { get; set; } = null!;
public virtual CardCount CardCount { get; set; } = null!;
public virtual Legal? Legal { get; set; }
}
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using OakArchive.Entities.Cards;
namespace OakArchive.Entities.TCGdex;
public class TcgDexCardInfo
{
[Key] public Guid Id { get; set; } = Guid.NewGuid();
[Required] public string FullId { get; set; } = string.Empty;
[Required] public int LocalId { get; set; } = 0;
[ForeignKey(nameof(Card))] public Guid CardId { get; set; }
public virtual Card Card { get; set; } = null!;
}
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace OakArchive.Entities.TCGdex;
public class TcgDexSeriesInfo
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
public string SeriesId { get; set; } = string.Empty;
[ForeignKey(nameof(Set))]
public Guid SeriesIdRef { get; set; }
public virtual Serie.Serie Series { get; set; } = null!;
}
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace OakArchive.Entities.TCGdex;
public class TcgDexSetInfo
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
public string SetId { get; set; } = string.Empty;
[ForeignKey(nameof(Set))]
public Guid SetIdRef { get; set; }
public virtual Set.Set Set { get; set; } = null!;
}
@@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Identity;
namespace OakArchive.Entities.User;
public class ApplicationUser : IdentityUser<Guid>
{
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public virtual Settings Settings { get; set; } = new();
private Collection.Collection DefaultCollection { get; set; } = new();
public virtual ICollection<Collection.Collection> Collections { get; set; } = [];
}
+16
View File
@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace OakArchive.Entities.User;
public class Settings
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
public bool AddCardsToDefaultList { get; set; } = true;
[ForeignKey(nameof(User))]
public Guid UserId { get; set; }
public virtual ApplicationUser User { get; set; } = null!;
}
+12
View File
@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace OakArchive.Models.TcgDex;
public class Weakness
{
[JsonPropertyName("type")]
public string? Type { get; set; }
[JsonPropertyName("value")]
public string? Value { get; set; }
}
@@ -0,0 +1,46 @@
using OakArchive.Entities.Enums;
namespace OakArchive.Util.Extensions;
public static class LanguageExtensions
{
public static string ToApiCode(this Language lang)
{
return lang switch
{
Language.Es_Mx => "es-mx",
Language.Pt_Br => "pt-br",
Language.Pt_Pt => "pt-pt",
Language.Zh_Tw => "zh-tw",
Language.Zh_Cn => "zh-cn",
_ => lang.ToString().ToLower()
};
}
// Ein zusätzliches Feld für deine Avalonia-UI (Anzeigename)
public static string GetDisplayName(this Language lang)
{
return lang switch
{
Language.En => "English",
Language.Fr => "Français",
Language.Es => "Español",
Language.Es_Mx => "Español (México)",
Language.It => "Italiano",
Language.Pt => "Português",
Language.Pt_Br => "Português (Brasil)",
Language.Pt_Pt => "Português (Portugal)",
Language.De => "Deutsch",
Language.Nl => "Nederlands",
Language.Pl => "Polski",
Language.Ru => "Русский",
Language.Ja => "日本語",
Language.Ko => "한국어",
Language.Zh_Tw => "繁體中文 (Taiwan)",
Language.Id => "Bahasa Indonesia",
Language.Th => "ไทย",
Language.Zh_Cn => "简体中文 (China)",
_ => lang.ToString()
};
}
}