All API endpoints now use Arrays instead of Lists

This commit is contained in:
2025-06-25 18:38:37 -07:00
parent f151a48f0a
commit cf90241944
9 changed files with 34 additions and 33 deletions
@@ -6,7 +6,7 @@ using System.Data.Common;
namespace MistoxWebsite.Server.Services.DatabaseService {
public partial class DatabaseService {
public async Task<List<Cart>> GetCart( Account account ) {
public async Task<Cart[]> GetCart( Account account ) {
List<Cart> list = new List<Cart>();
using( MySqlConnection connection = GetConnection() ) {
connection.Open();
@@ -34,7 +34,7 @@ namespace MistoxWebsite.Server.Services.DatabaseService {
}
}
}
return list;
return list.ToArray();
}
public async Task AddToCart( Cart item ) {
@@ -62,8 +62,8 @@ namespace MistoxWebsite.Server.Services.DatabaseService {
}
}
account.products = new List<Product>();
account.receipts = new List<Receipt>();
List<Product> tempProds = new List<Product>();
List<Receipt> tempReceipt = new List<Receipt>();
command = @"
SELECT * FROM Product
@@ -76,8 +76,8 @@ namespace MistoxWebsite.Server.Services.DatabaseService {
cmd2.Parameters.AddWithValue("@AccountID", AccountID);
using( DbDataReader reader = await cmd2.ExecuteReaderAsync() ) {
while( await reader.ReadAsync() ) {
if( reader == null ) {
while (await reader.ReadAsync()) {
if (reader == null) {
break;
}
@@ -93,24 +93,26 @@ namespace MistoxWebsite.Server.Services.DatabaseService {
string[] _imageList = _gameImg.Split('|', StringSplitOptions.RemoveEmptyEntries);
account.products.Add( new Product {
tempProds.Add(new Product {
ID = _productID,
Cost = _gameCost,
Description = _gameDesc,
Name = _gameName,
URL = _gameURL,
Images = _imageList.ToList()
} );
Images = _imageList
});
if( _receiptAccountID != -1 ) {
account.receipts.Add( new Receipt {
if (_receiptAccountID != -1) {
tempReceipt.Add(new Receipt {
AccountID = _receiptAccountID,
ProductID = _productID,
ReceiptID = _receiptID,
Time = _receiptTime
} );
});
}
account.products = tempProds.ToArray();
account.receipts = tempReceipt.ToArray();
}
}
}
@@ -37,7 +37,7 @@ namespace MistoxWebsite.Server.Services.DatabaseService {
Name = _name,
Description = _description,
Cost = _cost,
Images = _imageList.ToList(),
Images = _imageList,
URL = _url
};
}
@@ -70,7 +70,7 @@ namespace MistoxWebsite.Server.Services.DatabaseService {
Name = _name,
Description = _description,
Cost = _cost,
Images = _imageList.ToList(),
Images = _imageList,
URL = _url
} );
}