All API endpoints now use Arrays instead of Lists
This commit is contained in:
@@ -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
|
||||
} );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user