Refactor CartService to use async methods for cart operations and integrate gRPC for backend synchronization
This commit is contained in:
@@ -14,14 +14,14 @@ public partial class Cart : ComponentBase, IDisposable
|
||||
CartService.OnChange += StateHasChanged;
|
||||
}
|
||||
|
||||
private void ChangeQty(long productId, int value)
|
||||
private async Task ChangeQty(long productId, int value)
|
||||
{
|
||||
CartService.UpdateQuantity(productId, value);
|
||||
await CartService.UpdateQuantity(productId, value);
|
||||
}
|
||||
|
||||
private void Remove(long productId)
|
||||
private async Task Remove(long productId)
|
||||
{
|
||||
CartService.Remove(productId);
|
||||
await CartService.Remove(productId);
|
||||
}
|
||||
|
||||
private void ProceedCheckout()
|
||||
|
||||
@@ -72,7 +72,7 @@ public partial class CheckoutSummary : ComponentBase
|
||||
};
|
||||
|
||||
var id = await OrderService.CreateOrderAsync(order);
|
||||
Cart.Clear();
|
||||
await Cart.Clear();
|
||||
Snackbar.Add("سفارش با موفقیت ثبت شد.", Severity.Success);
|
||||
Navigation.NavigateTo($"{RouteConstants.Store.OrderDetail}{id}");
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ public partial class ProductDetail : ComponentBase
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
private void AddToCart()
|
||||
private async Task AddToCart()
|
||||
{
|
||||
if (_product is null) return;
|
||||
Cart.Add(_product, _qty);
|
||||
await Cart.Add(_product, _qty);
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
|
||||
@@ -31,9 +31,9 @@ public partial class Products : ComponentBase, IDisposable
|
||||
await Load();
|
||||
}
|
||||
|
||||
private void AddToCart(Product p)
|
||||
private async Task AddToCart(Product p)
|
||||
{
|
||||
Cart.Add(p, 1);
|
||||
await Cart.Add(p, 1);
|
||||
}
|
||||
|
||||
private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price);
|
||||
|
||||
Reference in New Issue
Block a user