@page "/browse/{State}" @using TSC2.Components.CSharp; @State | The Shop Critics @if (isValid) {

@State

@results

} else {

Invalid state.

} @code { [Parameter] public string State { get; set; } = "MI"; private string results = "No results found."; private List> filterResults = new(); private bool isValid = false; protected override Task OnInitializedAsync() { // Verify that the requested url is valid var states = Enum.GetValues(typeof(States)).Cast().ToList(); if (Enum.IsDefined(typeof(States), State)) { // If a valid state, let it filter isValid = true; filterResults = DatabaseManager.FilterByState(State); if (filterResults.Count == 0) return Task.FromResult(0); this.results = "Results:\n"; } else { isValid = false; } return Task.FromResult(0); } private enum States { AL, AK, AR, AZ, CA, CO, CT, DC, DE, FL, GA, HI, IA, ID, IL, IN, KS, KY, LA, MA, MD, ME, MI, MN, MO, MS, MT, NC, ND, NE, NH, NJ, NM, NV, NY, OK, OH, OR, PA, RI, SC, SD, TN, TX, UT, VA, VT, WA, WI, WV, WY } }