diff --git a/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor b/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor
index b245a96..ff703c0 100644
--- a/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor
+++ b/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor
@@ -199,6 +199,7 @@
diff --git a/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs b/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs
index 569e4d4..8825991 100644
--- a/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs
+++ b/Netina.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs
@@ -259,4 +259,41 @@ public class OrderActionDialogBoxViewModel : BaseViewModel
}
}
-}
\ No newline at end of file
+
+ public async Task CancelAsync()
+ {
+ var reference = await _dialogService.ShowQuestionDialog($"ایا از کنسل کردن سفارش اطمینان دارید ?");
+ var result = await reference.Result;
+ if (!result.Canceled)
+ {
+ try
+ {
+ var token = await _userUtility.GetBearerTokenAsync();
+ if (token == null)
+ throw new Exception("Token is null");
+ IsProcessing = true;
+
+
+ await _restWrapper.OrderRestApi.CancelOrderStepAsync(PageDto.Id, token);
+ _snackbar.Add($"سفارش {PageDto.FactorCode} کنسل شد", Severity.Warning);
+ _mudDialog.Close(true);
+ }
+ catch (ApiException ex)
+ {
+ var exe = await ex.GetContentAsAsync();
+ _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
+ _mudDialog.Cancel();
+ }
+ catch (Exception e)
+ {
+ _snackbar.Add(e.Message, Severity.Error);
+ _mudDialog.Cancel();
+ }
+ finally
+ {
+
+ IsProcessing = false;
+ }
+ }
+ }
+}
diff --git a/Netina.AdminPanel.PWA/Pages/ProductsPage.razor.cs b/Netina.AdminPanel.PWA/Pages/ProductsPage.razor.cs
index 6525a94..33db24b 100644
--- a/Netina.AdminPanel.PWA/Pages/ProductsPage.razor.cs
+++ b/Netina.AdminPanel.PWA/Pages/ProductsPage.razor.cs
@@ -2,14 +2,17 @@
namespace Netina.AdminPanel.PWA.Pages;
-public class ProductsPageViewModel : BaseViewModel>
+public class ProductsPageViewModel(
+ NavigationManager navigationManager,
+ ISnackbar snackbar,
+ IUserUtility userUtility,
+ IRestWrapper restWrapper,
+ IDialogService dialogService,
+ IBrowserViewportService browserViewportService)
+ : BaseViewModel>(userUtility)
{
- private readonly NavigationManager _navigationManager;
- private readonly ISnackbar _snackbar;
- private readonly IUserUtility _userUtility;
- private readonly IDialogService _dialogService;
- private readonly IBrowserViewportService _browserViewportService;
- private readonly IRestWrapper _restWrapper;
+ private readonly NavigationManager _navigationManager = navigationManager;
+ private readonly IUserUtility _userUtility = userUtility;
public string? Search = string.Empty;
public int CurrentPage = 0;
@@ -18,22 +21,6 @@ public class ProductsPageViewModel : BaseViewModel PageDto.Add(d));
if (PageDto.Count % 20 == 0)
PageCount = CurrentPage + 2;
TotalItems = dto.Pager.TotalItems;
- IsXs = (await _browserViewportService.GetCurrentBreakpointAsync()) == Breakpoint.Xs;
+ IsXs = (await browserViewportService.GetCurrentBreakpointAsync()) == Breakpoint.Xs;
}
catch (ApiException ex)
{
var exe = await ex.GetContentAsAsync();
- _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
+ snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
}
catch (Exception e)
{
- _snackbar.Add(e.Message, Severity.Error);
+ snackbar.Add(e.Message, Severity.Error);
}
finally
{
@@ -82,10 +69,10 @@ public class ProductsPageViewModel : BaseViewModel("افزودن محصول جدید", maxWidth);
+ var dialogResult = await dialogService.ShowAsync("افزودن محصول جدید", maxWidth);
var result = await dialogResult.Result;
if (!result.Canceled && result.Data is bool and true)
{
@@ -97,10 +84,10 @@ public class ProductsPageViewModel : BaseViewModel("افزودن محصول جدید", maxWidth);
+ var dialogResult = await dialogService.ShowAsync("افزودن محصول جدید", maxWidth);
var result = await dialogResult.Result;
if (!result.Canceled && result.Data is bool and true)
{
@@ -111,7 +98,7 @@ public class ProductsPageViewModel : BaseViewModel("افزودن محصول جدید", maxWidth);
+ var dialogResult = await dialogService.ShowAsync("افزودن محصول جدید", maxWidth);
var result = await dialogResult.Result;
if (!result.Canceled && result.Data is bool and true)
{
@@ -122,12 +109,12 @@ public class ProductsPageViewModel : BaseViewModel();
parameters.Add(x => x.Product, product);
- var dialogResult = await _dialogService.ShowAsync($"ویرایش محصول {product.PersianName}", parameters, maxWidth);
+ var dialogResult = await dialogService.ShowAsync($"ویرایش محصول {product.PersianName}", parameters, maxWidth);
var result = await dialogResult.Result;
if (!result.Canceled && result.Data is bool and true)
{
@@ -137,7 +124,7 @@ public class ProductsPageViewModel : BaseViewModel(Address.ProductController)
+ await restWrapper.CrudDtoApiRest(Address.ProductController)
.Delete(selectedCategoryId, token);
- _snackbar.Add("حذف محصول با موفقیت انجام شد", Severity.Success);
+ snackbar.Add("حذف محصول با موفقیت انجام شد", Severity.Success);
await InitializeAsync();
}
catch (ApiException ex)
{
var exe = await ex.GetContentAsAsync();
- _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
+ snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
}
catch (Exception e)
{
- _snackbar.Add(e.Message, Severity.Error);
+ snackbar.Add(e.Message, Severity.Error);
}
finally
{
@@ -185,22 +172,22 @@ public class ProductsPageViewModel : BaseViewModel();
if (exe != null)
- _snackbar.Add(exe.Message, Severity.Error);
- _snackbar.Add(ex.Content, Severity.Error);
+ snackbar.Add(exe.Message, Severity.Error);
+ snackbar.Add(ex.Content, Severity.Error);
return _productCategories;
}
catch (Exception e)
{
- _snackbar.Add(e.Message, Severity.Error);
+ snackbar.Add(e.Message, Severity.Error);
return _productCategories;
}
}
@@ -224,16 +211,16 @@ public class ProductsPageViewModel : BaseViewModel();
- _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
+ snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
}
catch (Exception e)
{
- _snackbar.Add(e.Message, Severity.Error);
+ snackbar.Add(e.Message, Severity.Error);
}
}
diff --git a/Netina.AdminPanel.PWA/Services/RestServices/IOrderRestApi.cs b/Netina.AdminPanel.PWA/Services/RestServices/IOrderRestApi.cs
index b6d1869..799dc6a 100644
--- a/Netina.AdminPanel.PWA/Services/RestServices/IOrderRestApi.cs
+++ b/Netina.AdminPanel.PWA/Services/RestServices/IOrderRestApi.cs
@@ -16,6 +16,9 @@ public interface IOrderRestApi
[Post("/{id}/confirm")]
Task ConfirmOrderStepAsync(Guid id,[Query] OrderStatus nextOrderStatus, [Header("Authorization")] string authorization);
+
+ [Post("/{id}/cancel")]
+ Task CancelOrderStepAsync(Guid id ,[Header("Authorization")] string authorization);
[Post("/{id}/confirm")]
Task ConfirmOrderStepAsync(Guid id, [Query] OrderStatus nextOrderStatus, [Query]string trackingCode, [Header("Authorization")] string authorization);
}
\ No newline at end of file