fix marten
parent
08a0fb79b7
commit
52e78968b0
|
@ -1,42 +1,36 @@
|
|||
namespace Netina.AdminPanel.PWA.Pages;
|
||||
|
||||
public class CategoriesPageViewModel : BaseViewModel<ObservableCollection<ProductCategorySDto>>
|
||||
public class CategoriesPageViewModel(
|
||||
NavigationManager navigationManager,
|
||||
ISnackbar snackbar,
|
||||
IUserUtility userUtility,
|
||||
IRestWrapper restWrapper,
|
||||
IDialogService dialogService)
|
||||
: BaseViewModel<ObservableCollection<ProductCategorySDto>>(userUtility)
|
||||
{
|
||||
private readonly NavigationManager _navigationManager;
|
||||
private readonly ISnackbar _snackbar;
|
||||
private readonly IUserUtility _userUtility;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IRestWrapper _restWrapper;
|
||||
private readonly NavigationManager _navigationManager = navigationManager;
|
||||
private readonly IUserUtility _userUtility = userUtility;
|
||||
|
||||
public string Search = string.Empty;
|
||||
|
||||
public CategoriesPageViewModel(NavigationManager navigationManager, ISnackbar snackbar, IUserUtility userUtility, IRestWrapper restWrapper, IDialogService dialogService) : base(userUtility)
|
||||
{
|
||||
_navigationManager = navigationManager;
|
||||
_snackbar = snackbar;
|
||||
_userUtility = userUtility;
|
||||
_restWrapper = restWrapper;
|
||||
_dialogService = dialogService;
|
||||
}
|
||||
|
||||
public override async Task InitializeAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsProcessing = true;
|
||||
PageDto.Clear();
|
||||
var dto = await _restWrapper.ProductCategoryRestApi.ReadAll(true);
|
||||
var dto = await restWrapper.ProductCategoryRestApi.ReadAll(true);
|
||||
dto.ForEach(d => PageDto.Add(d));
|
||||
|
||||
}
|
||||
catch (ApiException ex)
|
||||
{
|
||||
var exe = await ex.GetContentAsAsync<ApiResult>();
|
||||
_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
|
||||
{
|
||||
|
@ -50,7 +44,7 @@ public class CategoriesPageViewModel : BaseViewModel<ObservableCollection<Produc
|
|||
public async Task AddProductCategoryClicked()
|
||||
{
|
||||
DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, DisableBackdropClick = true };
|
||||
var dialogResult = await _dialogService.ShowAsync<ProductCategoryActionDialogBox>("افزودن دسته جدید", maxWidth);
|
||||
var dialogResult = await dialogService.ShowAsync<ProductCategoryActionDialogBox>("افزودن دسته جدید", maxWidth);
|
||||
var result = await dialogResult.Result;
|
||||
if (!result.Canceled && result.Data is bool and true)
|
||||
{
|
||||
|
@ -63,7 +57,7 @@ public class CategoriesPageViewModel : BaseViewModel<ObservableCollection<Produc
|
|||
DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, DisableBackdropClick = true };
|
||||
var parameters = new DialogParameters<ProductCategoryActionDialogBox>();
|
||||
parameters.Add(x => x.Category, category);
|
||||
var dialogResult = await _dialogService.ShowAsync<ProductCategoryActionDialogBox>($"ویرایش دسته {category.Name}", parameters, maxWidth);
|
||||
var dialogResult = await dialogService.ShowAsync<ProductCategoryActionDialogBox>($"ویرایش دسته {category.Name}", parameters, maxWidth);
|
||||
var result = await dialogResult.Result;
|
||||
if (!result.Canceled && result.Data is bool and true)
|
||||
{
|
||||
|
@ -73,7 +67,7 @@ public class CategoriesPageViewModel : BaseViewModel<ObservableCollection<Produc
|
|||
|
||||
public async Task DeleteProductCategoryAsync(Guid selectedCategoryId)
|
||||
{
|
||||
var reference = await _dialogService.ShowQuestionDialog($"آیا از حذف دسته بندی اطمینان دارید ?");
|
||||
var reference = await dialogService.ShowQuestionDialog($"آیا از حذف دسته بندی اطمینان دارید ?");
|
||||
var result = await reference.Result;
|
||||
if (!result.Canceled)
|
||||
{
|
||||
|
@ -83,20 +77,20 @@ public class CategoriesPageViewModel : BaseViewModel<ObservableCollection<Produc
|
|||
|
||||
IsProcessing = true;
|
||||
var token = await _userUtility.GetBearerTokenAsync();
|
||||
await _restWrapper.CrudDtoApiRest<ProductCategory, ProductCategorySDto, Guid>(Address.ProductCategoryController)
|
||||
await restWrapper.CrudDtoApiRest<ProductCategory, ProductCategorySDto, Guid>(Address.ProductCategoryController)
|
||||
.Delete(selectedCategoryId, token);
|
||||
_snackbar.Add("حذف دسته بندی با موفقیت انجام شد", Severity.Success);
|
||||
snackbar.Add("حذف دسته بندی با موفقیت انجام شد", Severity.Success);
|
||||
await InitializeAsync();
|
||||
|
||||
}
|
||||
catch (ApiException ex)
|
||||
{
|
||||
var exe = await ex.GetContentAsAsync<ApiResult>();
|
||||
_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
|
||||
{
|
||||
|
@ -114,17 +108,17 @@ public class CategoriesPageViewModel : BaseViewModel<ObservableCollection<Produc
|
|||
throw new AppException("دسته بندی برای جست جو وارد نشده است");
|
||||
IsProcessing = true;
|
||||
PageDto.Clear();
|
||||
var dto = await _restWrapper.ProductCategoryRestApi.ReadAll(Search);
|
||||
var dto = await restWrapper.ProductCategoryRestApi.ReadAll(Search);
|
||||
dto.ForEach(d => PageDto.Add(d));
|
||||
}
|
||||
catch (ApiException ex)
|
||||
{
|
||||
var exe = await ex.GetContentAsAsync<ApiResult>();
|
||||
_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
|
||||
{
|
||||
|
@ -173,7 +167,7 @@ public class CategoriesPageViewModel : BaseViewModel<ObservableCollection<Produc
|
|||
var token = await _userUtility.GetBearerTokenAsync();
|
||||
if (token == null)
|
||||
return;
|
||||
var response = await _restWrapper.CrudApiRest<ProductCategory, Guid>(Address.ProductCategoryController)
|
||||
var response = await restWrapper.CrudApiRest<ProductCategory, Guid>(Address.ProductCategoryController)
|
||||
.Create(command, token);
|
||||
category.Id = response;
|
||||
});
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
<Columns>
|
||||
<PropertyColumn Title="عنوان" Property="arg => arg.Title" />
|
||||
<PropertyColumn Title="اسلاگ" Property="arg => arg.Slug" />
|
||||
<PropertyColumn T="BaseFaq" TProperty="int" Title="تعداد سوالات" Property="arg => arg.Faqs.Count" />
|
||||
<TemplateColumn CellClass="d-flex justify-end">
|
||||
<CellTemplate>
|
||||
<MudStack Row="true">
|
||||
|
|
|
@ -66,7 +66,7 @@ public class FaqManagementPageViewModel(
|
|||
{
|
||||
DialogOptions maxWidth = new DialogOptions()
|
||||
{ MaxWidth = MaxWidth.Medium, FullWidth = true, DisableBackdropClick = true };
|
||||
var reference = await dialogService.ShowAsync<FaqActionDialogBox>("افزودن اژانس هواپیمایی جدید", maxWidth);
|
||||
var reference = await dialogService.ShowAsync<FaqActionDialogBox>("افزودن سوالات متداول جدید", maxWidth);
|
||||
var result = await reference.Result;
|
||||
if (result.Data is bool and true)
|
||||
await InitializeAsync();
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
"WebSiteUrl": "https://vesmeh.com",
|
||||
"AdminPanelBaseUrl": "https://admin.vesmeh.com",
|
||||
"StorageBaseUrl": "https://storage.vesmeh.com",
|
||||
"ApiUrl": "https://api.vesmeh.com/api",
|
||||
//"ApiUrl": "http://localhost:32770/api",
|
||||
//"ApiUrl": "https://api.vesmeh.com/api",
|
||||
"ApiUrl": "http://localhost:32770/api",
|
||||
|
||||
//"WebSiteUrl": "https://bonsaigallery.shop",
|
||||
//"AdminPanelBaseUrl": "https://admin.bonsaigallery.shop",
|
||||
|
|
Loading…
Reference in New Issue