66 lines
2.2 KiB
C#
66 lines
2.2 KiB
C#
namespace AuthorBuddy.Web.Models;
|
|
|
|
[Flags]
|
|
public enum FileCategory
|
|
{
|
|
None = 0,
|
|
Character = 1,
|
|
Exposee = 2,
|
|
Fact = 4,
|
|
Document = 8
|
|
}
|
|
|
|
public static class FileCategoryHelper
|
|
{
|
|
public static bool IsValid(FileCategory value)
|
|
{
|
|
if (value == FileCategory.None) return true;
|
|
|
|
// Exposee and Document must be alone
|
|
bool hasExposee = value.HasFlag(FileCategory.Exposee);
|
|
bool hasDocument = value.HasFlag(FileCategory.Document);
|
|
bool hasCharacter = value.HasFlag(FileCategory.Character);
|
|
bool hasFact = value.HasFlag(FileCategory.Fact);
|
|
|
|
if (hasExposee && value != FileCategory.Exposee) return false;
|
|
if (hasDocument && value != FileCategory.Document) return false;
|
|
|
|
// Charakter + Fakt is the only valid multi-category combination
|
|
if (hasCharacter && hasFact && value == (FileCategory.Character | FileCategory.Fact)) return true;
|
|
|
|
// Single categories are valid
|
|
if (value is FileCategory.Character or FileCategory.Fact or FileCategory.Exposee or FileCategory.Document) return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
public static string DisplayName(FileCategory category) => category switch
|
|
{
|
|
FileCategory.Character => "Charakter",
|
|
FileCategory.Exposee => "Exposé",
|
|
FileCategory.Fact => "Fakt",
|
|
FileCategory.Document => "Dokument",
|
|
FileCategory.Character | FileCategory.Fact => "Charakter + Fakt",
|
|
_ => ""
|
|
};
|
|
|
|
public static string DisplayIcon(FileCategory category) => category switch
|
|
{
|
|
FileCategory.Character => "👤",
|
|
FileCategory.Exposee => "📋",
|
|
FileCategory.Fact => "📌",
|
|
FileCategory.Document => "📄",
|
|
FileCategory.Character | FileCategory.Fact => "👤📌",
|
|
_ => ""
|
|
};
|
|
|
|
public static string CssClass(FileCategory category) => category switch
|
|
{
|
|
FileCategory.Character => "category-character",
|
|
FileCategory.Exposee => "category-exposee",
|
|
FileCategory.Fact => "category-fact",
|
|
FileCategory.Document => "category-document",
|
|
FileCategory.Character | FileCategory.Fact => "category-character-fact",
|
|
_ => ""
|
|
};
|
|
}
|