DTOs for index mostly done, doing DB models

This commit is contained in:
gamer147
2024-09-12 00:35:31 -04:00
parent ac3b002d74
commit 79505e0c1a
69 changed files with 1523 additions and 21 deletions

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using DCGEngine.Database.Interfaces;
namespace DCGEngine.Database.Models;
@@ -6,6 +7,7 @@ namespace DCGEngine.Database.Models;
public class BaseEntity<TKey> : ITimeTrackedEntity, IDbTrackedEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public virtual TKey Id { get; set; }
public DateTime? DateCreated { get; set; }

View File

@@ -1,3 +1,5 @@
using System.ComponentModel.DataAnnotations;
namespace DCGEngine.Database.Models;
/// <summary>
@@ -8,7 +10,8 @@ public abstract class CardEntry : BaseEntity<long>
/// <summary>
/// The name of this card used internally, to separate it from any localization key stored.
/// </summary>
public virtual string InternalName { get; set; }
[Required(AllowEmptyStrings = false)]
public virtual string Name { get; set; } = string.Empty;
/// <summary>
/// The offensive power of this card.

View File

@@ -0,0 +1,17 @@
namespace DCGEngine.Database.Models;
/// <summary>
/// A set containing 0 or more <see cref="CardEntry"/>s. All cards must belong to a set.
/// </summary>
public abstract class CardSetEntry : BaseEntity<int>
{
/// <summary>
/// The internal name of the set.
/// </summary>
public virtual string Name { get; set; } = string.Empty;
/// <summary>
/// The cards in the set.
/// </summary>
public virtual List<CardEntry> Cards { get; set; } = new List<CardEntry>();
}

View File

@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
namespace DCGEngine.Database.Models;
/// <summary>
/// A <see cref="CardEntry"/> that is in a <see cref="DeckEntry"/> X times.
/// </summary>
[Owned]
public class DeckCard
{
/// <summary>
/// The card in the deck.
/// </summary>
public virtual CardEntry Card { get; set; }
/// <summary>
/// The number of the card that is in the deck.
/// </summary>
public virtual int Count { get; set; }
/// <summary>
/// The deck this belongs to.
/// </summary>
public virtual DeckEntry Deck { get; set; }
}

View File

@@ -1,3 +1,5 @@
using System.ComponentModel.DataAnnotations;
namespace DCGEngine.Database.Models;
/// <summary>
@@ -8,10 +10,11 @@ public abstract class DeckEntry : BaseEntity<long>
/// <summary>
/// How this deck is referred to internally.
/// </summary>
public virtual string InternalName { get; set; }
[Required(AllowEmptyStrings = false)]
public virtual string Name { get; set; } = string.Empty;
/// <summary>
/// The cards present in this deck.
/// </summary>
public virtual List<CardEntry> Cards { get; set; }
public virtual List<DeckCard> Cards { get; set; } = new List<DeckCard>();
}