diff --git a/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor b/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor index 8a313d1..45f1cb1 100644 --- a/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor +++ b/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor @@ -106,6 +106,59 @@ + + اطلاعات متا تگ + می توانید متا تگ های سئو برای صفحه مورد نظر را وارد کنید + + + + + + + + + + + + افزودن + + + + + + + + + + + + حذف + + + + + + + + سوالات متداول می توانید سوالات متداول شهر موردنظر را وارد کنید diff --git a/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor.cs b/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor.cs index 86d937b..95884dc 100644 --- a/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor.cs +++ b/Netina.AdminPanel.PWA/Dialogs/ProductCategoryActionDialogBox.razor.cs @@ -1,4 +1,7 @@ -namespace Netina.AdminPanel.PWA.Dialogs; +using Netina.Common.Models.Mapper; +using Netina.Domain.Entities.Seo; + +namespace Netina.AdminPanel.PWA.Dialogs; public class ProductCategoryActionDialogBoxViewModel:BaseViewModel { @@ -32,7 +35,8 @@ public class ProductCategoryActionDialogBoxViewModel:BaseViewModel public string Description = string.Empty; public bool IsMain; public bool IsEditing = false; - public readonly ObservableCollection Files = new ObservableCollection(); + public readonly ObservableCollection Files = new (); + public readonly ObservableCollection MetaTags = new(); private ProductCategorySDto? _category = null; [Parameter] @@ -59,6 +63,7 @@ public class ProductCategoryActionDialogBoxViewModel:BaseViewModel var response = await _restWrapper.CrudDtoApiRest(Address.ProductCategoryController).ReadOne(Category.Id); var categoryLDto = response; categoryLDto.Files.ForEach(f => Files.Add(f)); + categoryLDto.MetaTags.ForEach(m=> MetaTags.Add(m)); SelectedCategory = new ProductCategorySDto { Id = categoryLDto.ParentId, Name = categoryLDto.ParentName }; Name = categoryLDto.Name; Description = categoryLDto.Description; @@ -100,7 +105,7 @@ public class ProductCategoryActionDialogBoxViewModel:BaseViewModel SelectedCategory?.Id ?? default, Files.ToList(), Faqs, - new Dictionary()); + MetaTags.ToDictionary(x => x.Type, x => x.Value)); await _restWrapper.CrudApiRest(Address.ProductCategoryController).Create(request, token); _mudDialog.Close(DialogResult.Ok(true)); } @@ -140,7 +145,7 @@ public class ProductCategoryActionDialogBoxViewModel:BaseViewModel SelectedCategory?.Id ?? default, Files.ToList(), Faqs, - new Dictionary()); + MetaTags.ToDictionary(x => x.Type, x => x.Value)); await _restWrapper.CrudApiRest(Address.ProductCategoryController).Update(request, token); _mudDialog.Close(DialogResult.Ok(true)); } @@ -162,6 +167,25 @@ public class ProductCategoryActionDialogBoxViewModel:BaseViewModel } } + public string MetaTagType { get; set; } = string.Empty; + public string MetaTagValue { get; set; } = string.Empty; + public void AddMetaTag() + { + try + { + if (MetaTagType.IsNullOrEmpty()) + throw new Exception("لطفا نوع متا مورد نظر را وارد کنید"); + if (MetaTagValue.IsNullOrEmpty()) + throw new Exception("لطفا مقدار متا مورد نظر را وارد کنید"); + + MetaTags.Add(new MetaTagSDto() { Type = MetaTagType, Value = MetaTagValue }); + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + } + } + private List _productCategories = new List(); public ProductCategorySDto? SelectedCategory; public async Task> SearchCategory(string city) diff --git a/Netina.AdminPanel.PWA/Netina.AdminPanel.PWA.csproj b/Netina.AdminPanel.PWA/Netina.AdminPanel.PWA.csproj index ec3db87..af06988 100644 --- a/Netina.AdminPanel.PWA/Netina.AdminPanel.PWA.csproj +++ b/Netina.AdminPanel.PWA/Netina.AdminPanel.PWA.csproj @@ -5,8 +5,8 @@ enable enable service-worker-assets.js - 1.5.15.22 - 1.5.15.22 + 1.6.18.28 + 1.6.18.28 $(MSBuildProjectName) diff --git a/Netina.AdminPanel.PWA/Pages/BrandsPage.razor.cs b/Netina.AdminPanel.PWA/Pages/BrandsPage.razor.cs index 50cb523..0a72ecd 100644 --- a/Netina.AdminPanel.PWA/Pages/BrandsPage.razor.cs +++ b/Netina.AdminPanel.PWA/Pages/BrandsPage.razor.cs @@ -2,43 +2,36 @@ namespace Netina.AdminPanel.PWA.Pages; -public class BrandsPageViewModel : BaseViewModel> +public class BrandsPageViewModel( + NavigationManager navigationManager, + ISnackbar snackbar, + IUserUtility userUtility, + IRestWrapper restWrapper, + IDialogService dialogService) : BaseViewModel>(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 int CurrentPage = 0; public int PageCount = 1; - public BrandsPageViewModel(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; - var dto = await _restWrapper.CrudDtoApiRest(Address.BrandController) + var dto = await restWrapper.CrudDtoApiRest(Address.BrandController) .ReadAll(0); PageDto = dto; } 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 { @@ -51,18 +44,18 @@ public class BrandsPageViewModel : BaseViewModel> public async Task AddBrandClicked() { DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, DisableBackdropClick = true }; - await _dialogService.ShowAsync("افزودن برند جدید", maxWidth); + await dialogService.ShowAsync("افزودن برند جدید", maxWidth); } public async Task EditBrandAsync(BrandSDto brand) { DialogOptions maxWidth = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true, DisableBackdropClick = true }; var parameters = new DialogParameters { { x => x.Brand, brand } }; - await _dialogService.ShowAsync($"ویرایش برند {brand.PersianName}", parameters, maxWidth); + await dialogService.ShowAsync($"ویرایش برند {brand.PersianName}", parameters, maxWidth); } public async Task DeleteBrandAsync(Guid selectedCategoryId) { - var reference = await _dialogService.ShowQuestionDialog($"آیا از حذف برند اطمینان دارید ?"); + var reference = await dialogService.ShowQuestionDialog($"آیا از حذف برند اطمینان دارید ?"); var result = await reference.Result; if (!result.Canceled) { @@ -72,20 +65,20 @@ public class BrandsPageViewModel : BaseViewModel> IsProcessing = true; var token = await _userUtility.GetBearerTokenAsync(); - await _restWrapper.CrudDtoApiRest(Address.BrandController) + await restWrapper.CrudDtoApiRest(Address.BrandController) .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 { @@ -102,6 +95,7 @@ public class BrandsPageViewModel : BaseViewModel> await InitializeAsync(); Search = search; } + public async Task SearchAsync() { try @@ -112,7 +106,7 @@ public class BrandsPageViewModel : BaseViewModel> CurrentPage = 0; PageCount = 1; PageDto.Clear(); - var dto = await _restWrapper.BrandRestApi.ReadAll(CurrentPage, Search); + var dto = await restWrapper.BrandRestApi.ReadAll(CurrentPage, Search); dto.ForEach(d => PageDto.Add(d)); if (PageDto.Count == 20) PageCount = 2; @@ -120,11 +114,11 @@ public class BrandsPageViewModel : BaseViewModel> 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 { @@ -146,12 +140,12 @@ public class BrandsPageViewModel : BaseViewModel> List dto = new List(); if (Search.IsNullOrEmpty()) { - dto = await _restWrapper.CrudDtoApiRest(Address.BrandController) + dto = await restWrapper.CrudDtoApiRest(Address.BrandController) .ReadAll(CurrentPage); } else { - dto = await _restWrapper.BrandRestApi.ReadAll(CurrentPage, Search); + dto = await restWrapper.BrandRestApi.ReadAll(CurrentPage, Search); } dto.ForEach(d => PageDto.Add(d)); @@ -162,11 +156,11 @@ public class BrandsPageViewModel : BaseViewModel> 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 { diff --git a/Netina.AdminPanel.PWA/Pages/CustomersPage.razor b/Netina.AdminPanel.PWA/Pages/CustomersPage.razor new file mode 100644 index 0000000..9b15d2c --- /dev/null +++ b/Netina.AdminPanel.PWA/Pages/CustomersPage.razor @@ -0,0 +1,92 @@ +@page "/crm/customers" + +@inject IDialogService DialogService +@inject NavigationManager NavigationManager +@inject IRestWrapper RestWrapper +@inject ISnackbar Snackbar +@inject IUserUtility UserUtility + + +@* + + + + مشتریان شما + + + + + + + + + + + + + + + @if (@context.Item.HasSpecialPage) + { +

بلی

+ } + else + { +

خیر

+ + } +
+
+ + + + + + + + +
+ + + + + + + +
+
+
+
+
*@ + +@code { + + public BrandsPageViewModel ViewModel { get; set; } + protected override async Task OnInitializedAsync() + { + ViewModel = new BrandsPageViewModel(NavigationManager, Snackbar, UserUtility, RestWrapper, DialogService); + await ViewModel.InitializeAsync(); + await base.OnInitializedAsync(); + } + +} diff --git a/Netina.AdminPanel.PWA/Pages/CustomersPage.razor.cs b/Netina.AdminPanel.PWA/Pages/CustomersPage.razor.cs new file mode 100644 index 0000000..c4f36d5 --- /dev/null +++ b/Netina.AdminPanel.PWA/Pages/CustomersPage.razor.cs @@ -0,0 +1,121 @@ +using Netina.Domain.Entities.Brands; + +namespace Netina.AdminPanel.PWA.Pages; + +public class CustomersPageViewModel( + NavigationManager navigationManager, + ISnackbar snackbar, + IUserUtility userUtility, + IRestWrapper restWrapper, + IDialogService dialogService) : BaseViewModel> (userUtility) +{ + public string Search = string.Empty; + public int CurrentPage = 0; + public int PageCount = 1; + + public override async Task InitializeAsync() + { + try + { + IsProcessing = true; + //var dto = await restWrapper.CrudDtoApiRest(Address.BrandController) + // .ReadAll(0); + //PageDto = dto; + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + snackbar.Add(e.Message, Severity.Error); + } + finally + { + + IsProcessing = false; + } + await base.InitializeAsync(); + } + public async Task SearchChanged(string search) + { + if (search.IsNullOrEmpty() && !Search.IsNullOrEmpty()) + await InitializeAsync(); + Search = search; + } + + public async Task SearchAsync() + { + try + { + if (Search.IsNullOrEmpty()) + throw new AppException("نام برند برای جست جو وارد نشده است"); + IsProcessing = true; + CurrentPage = 0; + PageCount = 1; + PageDto.Clear(); + //var dto = await restWrapper.BrandRestApi.ReadAll(CurrentPage, Search); + //dto.ForEach(d => PageDto.Add(d)); + //if (PageDto.Count == 20) + // PageCount = 2; + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + snackbar.Add(e.Message, Severity.Error); + } + finally + { + + IsProcessing = false; + } + } + + public async Task ChangePageAsync(int page) + { + CurrentPage = page - 1; + if (CurrentPage > PageCount - 2) + { + + try + { + IsProcessing = true; + + List dto = new List(); + if (Search.IsNullOrEmpty()) + { + dto = await restWrapper.CrudDtoApiRest(Address.BrandController) + .ReadAll(CurrentPage); + } + else + { + dto = await restWrapper.BrandRestApi.ReadAll(CurrentPage, Search); + } + + //dto.ForEach(d => PageDto.Add(d)); + if (PageDto.Count % 20 == 0) + PageCount = CurrentPage + 2; + + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + snackbar.Add(e.Message, Severity.Error); + } + finally + { + + IsProcessing = false; + } + } + } +} \ No newline at end of file diff --git a/Netina.AdminPanel.PWA/Services/RestServices/ICustomerRestApi.cs b/Netina.AdminPanel.PWA/Services/RestServices/ICustomerRestApi.cs new file mode 100644 index 0000000..df30c34 --- /dev/null +++ b/Netina.AdminPanel.PWA/Services/RestServices/ICustomerRestApi.cs @@ -0,0 +1,6 @@ +namespace Netina.AdminPanel.PWA.Services.RestServices; + +public interface ICustomerRestApi +{ + +} \ No newline at end of file