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