diff --git a/TASVideos/Extensions/EntityExtensions.cs b/TASVideos/Extensions/EntityExtensions.cs index af2f0eda8..3e7dfb68b 100644 --- a/TASVideos/Extensions/EntityExtensions.cs +++ b/TASVideos/Extensions/EntityExtensions.cs @@ -25,6 +25,18 @@ public static Task> ToDropDownList(this IQueryable .ToListAsync(); } + public static List ToDropDownList(this IEnumerable list) + { + return list + .OrderBy(s => s.Code) + .Select(s => new SelectListItem + { + Text = s.Code, + Value = s.Code + }) + .ToList(); + } + public static IEnumerable ToDropDown(this IEnumerable strings) { return strings.Select(s => new SelectListItem diff --git a/TASVideos/Pages/Submissions/Index.cshtml.cs b/TASVideos/Pages/Submissions/Index.cshtml.cs index 6c2de3441..2af91c38c 100644 --- a/TASVideos/Pages/Submissions/Index.cshtml.cs +++ b/TASVideos/Pages/Submissions/Index.cshtml.cs @@ -3,7 +3,7 @@ namespace TASVideos.Pages.Submissions; [AllowAnonymous] -public class IndexModel(ApplicationDbContext db) : BasePageModel +public class IndexModel(ApplicationDbContext db, IGameSystemService gameSystemService) : BasePageModel { private static readonly List Statuses = Enum.GetValues().ToDropDown(); @@ -22,9 +22,8 @@ public class IndexModel(ApplicationDbContext db) : BasePageModel public async Task OnGet() { - SystemList = (await db.GameSystems - .ToDropDownList()) - .WithDefaultEntry(); + SystemList = (await gameSystemService.GetAll()) + .ToDropDownList().WithDefaultEntry(); var search = LegacySubListConverter.ToSearchRequest(Query); if (search is not null)