diff --git a/src/MistoxWebsite.Server/Controllers/ProductController.cs b/src/MistoxWebsite.Server/Controllers/ProductController.cs index 8bb5b61..1d88daf 100755 --- a/src/MistoxWebsite.Server/Controllers/ProductController.cs +++ b/src/MistoxWebsite.Server/Controllers/ProductController.cs @@ -9,7 +9,7 @@ namespace MistoxWebsite.Server.Controllers { DatabaseService _databaseService; - public static List CatalogItems = new List(); + public static Product[] CatalogItems = []; public ProductController( DatabaseService databaseService ) { _databaseService = databaseService; @@ -114,8 +114,8 @@ namespace MistoxWebsite.Server.Controllers { if( !string.IsNullOrEmpty( email ) ) { Account? test = await _databaseService.GetAccount(email); if( test != null ) { - List returned = await _databaseService.GetAllReceipts(test); - return returned.ToArray(); + Receipt[] returned = await _databaseService.GetAllReceipts(test); + return returned; } } } @@ -145,7 +145,7 @@ namespace MistoxWebsite.Server.Controllers { if( !string.IsNullOrEmpty( email ) ) { Account? user = await _databaseService.GetAccount(email); if (user != null){ - List? games = await _databaseService.GetAllProducts(); + Product[] games = await _databaseService.GetAllProducts(); foreach( Product product in games ) { if ( contains( Product, product.URL ) ) { Receipt? receipt = await _databaseService.GetReceipt(user, product); @@ -175,13 +175,14 @@ namespace MistoxWebsite.Server.Controllers { } public static async Task HotReload( DatabaseService ds ) { - CatalogItems = new List(); try { CatalogItems = await ds.GetAllProducts(); } catch { - CatalogItems.Add( new Product() { ID = 0, Name = "offline prod1", Cost = 100, Description = "offline desc" } ); - CatalogItems.Add( new Product() { ID = 1, Name = "offline prod2", Cost = 100, Description = "offline desc" } ); - CatalogItems.Add( new Product() { ID = 2, Name = "offline prod3", Cost = 100, Description = "offline desc" } ); + CatalogItems = new Product[]{ + new Product() { ID = 0, Name = "offline prod1", Cost = 100, Description = "offline desc" }, + new Product() { ID = 1, Name = "offline prod2", Cost = 100, Description = "offline desc" }, + new Product() { ID = 2, Name = "offline prod3", Cost = 100, Description = "offline desc" } + }; }; } diff --git a/src/MistoxWebsite.Server/Services/DatabaseService/AccountInventory.cs b/src/MistoxWebsite.Server/Services/DatabaseService/AccountInventory.cs index ec00f02..e2a99a3 100755 --- a/src/MistoxWebsite.Server/Services/DatabaseService/AccountInventory.cs +++ b/src/MistoxWebsite.Server/Services/DatabaseService/AccountInventory.cs @@ -9,7 +9,7 @@ using System.Data.Common; namespace MistoxWebsite.Server.Services.DatabaseService { public partial class DatabaseService { - public async Task> GetInventory( Account account, Product product ) { + public async Task GetInventory( Account account, Product product ) { List list = new List(); using( MySqlConnection connection = GetConnection() ) { connection.Open(); @@ -40,7 +40,7 @@ namespace MistoxWebsite.Server.Services.DatabaseService { } } } - return list; + return list.ToArray(); } async Task UpdateInventory( MySqlConnection connection, AccountInventory item ) { diff --git a/src/MistoxWebsite.Server/Services/DatabaseService/Receipt.cs b/src/MistoxWebsite.Server/Services/DatabaseService/Receipt.cs index fdb6f5d..79e8b87 100755 --- a/src/MistoxWebsite.Server/Services/DatabaseService/Receipt.cs +++ b/src/MistoxWebsite.Server/Services/DatabaseService/Receipt.cs @@ -6,7 +6,7 @@ using System.Data.Common; namespace MistoxWebsite.Server.Services.DatabaseService { public partial class DatabaseService { - public async Task> GetAllReceipts( Account account ) { + public async Task GetAllReceipts( Account account ) { List receipts = new List (); using( MySqlConnection connection = GetConnection() ) { connection.Open(); @@ -43,10 +43,10 @@ namespace MistoxWebsite.Server.Services.DatabaseService { } } } - return receipts; + return receipts.ToArray(); } - public async Task> GetAllReceiptsJoinedToProduct( Account account ) { + public async Task<( Receipt, Product )[]> GetAllReceiptsJoinedToProduct( Account account ) { List<( Receipt, Product )> join = new(); using( MySqlConnection connection = GetConnection() ) { connection.Open(); @@ -100,7 +100,7 @@ namespace MistoxWebsite.Server.Services.DatabaseService { } } } - return join; + return join.ToArray(); } public async Task GetReceipt( Account account, Product game ) {