37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace MoneyMap.Models;
|
|
|
|
public class Category
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(100)]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
[MaxLength(500)]
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
[MaxLength(50)]
|
|
public string Type { get; set; } = string.Empty; // e.g., "Expense", "Income", "Transfer"
|
|
|
|
public bool IsDefault { get; set; } = false;
|
|
|
|
public int? ParentCategoryId { get; set; }
|
|
public Category? ParentCategory { get; set; }
|
|
public ICollection<Category> Children { get; set; } = new List<Category>();
|
|
|
|
public ICollection<RecurringPlace> RecurringPlaces { get; set; } = new List<RecurringPlace>();
|
|
// These entities store category names, not Category foreign keys. Mapping these
|
|
// collections would make EF invent CategoryId columns absent from the schema.
|
|
[NotMapped]
|
|
public ICollection<CategoryMapping> CategoryMappings { get; set; } = new List<CategoryMapping>();
|
|
[NotMapped]
|
|
public ICollection<Transaction> Transactions { get; set; } = new List<Transaction>();
|
|
|
|
[NotMapped]
|
|
public string DisplayLabel => Name;
|
|
} |