DTOs for index mostly done, doing DB models
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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.
|
||||
|
||||
17
DCGEngine.Database/Models/CardSetEntry.cs
Normal file
17
DCGEngine.Database/Models/CardSetEntry.cs
Normal 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>();
|
||||
}
|
||||
25
DCGEngine.Database/Models/DeckCard.cs
Normal file
25
DCGEngine.Database/Models/DeckCard.cs
Normal 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; }
|
||||
}
|
||||
@@ -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>();
|
||||
}
|
||||
Reference in New Issue
Block a user