using System.Collections.Generic; namespace Model { public static class StatusTransitionManager { private static readonly Dictionary> transitions = new Dictionary> { // 掛單狀態 { "401", new List { "402", "404" } }, { "402", new List { "403" } }, { "403", new List() }, { "404", new List() }, // 床位狀態 { "101", new List {"101", "102","103"} }, { "102", new List { "101" } }, { "103", new List { "101" } }, }; public static bool CanTransition(string currentCode, string targetCode) { if (string.IsNullOrEmpty(currentCode)) { return targetCode == "401" || targetCode == "402" || targetCode == "101"; } if(string.IsNullOrEmpty(targetCode)) { return false; } return transitions.ContainsKey(currentCode) && transitions[currentCode].Contains(targetCode); } } }