diff --git a/LANCommander/Controllers/Api/ArchivesController.cs b/LANCommander/Controllers/Api/ArchivesController.cs index a69f60e..5de1b69 100644 --- a/LANCommander/Controllers/Api/ArchivesController.cs +++ b/LANCommander/Controllers/Api/ArchivesController.cs @@ -3,6 +3,7 @@ using LANCommander.Data.Models; using LANCommander.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; namespace LANCommander.Controllers.Api { @@ -19,11 +20,11 @@ namespace LANCommander.Controllers.Api } [HttpGet] - public IEnumerable Get() + public async Task> Get() { using (var repo = new Repository(Context, HttpContext)) { - return repo.Get(a => true).ToList(); + return await repo.Get(a => true).ToListAsync(); } } diff --git a/LANCommander/Controllers/Api/GamesController.cs b/LANCommander/Controllers/Api/GamesController.cs index 882e9ad..f283efc 100644 --- a/LANCommander/Controllers/Api/GamesController.cs +++ b/LANCommander/Controllers/Api/GamesController.cs @@ -23,9 +23,9 @@ namespace LANCommander.Controllers.Api } [HttpGet] - public IEnumerable Get() + public async Task> Get() { - return GameService.Get(); + return await GameService.Get(); } [HttpGet("{id}")] diff --git a/LANCommander/Controllers/Api/SavesController.cs b/LANCommander/Controllers/Api/SavesController.cs index 362e3fc..16b9a8e 100644 --- a/LANCommander/Controllers/Api/SavesController.cs +++ b/LANCommander/Controllers/Api/SavesController.cs @@ -29,9 +29,9 @@ namespace LANCommander.Controllers.Api } [HttpGet] - public IEnumerable Get() + public async Task> Get() { - return GameSaveService.Get(); + return await GameSaveService.Get(); } [HttpGet("{id}")] diff --git a/LANCommander/Pages/Games/Edit.razor b/LANCommander/Pages/Games/Edit.razor index e9cf115..5046b7c 100644 --- a/LANCommander/Pages/Games/Edit.razor +++ b/LANCommander/Pages/Games/Edit.razor @@ -217,9 +217,9 @@ else else Game = await GameService.Get(Id); - Companies = CompanyService.Get(); - Genres = GenreService.Get(); - Tags = TagService.Get(); + Companies = await CompanyService.Get(); + Genres = await GenreService.Get(); + Tags = await TagService.Get(); } private async Task Save() diff --git a/LANCommander/Pages/Games/Index.razor b/LANCommander/Pages/Games/Index.razor index c4075b1..19b7ce0 100644 --- a/LANCommander/Pages/Games/Index.razor +++ b/LANCommander/Pages/Games/Index.razor @@ -3,6 +3,7 @@ @using LANCommander.Extensions; @using System.ComponentModel.DataAnnotations; @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; +@using Microsoft.EntityFrameworkCore; @attribute [Authorize] @inject GameService GameService @inject NavigationManager NavigationManager @@ -264,9 +265,9 @@ } } - private void LoadData() + private async Task LoadData() { - Games = GameService.Get(g => g.Title.ToLower().Contains(Search.ToLower().Trim()) || g.SortTitle.ToLower().Contains(Search.ToLower().Trim())).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToList(); + Games = await GameService.Get(g => g.Title.ToLower().Contains(Search.ToLower().Trim()) || g.SortTitle.ToLower().Contains(Search.ToLower().Trim())).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToListAsync(); } private bool FieldVisible(Field field) @@ -307,7 +308,7 @@ await GameService.Delete(game); - Games = GameService.Get().OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToList(); + Games = await GameService.Get(x => true).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToListAsync(); Loading = false; } diff --git a/LANCommander/Pages/Games/Saves.razor b/LANCommander/Pages/Games/Saves.razor index 5e15e03..502a1b0 100644 --- a/LANCommander/Pages/Games/Saves.razor +++ b/LANCommander/Pages/Games/Saves.razor @@ -1,6 +1,7 @@ @page "/Games/{id:guid}/Saves" @using LANCommander.Models; @using System.IO.Compression; +@using Microsoft.EntityFrameworkCore; @attribute [Authorize(Roles = "Administrator")] @inject GameService GameService @inject CompanyService CompanyService @@ -41,7 +42,7 @@ protected override async Task OnInitializedAsync() { - GameSaves = GameSaveService.Get(gs => gs.GameId == Id).OrderBy(gs => gs.User.UserName).ThenByDescending(gs => gs.CreatedOn).ToList(); + GameSaves = await GameSaveService.Get(gs => gs.GameId == Id).OrderBy(gs => gs.User.UserName).ThenByDescending(gs => gs.CreatedOn).ToListAsync(); Loading = false; } @@ -54,7 +55,7 @@ await GameSaveService.Delete(gameSave); - GameSaves = GameSaveService.Get(gs => gs.GameId == Id).OrderBy(gs => gs.User.UserName).ThenByDescending(gs => gs.CreatedOn).ToList(); + GameSaves = await GameSaveService.Get(gs => gs.GameId == Id).OrderBy(gs => gs.User.UserName).ThenByDescending(gs => gs.CreatedOn).ToListAsync(); Loading = false; } diff --git a/LANCommander/Pages/Servers/Edit.razor b/LANCommander/Pages/Servers/Edit.razor index 43fbe35..21fe2af 100644 --- a/LANCommander/Pages/Servers/Edit.razor +++ b/LANCommander/Pages/Servers/Edit.razor @@ -166,7 +166,7 @@ if (Server.GameId.HasValue) GameId = Server.GameId.Value; - Games = GameService.Get().ToList(); + Games = await GameService.Get(); } private async Task Save() diff --git a/LANCommander/Pages/Servers/Index.razor b/LANCommander/Pages/Servers/Index.razor index 6003e30..ae49eda 100644 --- a/LANCommander/Pages/Servers/Index.razor +++ b/LANCommander/Pages/Servers/Index.razor @@ -1,5 +1,6 @@ @page "/Servers" @using LANCommander.Pages.Servers.Components +@using Microsoft.EntityFrameworkCore; @attribute [Authorize] @inject ServerService ServerService @inject ServerProcessService ServerProcessService @@ -67,11 +68,11 @@ } } - private void LoadData() + private async Task LoadData() { var fuzzySearch = Search.ToLower().Trim(); - Servers = ServerService.Get(s => s.Name.ToLower().Contains(fuzzySearch) || (s.Game != null && (s.Game.Title.ToLower().Contains(fuzzySearch) || s.Game.SortTitle.ToLower().Contains(fuzzySearch)))).OrderBy(s => s.Name).ToList(); + Servers = await ServerService.Get(s => s.Name.ToLower().Contains(fuzzySearch) || (s.Game != null && (s.Game.Title.ToLower().Contains(fuzzySearch) || s.Game.SortTitle.ToLower().Contains(fuzzySearch)))).OrderBy(s => s.Name).ToListAsync(); } private void Add() @@ -92,7 +93,7 @@ await ServerService.Delete(server); - Servers = ServerService.Get().OrderBy(s => s.Name).ToList(); + Servers = await ServerService.Get(x => true).OrderBy(s => s.Name).ToListAsync(); Loading = false; } diff --git a/LANCommander/Services/_BaseDatabaseService.cs b/LANCommander/Services/_BaseDatabaseService.cs index 8a003fe..f7d986d 100644 --- a/LANCommander/Services/_BaseDatabaseService.cs +++ b/LANCommander/Services/_BaseDatabaseService.cs @@ -1,5 +1,6 @@ using LANCommander.Data; using LANCommander.Data.Models; +using Microsoft.EntityFrameworkCore; using System.Linq.Expressions; namespace LANCommander.Services @@ -14,9 +15,9 @@ namespace LANCommander.Services HttpContext = httpContextAccessor.HttpContext; } - public virtual ICollection Get() + public virtual async Task> Get() { - return Get(x => true).ToList(); + return await Get(x => true).ToListAsync(); } public virtual async Task Get(Guid id)