52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace TournamentOrganizer.Models;
|
|
|
|
public enum RuleSet
|
|
{
|
|
DoubleElimination,
|
|
SingleElimination,
|
|
RoundRobin,
|
|
Swiss
|
|
}
|
|
|
|
public static class RuleSetExtensions
|
|
{
|
|
public static string ToDisplayName(this RuleSet ruleSet) => ruleSet switch
|
|
{
|
|
RuleSet.DoubleElimination => "Double Elimination",
|
|
RuleSet.SingleElimination => "Single Elimination",
|
|
RuleSet.RoundRobin => "Round Robin",
|
|
RuleSet.Swiss => "Swiss",
|
|
_ => ruleSet.ToString()
|
|
};
|
|
|
|
public static RuleSet? FromDisplayName(string? displayName) => displayName switch
|
|
{
|
|
"Double Elimination" => RuleSet.DoubleElimination,
|
|
"Single Elimination" => RuleSet.SingleElimination,
|
|
"Round Robin" => RuleSet.RoundRobin,
|
|
"Swiss" => RuleSet.Swiss,
|
|
_ => null
|
|
};
|
|
}
|
|
|
|
public class Game
|
|
{
|
|
[Key]
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int Id { get; set; }
|
|
public string Name { get; set; } = "Example Game";
|
|
public string Description { get; set; } = "Example Game Description";
|
|
|
|
public RuleSet S1RuleSet { get; set; }
|
|
public int? S1Groups { get; set; }
|
|
public int? S1GroupAdvances { get; set; }
|
|
|
|
public RuleSet? S2RuleSet { get; set; }
|
|
|
|
public List<Tournament> Tournaments { get; set; } = [];
|
|
|
|
} |