This commit is contained in:
mmrbnjd
2024-10-15 14:19:54 +03:30
parent 595a9ea5d8
commit fb4e9b5bd5
13 changed files with 257 additions and 122 deletions

View File

@@ -97,19 +97,21 @@
<br />
@if (order.Status == StatusOrder.Create)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickPay" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Success" @onclick="OnClickPay" Type="ButtonType.Button">
پرداخت با کیف پول
</Button>
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickCancel" Type="ButtonType.Button">
<Button Disabled="SpinnerVisible" class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickCancel" Type="ButtonType.Button">
ابطال
</Button>
}
</div>
<div class="col-md-2">
<Spinner Visible="SpinnerVisible" Color="SpinnerColor.Primary" />
</div>
@code {
public bool SpinnerVisible { get; set; } = false;
#region Alert
// alert
AlertColor alertColor = AlertColor.Primary;
@@ -162,12 +164,17 @@
}
private async Task<List<OrderItemDto>> LoadOrderItem()
{
SpinnerVisible = true;
var rsp = await hc.Get($"Orders/GetOrderDetails/{order.ID}");
if (rsp.IsSuccessStatusCode)
{
SpinnerVisible = false;
return await rsp.Content.ReadFromJsonAsync<List<OrderItemDto>?>();
}
else
{
SpinnerVisible = false;
ShowDangerAlert("خطایی در بارگیری");
return new List<OrderItemDto>();
}
@@ -175,6 +182,7 @@
}
private async Task OnClickPay()
{
SpinnerVisible = true;
var rsp = await hc.Get($"Orders/SubmitOrderBywallet/{order.ID}");
if (rsp.IsSuccessStatusCode)
@@ -183,6 +191,7 @@
result = new ActionInResultComponent();
result.Status = ComponentStatus.success;
result.Action = ComponentAction.add;
await OnMultipleOfThree.InvokeAsync(result);
}
else
@@ -190,8 +199,8 @@
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
SpinnerVisible = false;
}
private async Task OnClickCancel()
@@ -203,32 +212,35 @@
if (confirmation)
{
SpinnerVisible = true;
PreloadService.Show(SpinnerColor.Dark);
var rsp = await hc.Delete($"Orders/CancelOrder/{order.ID}");
PreloadService.Hide();
if (rsp.IsSuccessStatusCode)
{
if(await rsp.Content.ReadFromJsonAsync<bool>())
if (await rsp.Content.ReadFromJsonAsync<bool>())
{
order.Status = StatusOrder.Cancel;
result = new ActionInResultComponent();
result.Status = ComponentStatus.success;
result.Action = ComponentAction.delete;
await OnMultipleOfThree.InvokeAsync(result);
result.Action = ComponentAction.delete;
await OnMultipleOfThree.InvokeAsync(result);
}
else
ShowDangerAlert("خطای سیستمی");
}
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
ShowDangerAlert("سفارش یافت نشد");
else
ShowDangerAlert("خطای سیستمی");
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
SpinnerVisible = false;
}
else if (rsp.StatusCode==System.Net.HttpStatusCode.NotFound)
ShowDangerAlert("سفارش یافت نشد");
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
}
}