All API endpoints now use Arrays instead of Lists
This commit is contained in:
@@ -29,8 +29,8 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
string OrderNumber = Guid.NewGuid().ToString().Substring(0,10);
|
||||
Account? acc = await _databaseService.GetAccount(userID);
|
||||
if (acc != null) {
|
||||
List<Cart> cart = await _databaseService.GetCart(acc);
|
||||
(bool, string) PaymentResponse = await _paymentService.TryGetCheckoutToken(OrderNumber, acc, cart);
|
||||
Cart[] carts = await _databaseService.GetCart(acc);
|
||||
(bool, string) PaymentResponse = await _paymentService.TryGetCheckoutToken(OrderNumber, acc, carts);
|
||||
if (PaymentResponse.Item1) {
|
||||
// Returns client secret
|
||||
return PaymentResponse.Item2;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace MistoxWebsite.Server.Controllers.Payment {
|
||||
public static PaymentType _PaymentType;
|
||||
public static string _EndpointSecret = "";
|
||||
|
||||
public Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, Account user, List<Cart> cart);
|
||||
public Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, Account user, Cart[] cart);
|
||||
public Task ValidatePurchase(string WebHookData, string Headers);
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
_databaseService = databaseService;
|
||||
}
|
||||
|
||||
public async Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, Account user, List<Cart> cart) {
|
||||
public async Task<(bool, string)> TryGetCheckoutToken(string OrderNumber, Account user, Cart[] cart) {
|
||||
try {
|
||||
// build Recipt and calculate Tax
|
||||
var options = new Stripe.Tax.CalculationCreateOptions {
|
||||
|
||||
@@ -17,12 +17,11 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
|
||||
[Route( "api/cart/get" )]
|
||||
[HttpPost]
|
||||
public async Task<List<Cart>> GetCart( [FromBody] Account acc ) {
|
||||
public async Task<Cart[]> GetCart( [FromBody] Account acc ) {
|
||||
try {
|
||||
List<Cart> cart = await _databaseService.GetCart( acc );
|
||||
return cart;
|
||||
return await _databaseService.GetCart( acc );
|
||||
} catch {
|
||||
return new List<Cart>();
|
||||
return new Cart[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,17 +97,17 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
|
||||
[Route( "api/product/getall" )]
|
||||
[HttpPost]
|
||||
public ActionResult<List<Product>> GetAllProducts() {
|
||||
public ActionResult<Product[]> GetAllProducts() {
|
||||
try {
|
||||
return CatalogItems;
|
||||
return CatalogItems.ToArray();
|
||||
} catch {
|
||||
return new List<Product>();
|
||||
return new Product[0];
|
||||
}
|
||||
}
|
||||
|
||||
[Route( "api/product/getowned" )]
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<List<Receipt>>> GetOwnedProduct() {
|
||||
public async Task<ActionResult<Receipt[]>> GetOwnedProduct() {
|
||||
try {
|
||||
if( User.Identity != null && User.Identity.IsAuthenticated ) {
|
||||
string? email = User.FindFirstValue(ClaimTypes.Email);
|
||||
@@ -116,13 +115,13 @@ namespace MistoxWebsite.Server.Controllers {
|
||||
Account? test = await _databaseService.GetAccount(email);
|
||||
if( test != null ) {
|
||||
List<Receipt> returned = await _databaseService.GetAllReceipts(test);
|
||||
return returned;
|
||||
return returned.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new List<Receipt>();
|
||||
return new Receipt[0];
|
||||
} catch {
|
||||
return new List<Receipt>();
|
||||
return new Receipt[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user