Skip to content

Commit

Permalink
Subs-List - use IGameService for system codes, to take advantage of c…
Browse files Browse the repository at this point in the history
…aching
  • Loading branch information
adelikat committed Sep 2, 2024
1 parent 641ef58 commit 347370e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 12 additions & 0 deletions TASVideos/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public static Task<List<SelectListItem>> ToDropDownList(this IQueryable<string>
.ToListAsync();
}

public static List<SelectListItem> ToDropDownList(this IEnumerable<SystemsResponse> list)
{
return list
.OrderBy(s => s.Code)
.Select(s => new SelectListItem
{
Text = s.Code,
Value = s.Code
})
.ToList();
}

public static IEnumerable<SelectListItem> ToDropDown(this IEnumerable<string> strings)
{
return strings.Select(s => new SelectListItem
Expand Down
7 changes: 3 additions & 4 deletions TASVideos/Pages/Submissions/Index.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SelectListItem> Statuses = Enum.GetValues<SubmissionStatus>().ToDropDown();

Expand All @@ -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)
Expand Down

0 comments on commit 347370e

Please sign in to comment.