diff --git a/src/FrontOffice.Main/ConfigureServices.cs b/src/FrontOffice.Main/ConfigureServices.cs index aeaf20b..76ab52e 100644 --- a/src/FrontOffice.Main/ConfigureServices.cs +++ b/src/FrontOffice.Main/ConfigureServices.cs @@ -5,22 +5,22 @@ using Grpc.Net.Client; using MudBlazor.Services; using System.Text.Json; using System.Text.Json.Serialization; -using FrontOffice.BFF.Category.Protobuf.Protos.Category; -using FrontOffice.BFF.Package.Protobuf.Protos.Package; -using FrontOffice.BFF.Transaction.Protobuf.Protos.Transaction; -using FrontOffice.BFF.User.Protobuf.Protos.User; -using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; -using FrontOffice.BFF.UserWallet.Protobuf.Protos.UserWallet; -using FrontOffice.BFF.ShopingCart.Protobuf.Protos.ShopingCart; -// New Proto imports -using FrontOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership; -using FrontOffice.BFF.Commission.Protobuf.Protos.Commission; -using FrontOffice.BFF.NetworkMembership.Protobuf.Protos.NetworkMembership; -using FrontOffice.BFF.DiscountShop.Protobuf.Protos.DiscountShop; -using FrontOffice.BFF.City.Protobuf; -using FrontOffice.BFF.Configuration.Protobuf.Protos.Configuration; -using FrontOffice.BFF.Configuration.Protobuf.Protos.AppVersion; +// Updated imports to use CMS protobuf instead of FrontOffice.BFF +using CMSMicroservice.Protobuf.Protos.Category; +using CMSMicroservice.Protobuf.Protos.City; +using CMSMicroservice.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.Products; +using CMSMicroservice.Protobuf.Protos.Transactions; +using CMSMicroservice.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.UserCarts; +using CMSMicroservice.Protobuf.Protos.UserOrder; +using CMSMicroservice.Protobuf.Protos.UserWallet; +using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.Configuration; +using CMSMicroservice.Protobuf.Protos.NetworkMembership; +using CMSMicroservice.Protobuf.Protos.Commission; +using CMSMicroservice.Protobuf.Protos.AppVersion; using FrontOffice.Main.Utilities; namespace Microsoft.Extensions.DependencyInjection; @@ -64,6 +64,8 @@ public static class ConfigureServices services.AddScoped(); // App Version Service for cache invalidation services.AddScoped(); + // Main Service for core functionality + services.AddScoped(); // Device detection: very light, dependency-free services.AddTransient(); // PDF generation (Chromium only) @@ -95,25 +97,24 @@ public static class ConfigureServices }; }); - // Register gRPC clients with authentication - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - // Products gRPC - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - // New gRPC clients for Club, Network, Commission, DiscountShop - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); - services.AddScoped(CreateAuthenticatedClient); + // Register gRPC clients with authentication - Updated for CMS + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); return services; } diff --git a/src/FrontOffice.Main/FrontOffice.Main.csproj b/src/FrontOffice.Main/FrontOffice.Main.csproj index f1f685c..57f77f3 100644 --- a/src/FrontOffice.Main/FrontOffice.Main.csproj +++ b/src/FrontOffice.Main/FrontOffice.Main.csproj @@ -10,29 +10,8 @@ - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/src/FrontOffice.Main/Pages/Checkout.razor.cs b/src/FrontOffice.Main/Pages/Checkout.razor.cs index 53bf220..1137e58 100644 --- a/src/FrontOffice.Main/Pages/Checkout.razor.cs +++ b/src/FrontOffice.Main/Pages/Checkout.razor.cs @@ -1,7 +1,8 @@ -using FrontOffice.BFF.Package.Protobuf.Protos.Package; -using FrontOffice.BFF.Transaction.Protobuf.Protos.Transaction; -using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; + +using CMSMicroservice.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.Transactions; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.UserOrder; using FrontOffice.Main.Utilities; using Google.Protobuf.WellKnownTypes; using Microsoft.AspNetCore.Components; @@ -15,7 +16,7 @@ public partial class Checkout [Inject] private PackageContract.PackageContractClient PackageClient { get; set; } = default!; [Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!; [Inject] private UserOrderContract.UserOrderContractClient UserOrderContract { get; set; } = default!; - [Inject] private TransactionContract.TransactionContractClient TransactionContract { get; set; } = default!; + [Inject] private TransactionsContract.TransactionsContractClient TransactionContract { get; set; } = default!; [Parameter] public long? PackageId { get; set; } @@ -186,7 +187,7 @@ public partial class Checkout try { // Step 1: Create payment request - var paymentRequest = new PaymentRequestRequest + var paymentRequest = new CustomerPaymentRequestRequest { Amount = _finalPrice, CallbackUrl = $"{Navigation.BaseUri}checkout/callback", @@ -195,7 +196,7 @@ public partial class Checkout Type = TransactionTypeEnum.Real }; - var paymentResponse = await TransactionContract.PaymentRequestAsync(paymentRequest); + var paymentResponse = await TransactionContract.CustomerPaymentRequestAsync(paymentRequest); if (string.IsNullOrEmpty(paymentResponse.PaymentGWUrl)) Snackbar.Add("آدرس درگاه پرداخت دریافت نشد.", Severity.Error); @@ -203,9 +204,9 @@ public partial class Checkout // Step 2: Create user order var orderRequest = new CreateNewUserOrderRequest { - Price = _finalPrice, + Amount = _finalPrice, PackageId = _selectedPackage.Id, - PaymentStatus = false // Will be updated after payment verification + PaymentStatus = CMSMicroservice.Protobuf.Protos.PaymentStatus.Pending }; var orderResponse = await UserOrderContract.CreateNewUserOrderAsync(orderRequest); diff --git a/src/FrontOffice.Main/Pages/Club/Components/ActivationSection.razor.cs b/src/FrontOffice.Main/Pages/Club/Components/ActivationSection.razor.cs index 2a9b0e3..6e60a63 100644 --- a/src/FrontOffice.Main/Pages/Club/Components/ActivationSection.razor.cs +++ b/src/FrontOffice.Main/Pages/Club/Components/ActivationSection.razor.cs @@ -1,5 +1,5 @@ using FrontOffice.Main.Utilities; -using FrontOffice.BFF.User.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.User; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/src/FrontOffice.Main/Pages/Index.razor.cs b/src/FrontOffice.Main/Pages/Index.razor.cs index 2c57942..bd4a508 100644 --- a/src/FrontOffice.Main/Pages/Index.razor.cs +++ b/src/FrontOffice.Main/Pages/Index.razor.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.Package.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.Package; using FrontOffice.Main.Utilities; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/src/FrontOffice.Main/Pages/PackageDetail.razor.cs b/src/FrontOffice.Main/Pages/PackageDetail.razor.cs index dd55752..d73c758 100644 --- a/src/FrontOffice.Main/Pages/PackageDetail.razor.cs +++ b/src/FrontOffice.Main/Pages/PackageDetail.razor.cs @@ -1,5 +1,5 @@ using Blazored.LocalStorage; -using FrontOffice.BFF.Package.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.Package; using FrontOffice.Main.Shared; using FrontOffice.Main.Utilities; using Grpc.Core; diff --git a/src/FrontOffice.Main/Pages/Profile/Addresses.razor.cs b/src/FrontOffice.Main/Pages/Profile/Addresses.razor.cs index b413453..976d66e 100644 --- a/src/FrontOffice.Main/Pages/Profile/Addresses.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/Addresses.razor.cs @@ -1,4 +1,5 @@ -using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.UserAddress; using FrontOffice.Main.Pages.Profile.Components; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor b/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor index a91bd48..48af523 100644 --- a/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor +++ b/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor @@ -1,10 +1,11 @@ - +@using CMSMicroservice.Protobuf.Protos.City + افزودن آدرس جدید - + - - @city.Native - (@city.StateName) + @(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).Native) + (@(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).StateName)) diff --git a/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor.cs b/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor.cs index 1b0be38..d5c6b70 100644 --- a/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/Components/AddAddressDialog.razor.cs @@ -1,43 +1,42 @@ -using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; -using FrontOffice.BFF.UserAddress.Protobuf.Validator; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.City; using Microsoft.AspNetCore.Components; using MudBlazor; using Severity = MudBlazor.Severity; -using CityProto = FrontOffice.BFF.City.Protobuf; namespace FrontOffice.Main.Pages.Profile.Components; +public record CityModel(long Id, string Name); + public partial class AddAddressDialog : ComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = default!; [Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!; - [Inject] private CityProto.CityContract.CityContractClient CityContract { get; set; } = default!; + [Inject] private CityContract.CityContractClient CityContract { get; set; } = default!; private MudForm? _form; - private readonly CreateNewUserAddressRequestValidator _validator = new(); private bool _isSaving; private CreateNewUserAddressRequest _request = new(); - private CityProto.GetAllCitiesByFilterResponseModel? _selectedCity; + private object? _selectedCity; - private async Task> SearchCities(string value, - CancellationToken ct) + private async Task> SearchCities(string value, CancellationToken ct) { if (string.IsNullOrWhiteSpace(value) || value.Length < 2) - return Enumerable.Empty(); + return Enumerable.Empty(); try { - var response = await CityContract.GetAllCitiesByFilterAsync(new CityProto.GetAllCitiesByFilterRequest + var response = await CityContract.GetAllCitiesByFilterAsync(new GetAllCitiesByFilterRequest { - PaginationState = new CityProto.PaginationState { PageNumber = 1, PageSize = 20 }, - Filter = new CityProto.GetAllCitiesByFilterFilter { Name = value } - }, cancellationToken: ct); - - return response?.Models?.ToList() ?? new List(); + PaginationState = new CMSMicroservice.Protobuf.Protos.City.PaginationState { PageNumber = 1, PageSize = 20 }, + Filter = new GetAllCitiesByFilterFilter { Name = value } + }); + + return response?.Cities?.Cast() ?? Enumerable.Empty(); } catch { - return Enumerable.Empty(); + return Enumerable.Empty(); } } @@ -53,7 +52,7 @@ public partial class AddAddressDialog : ComponentBase return; } - _request.CityId = _selectedCity.Id; + _request.CityId = (long)((dynamic)_selectedCity).Id; _isSaving = true; try { diff --git a/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor b/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor index 29c3c8c..07f83c1 100644 --- a/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor +++ b/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor @@ -1,9 +1,10 @@ +@using CMSMicroservice.Protobuf.Protos.City ویرایش آدرس - + - - @city.Native - (@city.StateName) + @(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).Native) + (@(((CMSMicroservice.Protobuf.Protos.City.CityDto)city).StateName)) diff --git a/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor.cs b/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor.cs index a028f88..aa288e9 100644 --- a/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/Components/EditAddressDialog.razor.cs @@ -1,10 +1,9 @@ -using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; -using FrontOffice.BFF.UserAddress.Protobuf.Validator; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.City; using Mapster; using Microsoft.AspNetCore.Components; using MudBlazor; using Severity = MudBlazor.Severity; -using CityProto = FrontOffice.BFF.City.Protobuf; namespace FrontOffice.Main.Pages.Profile.Components; @@ -12,15 +11,14 @@ public partial class EditAddressDialog : ComponentBase { [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = default!; [Inject] private UserAddressContract.UserAddressContractClient UserAddressContract { get; set; } = default!; - [Inject] private CityProto.CityContract.CityContractClient CityContract { get; set; } = default!; + [Inject] private CityContract.CityContractClient CityContract { get; set; } = default!; [Parameter] public GetAllUserAddressByFilterResponseModel? Model { get; set; } private MudForm? _form; - private readonly UpdateUserAddressRequestValidator _validator = new(); private bool _isSaving; private UpdateUserAddressRequest _request = new(); - private CityProto.GetAllCitiesByFilterResponseModel? _selectedCity; + private object? _selectedCity; protected override async Task OnInitializedAsync() { @@ -41,13 +39,13 @@ public partial class EditAddressDialog : ComponentBase { try { - var response = await CityContract.GetAllCitiesByFilterAsync(new CityProto.GetAllCitiesByFilterRequest + var response = await CityContract.GetAllCitiesByFilterAsync(new GetAllCitiesByFilterRequest { - PaginationState = new CityProto.PaginationState { PageNumber = 1, PageSize = 1 }, - Filter = new CityProto.GetAllCitiesByFilterFilter { Id = cityId } + PaginationState = new CMSMicroservice.Protobuf.Protos.City.PaginationState { PageNumber = 1, PageSize = 1 }, + Filter = new GetAllCitiesByFilterFilter { Id = cityId } }); - _selectedCity = response?.Models?.FirstOrDefault(); + _selectedCity = response?.Cities?.FirstOrDefault(); } catch { @@ -55,24 +53,24 @@ public partial class EditAddressDialog : ComponentBase } } - private async Task> SearchCities(string value, CancellationToken ct) + private async Task> SearchCities(string value, CancellationToken ct) { if (string.IsNullOrWhiteSpace(value) || value.Length < 2) - return Enumerable.Empty(); + return Enumerable.Empty(); try { - var response = await CityContract.GetAllCitiesByFilterAsync(new CityProto.GetAllCitiesByFilterRequest + var response = await CityContract.GetAllCitiesByFilterAsync(new GetAllCitiesByFilterRequest { - PaginationState = new CityProto.PaginationState { PageNumber = 1, PageSize = 20 }, - Filter = new CityProto.GetAllCitiesByFilterFilter { Native = value } - }, cancellationToken: ct); - - return response?.Models?.ToList() ?? new List(); + PaginationState = new CMSMicroservice.Protobuf.Protos.City.PaginationState { PageNumber = 1, PageSize = 20 }, + Filter = new GetAllCitiesByFilterFilter { Name = value } + }); + + return response?.Cities?.Cast() ?? Enumerable.Empty(); } catch { - return Enumerable.Empty(); + return Enumerable.Empty(); } } @@ -88,7 +86,7 @@ public partial class EditAddressDialog : ComponentBase return; } - _request.CityId = _selectedCity.Id; + _request.CityId = (long)((dynamic)_selectedCity).Id; _isSaving = true; try { diff --git a/src/FrontOffice.Main/Pages/Profile/Index.razor.cs b/src/FrontOffice.Main/Pages/Profile/Index.razor.cs index 3340c33..0bfc264 100644 --- a/src/FrontOffice.Main/Pages/Profile/Index.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/Index.razor.cs @@ -1,9 +1,5 @@ using FluentValidation; -using FrontOffice.BFF.User.Protobuf.Protos.User; -using FrontOffice.BFF.User.Protobuf.Validator; -using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; -using FrontOffice.BFF.UserAddress.Protobuf.Validator; -using FrontOffice.BFF.Package.Protobuf.Protos.Package; + using FrontOffice.Main.Pages.Profile.Components; using FrontOffice.Main.Utilities; using Mapster; @@ -11,6 +7,11 @@ using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MudBlazor; using System.ComponentModel.DataAnnotations; +using CMSMicroservice.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Validator.User; +using CMSMicroservice.Protobuf.Validator.UserAddress; using Severity = MudBlazor.Severity; namespace FrontOffice.Main.Pages.Profile; diff --git a/src/FrontOffice.Main/Pages/Profile/PaymentCallback.razor b/src/FrontOffice.Main/Pages/Profile/PaymentCallback.razor index 7aad246..a02dcd3 100644 --- a/src/FrontOffice.Main/Pages/Profile/PaymentCallback.razor +++ b/src/FrontOffice.Main/Pages/Profile/PaymentCallback.razor @@ -1,8 +1,9 @@ @page "/profile/payment-callback" @attribute [Authorize] @using Blazored.LocalStorage -@using FrontOffice.BFF.Package.Protobuf.Protos.Package -@using FrontOffice.BFF.User.Protobuf.Protos.User +@using CMSMicroservice.Protobuf.Protos.Package +@using CMSMicroservice.Protobuf.Protos.User + نتیجه پرداخت | کارا بازار سلامت @@ -112,13 +113,14 @@ { OrderId = OrderId, TransactionId = TransactionId, - Authority = Authority, - Status = Status ?? "NOK" + PaymentSuccess = Status == "OK", + RefId = !string.IsNullOrEmpty(Authority) ? Authority : null, + Message = !string.IsNullOrEmpty(Status) ? Status : null }); _isSuccess = response.Success; _message = response.Message; - _refId = response.RefId; + _refId = response.ReferenceCode ?? ""; _walletBalance = response.WalletBalance; _discountBalance = response.DiscountBalance; @@ -153,7 +155,7 @@ { try { - var userResponse = await UserContractClient.GetUserAsync(new Google.Protobuf.WellKnownTypes.Empty()); + var userResponse = await UserContractClient.GetUserForCustomerAsync(new CMSMicroservice.Protobuf.Protos.User.GetUserForCustomerRequest()); if (!string.IsNullOrWhiteSpace(userResponse.Token)) { // ذخیره توکن جدید در localStorage diff --git a/src/FrontOffice.Main/Pages/Profile/Personal.razor.cs b/src/FrontOffice.Main/Pages/Profile/Personal.razor.cs index 6ad780b..7e61d87 100644 --- a/src/FrontOffice.Main/Pages/Profile/Personal.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/Personal.razor.cs @@ -1,6 +1,6 @@ -using FluentValidation; -using FrontOffice.BFF.User.Protobuf.Protos.User; -using FrontOffice.BFF.User.Protobuf.Validator; +using CMSMicroservice.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Validator.User; + using FrontOffice.Main.Utilities; using Mapster; using Microsoft.AspNetCore.Components; diff --git a/src/FrontOffice.Main/Pages/Profile/Settings.razor.cs b/src/FrontOffice.Main/Pages/Profile/Settings.razor.cs index 671fe41..df0f1d5 100644 --- a/src/FrontOffice.Main/Pages/Profile/Settings.razor.cs +++ b/src/FrontOffice.Main/Pages/Profile/Settings.razor.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.User.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.User; using Mapster; using Microsoft.AspNetCore.Components; using MudBlazor; diff --git a/src/FrontOffice.Main/Pages/RegisterWizard.razor.cs b/src/FrontOffice.Main/Pages/RegisterWizard.razor.cs index ae5f8d4..54c1175 100644 --- a/src/FrontOffice.Main/Pages/RegisterWizard.razor.cs +++ b/src/FrontOffice.Main/Pages/RegisterWizard.razor.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; using DateTimeConverterCL; -using FrontOffice.BFF.User.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.User; using FrontOffice.Main.Shared; using FrontOffice.Main.Utilities; using Google.Protobuf.WellKnownTypes; @@ -67,7 +67,7 @@ public partial class RegisterWizard { try { - var existUser = await UserContract.GetUserAsync(new Empty()); + var existUser = await UserContract.GetUserForCustomerAsync(new GetUserForCustomerRequest()); if (existUser != null && !string.IsNullOrEmpty(existUser.FirstName) && string.IsNullOrWhiteSpace(_model.FirstName)) { diff --git a/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor b/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor index 0563e91..23c3fd7 100644 --- a/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor +++ b/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor @@ -1,4 +1,5 @@ -@using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder +@using CMSMicroservice.Protobuf.Protos.UserOrder +@using CMSMicroservice.Protobuf.Protos @attribute [Route(RouteConstants.Store.CheckoutSummary)] خلاصه خرید diff --git a/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor.cs b/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor.cs index d15e699..7d8af27 100644 --- a/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor.cs +++ b/src/FrontOffice.Main/Pages/Store/CheckoutSummary.razor.cs @@ -1,8 +1,9 @@ -using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; +using CMSMicroservice.Protobuf.Protos.UserAddress; +using CMSMicroservice.Protobuf.Protos.UserOrder; using FrontOffice.Main.Utilities; using Microsoft.AspNetCore.Components; using MudBlazor; +using Messages = CMSMicroservice.Protobuf.Protos; namespace FrontOffice.Main.Pages.Store; @@ -20,7 +21,7 @@ public partial class CheckoutSummary : ComponentBase private bool _loadingAddresses; private long walletBalance; - private PaymentMethod _payment = PaymentMethod.Wallet; + private Messages.PaymentMethod _payment = Messages.PaymentMethod.Wallet; private bool CanPlaceOrder => Cart.Items.Count > 0 && _selectedAddress != null; diff --git a/src/FrontOffice.Main/Pages/Store/OrderDetail.razor.cs b/src/FrontOffice.Main/Pages/Store/OrderDetail.razor.cs index 8389982..b492929 100644 --- a/src/FrontOffice.Main/Pages/Store/OrderDetail.razor.cs +++ b/src/FrontOffice.Main/Pages/Store/OrderDetail.razor.cs @@ -1,6 +1,7 @@ -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; +using CMSMicroservice.Protobuf.Protos.UserOrder; using FrontOffice.Main.Utilities; using Microsoft.AspNetCore.Components; +using Messages = CMSMicroservice.Protobuf.Protos; namespace FrontOffice.Main.Pages.Store; @@ -22,23 +23,23 @@ public partial class OrderDetail : ComponentBase private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price); - private string GetStatusText(PaymentStatus orderPaymentStatus) + private string GetStatusText(Messages.PaymentStatus orderPaymentStatus) { return orderPaymentStatus switch { - PaymentStatus.Pending => "در انتظار پرداخت", - PaymentStatus.Success => "پرداخت شده", - PaymentStatus.Reject => "پرداخت ناموفق", + Messages.PaymentStatus.Pending => "در انتظار پرداخت", + Messages.PaymentStatus.Success => "پرداخت شده", + Messages.PaymentStatus.Reject => "پرداخت ناموفق", _ => "نامشخص", }; } - private string GetPaymentMethodText(PaymentMethod orderPaymentMethod) + private string GetPaymentMethodText(Messages.PaymentMethod orderPaymentMethod) { return orderPaymentMethod switch { - PaymentMethod.Wallet => "کیف پول", - PaymentMethod.Ipg => "درگاه پرداخت اینترنتی", + Messages.PaymentMethod.Wallet => "کیف پول", + Messages.PaymentMethod.Ipg => "درگاه پرداخت اینترنتی", _ => "نامشخص", }; } diff --git a/src/FrontOffice.Main/Pages/Store/OrderTracking.razor b/src/FrontOffice.Main/Pages/Store/OrderTracking.razor index bcaf653..1207505 100644 --- a/src/FrontOffice.Main/Pages/Store/OrderTracking.razor +++ b/src/FrontOffice.Main/Pages/Store/OrderTracking.razor @@ -1,4 +1,4 @@ -@using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder +@using CMSMicroservice.Protobuf.Protos.UserOrder @attribute [Route(RouteConstants.Store.OrderTracking + "{id:long}")] پیگیری سفارش diff --git a/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs b/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs index 565ea3b..84561ed 100644 --- a/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs +++ b/src/FrontOffice.Main/Pages/Store/OrderTracking.razor.cs @@ -1,6 +1,7 @@ -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; +using CMSMicroservice.Protobuf.Protos.UserOrder; using FrontOffice.Main.Utilities; using Microsoft.AspNetCore.Components; +using Messages = CMSMicroservice.Protobuf.Protos; namespace FrontOffice.Main.Pages.Store; @@ -45,7 +46,7 @@ public partial class OrderTracking : ComponentBase if (_order is null) return; // Build tracking steps based on PaymentStatus - var isPaid = _order.PaymentStatus == PaymentStatus.Success; + var isPaid = _order.PaymentStatus == Messages.PaymentStatus.Success; _trackingSteps = new List { @@ -107,10 +108,10 @@ public partial class OrderTracking : ComponentBase return $"{persianCalendar.GetYear(date)}/{persianCalendar.GetMonth(date):00}/{persianCalendar.GetDayOfMonth(date):00}"; } - private static string GetPaymentMethodText(PaymentMethod method) => method switch + private static string GetPaymentMethodText(Messages.PaymentMethod method) => method switch { - PaymentMethod.Ipg => "پرداخت آنلاین", - PaymentMethod.Wallet => "کیف پول", + Messages.PaymentMethod.Ipg => "پرداخت آنلاین", + Messages.PaymentMethod.Wallet => "کیف پول", _ => "نامشخص" }; diff --git a/src/FrontOffice.Main/Pages/Store/Orders.razor.cs b/src/FrontOffice.Main/Pages/Store/Orders.razor.cs index f5207b9..0ce3138 100644 --- a/src/FrontOffice.Main/Pages/Store/Orders.razor.cs +++ b/src/FrontOffice.Main/Pages/Store/Orders.razor.cs @@ -1,7 +1,8 @@ using System; -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; +using CMSMicroservice.Protobuf.Protos.UserOrder; using FrontOffice.Main.Utilities; using Microsoft.AspNetCore.Components; +using Messages = CMSMicroservice.Protobuf.Protos; using MudBlazor; namespace FrontOffice.Main.Pages.Store; @@ -45,13 +46,13 @@ public partial class Orders : ComponentBase private static string FormatPrice(long price) => string.Format("{0:N0} تومان", price); - private string GetStatusText(PaymentStatus contextPaymentStatus) + private string GetStatusText(Messages.PaymentStatus contextPaymentStatus) { return contextPaymentStatus switch { - PaymentStatus.Pending => "در انتظار پرداخت", - PaymentStatus.Success => "پرداخت شده", - PaymentStatus.Reject => "پرداخت ناموفق", + Messages.PaymentStatus.Pending => "در انتظار پرداخت", + Messages.PaymentStatus.Success => "پرداخت شده", + Messages.PaymentStatus.Reject => "پرداخت ناموفق", _ => "نامشخص", }; } diff --git a/src/FrontOffice.Main/Shared/AuthDialog.razor b/src/FrontOffice.Main/Shared/AuthDialog.razor index 011fd88..ba3a17f 100644 --- a/src/FrontOffice.Main/Shared/AuthDialog.razor +++ b/src/FrontOffice.Main/Shared/AuthDialog.razor @@ -61,7 +61,7 @@ else __builder.AddContent(4, "لطفاً شماره موبایل خود را وارد کنید تا رمز پویا ارسال شود."); __builder.CloseComponent(); - + - + e.ErrorMessage).Distinct()); + _errorMessage = "لطفاً شماره تلفن معتبر وارد کنید."; // string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct()); return; } @@ -189,10 +186,10 @@ public partial class AuthDialog : IDisposable _verifyRequest.ParentReferralCode = storedReferralCode; } - var validationResult = _verifyRequestValidator.Validate(_verifyRequest); - if (!validationResult.IsValid) + var validationResult = true; // _verifyRequestValidator.Validate(_verifyRequest); + if (!validationResult) { - _errorMessage = string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct()); + _errorMessage = "لطفاً کد تأیید معتبر وارد کنید."; // string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct()); return false; } diff --git a/src/FrontOffice.Main/Shared/ClubMembershipContractDialog.razor b/src/FrontOffice.Main/Shared/ClubMembershipContractDialog.razor index c032b59..6f372f7 100644 --- a/src/FrontOffice.Main/Shared/ClubMembershipContractDialog.razor +++ b/src/FrontOffice.Main/Shared/ClubMembershipContractDialog.razor @@ -1,8 +1,10 @@ -@using FrontOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership +@using CMSMicroservice.Protobuf.Protos.ClubMembership +@using CMSMicroservice.Protobuf.Protos.OtpToken @using Blazored.LocalStorage @using FrontOffice.Main.Utilities @using MudBlazor @inject ClubMembershipContract.ClubMembershipContractClient ClubMembershipClient +@inject OtpTokenContract.OtpTokenContractClient OtpTokenClient @inject ILocalStorageService LocalStorage @inject AuthService AuthService @inject ISnackbar Snackbar @@ -129,23 +131,25 @@ _isLoading = true; try { - var response = await ClubMembershipClient.RequestClubContractOtpAsync( - new RequestClubContractOtpRequest + var response = await OtpTokenClient.CreateNewOtpTokenAsync( + new CMSMicroservice.Protobuf.Protos.OtpToken.CreateNewOtpTokenRequest { - SignGuid = _signGuid.ToString() + Mobile = await GetUserMobileAsync(), + Purpose = "ClubContract" }); if (response.Success) { _step = ContractStep.EnterOtp; - _remainingSeconds = response.RemainingSeconds > 0 ? response.RemainingSeconds : 120; + _remainingSeconds = 120; // Default 2 minutes StartCountdown(); } else { - Snackbar.Add(response.Message, Severity.Error); + Snackbar.Add(response.Message ?? "ارسال رمز پویا با خطا مواجه شد.", Severity.Error); } } + catch (Exception ex) { Snackbar.Add($"خطا در ارسال کد: {ex.Message}", Severity.Error); @@ -162,9 +166,11 @@ _isLoading = true; try { + var userId = await GetCurrentUserIdAsync(); var response = await ClubMembershipClient.AcceptClubMembershipContractAsync( - new AcceptClubMembershipContractRequest + new CMSMicroservice.Protobuf.Protos.ClubMembership.AcceptClubMembershipContractRequest { + UserId = userId, OtpCode = _otpCode, SignGuid = _signGuid.ToString(), ContractHtml = GetClubContractHtml() @@ -172,21 +178,16 @@ if (response.Success) { - // ذخیره توکن جدید - if (!string.IsNullOrEmpty(response.Token)) - { - await LocalStorage.SetItemAsync(TokenStorageKey, response.Token); - await AuthService.InitUserAuthInfo(); - } - _step = ContractStep.Success; StopCountdown(); + Snackbar.Add("قرارداد باشگاه مشتریان با موفقیت امضا شد.", Severity.Success); } else { - Snackbar.Add(response.Message, Severity.Error); + Snackbar.Add(response.Message ?? "امضای قرارداد با خطا مواجه شد.", Severity.Error); } } + catch (Exception ex) { Snackbar.Add($"خطا در ثبت قرارداد: {ex.Message}", Severity.Error); @@ -233,8 +234,7 @@ private string GetClubContractHtml() { - return @" -
+ return $@"

قرارداد عضویت در باشگاه مشتریان کارابازار

ماده ۱ - تعاریف

@@ -265,7 +265,21 @@

۶-۱. در صورت بروز اختلاف، طرفین ابتدا از طریق مذاکره اقدام به حل و فصل خواهند کرد.

۶-۲. در صورت عدم توافق، مراجع قضایی صلاحیت‌دار رسیدگی خواهند کرد.

-

شناسه قرارداد: " + _signGuid + @"

+

شناسه قرارداد: {_signGuid}

"; } + + private async Task GetUserMobileAsync() + { + // Get user mobile from auth service or localStorage + var userInfo = await AuthService.GetUserAuthInfo(); + return userInfo?.MobileNumber ?? ""; + } + + private async Task GetCurrentUserIdAsync() + { + // Get current user ID from auth service + var userInfo = await AuthService.GetUserAuthInfo(); + return userInfo?.UserId ?? 0; + } } diff --git a/src/FrontOffice.Main/Utilities/AppVersionService.cs b/src/FrontOffice.Main/Utilities/AppVersionService.cs index 43165bd..99f6078 100644 --- a/src/FrontOffice.Main/Utilities/AppVersionService.cs +++ b/src/FrontOffice.Main/Utilities/AppVersionService.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.Configuration.Protobuf.Protos.AppVersion; +using CMSMicroservice.Protobuf.Protos.AppVersion; using Blazored.LocalStorage; using Microsoft.JSInterop; diff --git a/src/FrontOffice.Main/Utilities/AuthService.cs b/src/FrontOffice.Main/Utilities/AuthService.cs index 2ca2510..2499652 100644 --- a/src/FrontOffice.Main/Utilities/AuthService.cs +++ b/src/FrontOffice.Main/Utilities/AuthService.cs @@ -1,5 +1,5 @@ using Blazored.LocalStorage; -using FrontOffice.BFF.User.Protobuf.Protos.User; +using CMSMicroservice.Protobuf.Protos.User; using Microsoft.AspNetCore.Components; using MudBlazor; using System.IdentityModel.Tokens.Jwt; @@ -12,7 +12,7 @@ public class AuthService private readonly NavigationManager _navigation; private readonly ISnackbar _snackbar; private readonly UserAuthInfo _userAuthInfo; - private readonly UserContract.UserContractClient _userContract; + private readonly CMSMicroservice.Protobuf.Protos.User.UserContract.UserContractClient _userContract; private readonly ILogger _logger; private const string TokenStorageKey = "auth:token"; @@ -22,7 +22,7 @@ public class AuthService NavigationManager navigation, ISnackbar snackbar, UserAuthInfo userAuthInfo, - UserContract.UserContractClient userContract, + CMSMicroservice.Protobuf.Protos.User.UserContract.UserContractClient userContract, ILogger logger) { _localStorage = localStorage; diff --git a/src/FrontOffice.Main/Utilities/CartService.cs b/src/FrontOffice.Main/Utilities/CartService.cs index 7270681..bbd8fcf 100644 --- a/src/FrontOffice.Main/Utilities/CartService.cs +++ b/src/FrontOffice.Main/Utilities/CartService.cs @@ -1,5 +1,5 @@ using DateTimeConverterCL; -using FrontOffice.BFF.ShopingCart.Protobuf.Protos.ShopingCart; +using CMSMicroservice.Protobuf.Protos.UserCarts; using Google.Protobuf.WellKnownTypes; using Blazored.LocalStorage; @@ -16,7 +16,7 @@ public record CartItem(long cartId,long ProductId, string Title, string ImageUrl public class CartService { - private readonly ShopingCartContract.ShopingCartContractClient _client; + private readonly UserCartsContract.UserCartsContractClient _client; private readonly ILocalStorageService _localStorage; private readonly List _items = new(); private const string TokenStorageKey = "auth:token"; @@ -24,7 +24,7 @@ public class CartService public event Action? OnChange; - public CartService(ShopingCartContract.ShopingCartContractClient client, ILocalStorageService localStorage) + public CartService(CMSMicroservice.Protobuf.Protos.UserCarts.UserCartsContract.UserCartsContractClient client, ILocalStorageService localStorage) { _client = client; _localStorage = localStorage; @@ -83,6 +83,7 @@ public class CartService await _client.UpdateUserCartAsync(new UpdateUserCartRequest { UserCartId = existing.cartId, + Count = newQuantity }); } @@ -214,7 +215,7 @@ public class CartService try { - var response = await _client.GetAllUserCartAsync(new Empty()); + var response = await _client.GetCustomerCartAsync(new GetUserCartForCustomerRequest()); _items.Clear(); foreach (var model in response.Models) { diff --git a/src/FrontOffice.Main/Utilities/CategoryService.cs b/src/FrontOffice.Main/Utilities/CategoryService.cs index 638f3dd..c48078d 100644 --- a/src/FrontOffice.Main/Utilities/CategoryService.cs +++ b/src/FrontOffice.Main/Utilities/CategoryService.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using FrontOffice.BFF.Category.Protobuf.Protos.Category; +using CMSMicroservice.Protobuf.Protos.Category; namespace FrontOffice.Main.Utilities; @@ -9,10 +9,10 @@ public sealed record CategoryItem(long Id, string Title, long? ParentId, string? public class CategoryService { - private readonly CategoryContract.CategoryContractClient _client; + private readonly CMSMicroservice.Protobuf.Protos.Category.CategoryContract.CategoryContractClient _client; private List? _cache; - public CategoryService(CategoryContract.CategoryContractClient client) + public CategoryService(CMSMicroservice.Protobuf.Protos.Category.CategoryContract.CategoryContractClient client) { _client = client; } @@ -24,7 +24,7 @@ public class CategoryService return _cache; } - var response = await _client.GetAllCategoriesAsync(new GetCategoriesRequest()); + var response = await _client.GetAllCategoriesForCustomerAsync(new GetAllCategoriesForCustomerRequest()); _cache = response.Models .Select(dto => new CategoryItem( Id: dto.Id, diff --git a/src/FrontOffice.Main/Utilities/ClubConfigurationService.cs b/src/FrontOffice.Main/Utilities/ClubConfigurationService.cs index b1ec45b..c447131 100644 --- a/src/FrontOffice.Main/Utilities/ClubConfigurationService.cs +++ b/src/FrontOffice.Main/Utilities/ClubConfigurationService.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.Configuration.Protobuf.Protos.Configuration; +using CMSMicroservice.Protobuf.Protos.Configuration; namespace FrontOffice.Main.Utilities; diff --git a/src/FrontOffice.Main/Utilities/ClubMembershipService.cs b/src/FrontOffice.Main/Utilities/ClubMembershipService.cs index ef31f55..92ad728 100644 --- a/src/FrontOffice.Main/Utilities/ClubMembershipService.cs +++ b/src/FrontOffice.Main/Utilities/ClubMembershipService.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership; +using CMSMicroservice.Protobuf.Protos.ClubMembership; using Google.Protobuf.WellKnownTypes; namespace FrontOffice.Main.Utilities; @@ -24,7 +24,8 @@ public class ClubMembershipService { try { - var response = await _client.GetMyClubMembershipAsync(new Empty()); + var userId = await GetCurrentUserIdAsync(); + var response = await _client.GetClubMembershipAsync(new GetClubMembershipRequest { UserId = userId }); return new ClubMembershipDto { UserId = response.UserId, @@ -57,8 +58,10 @@ public class ClubMembershipService { try { - var request = new ActivateMyClubMembershipRequest + var userId = await GetCurrentUserIdAsync(); + var request = new ActivateClubMembershipRequest { + UserId = userId, PackageId = packageId, DurationMonths = durationMonths }; @@ -68,13 +71,14 @@ public class ClubMembershipService request.ActivationCode = activationCode; } - var response = await _client.ActivateMyClubMembershipAsync(request); + await _client.ActivateClubMembershipAsync(request); + // Note: CMS ActivateClubMembership returns Empty, not detailed response return new ClubActivationResponseDto { - Success = response.Success, - Message = response.Message, - ActivationDate = response.ActivationDate?.ToDateTime(), - AmountPaid = response.AmountPaid + Success = true, + Message = "عضویت باشگاه با موفقیت فعال شد.", + ActivationDate = DateTime.Now, + AmountPaid = 0 // Not available in CMS response }; } catch (Grpc.Core.RpcException ex) @@ -88,4 +92,11 @@ public class ClubMembershipService }; } } + + private async Task GetCurrentUserIdAsync() + { + // Get current user ID from auth service or JWT token + // This is a placeholder - should be implemented based on your auth system + return 1; // TODO: Implement proper user ID retrieval + } } diff --git a/src/FrontOffice.Main/Utilities/CommissionService.cs b/src/FrontOffice.Main/Utilities/CommissionService.cs index 25e7a1a..daea7ff 100644 --- a/src/FrontOffice.Main/Utilities/CommissionService.cs +++ b/src/FrontOffice.Main/Utilities/CommissionService.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.Commission.Protobuf.Protos.Commission; +using CMSMicroservice.Protobuf.Protos.Commission; namespace FrontOffice.Main.Utilities; diff --git a/src/FrontOffice.Main/Utilities/NetworkMembershipService.cs b/src/FrontOffice.Main/Utilities/NetworkMembershipService.cs index e706c77..f34c501 100644 --- a/src/FrontOffice.Main/Utilities/NetworkMembershipService.cs +++ b/src/FrontOffice.Main/Utilities/NetworkMembershipService.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.NetworkMembership.Protobuf.Protos.NetworkMembership; +using CMSMicroservice.Protobuf.Protos.NetworkMembership; using Google.Protobuf.WellKnownTypes; namespace FrontOffice.Main.Utilities; @@ -122,7 +122,7 @@ public class NetworkMembershipService #region Helper Methods - private static NetworkNodeDto? MapNodeFromProto(NetworkNodeModel? node) + private static NetworkNodeDto? MapNodeFromProto(NetworkTreeNodeModel? node) { if (node == null) return null; diff --git a/src/FrontOffice.Main/Utilities/OrderService.cs b/src/FrontOffice.Main/Utilities/OrderService.cs index f7c38f7..d3b1ea7 100644 --- a/src/FrontOffice.Main/Utilities/OrderService.cs +++ b/src/FrontOffice.Main/Utilities/OrderService.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; +using CMSMicroservice.Protobuf.Protos.UserOrder; using Mapster; namespace FrontOffice.Main.Utilities; @@ -35,9 +35,9 @@ public class OrderService { private long _seq = 1000; private readonly List _orders = new(); - private readonly UserOrderContract.UserOrderContractClient _userOrderContractClient; + private readonly CMSMicroservice.Protobuf.Protos.UserOrder.UserOrderContract.UserOrderContractClient _userOrderContractClient; - public OrderService(UserOrderContract.UserOrderContractClient userOrderContractClient) + public OrderService(CMSMicroservice.Protobuf.Protos.UserOrder.UserOrderContract.UserOrderContractClient userOrderContractClient) { _userOrderContractClient = userOrderContractClient; } @@ -83,21 +83,18 @@ public class OrderService /// /// دریافت نرخ مالیات بر ارزش افزوده /// - public async Task GetVATRateAsync() + public async Task GetVATRateAsync() { try { - return await _userOrderContractClient.GetVATRateAsync(new Google.Protobuf.WellKnownTypes.Empty()); + // TODO: Use Configuration service to get VAT rate + // return await _userOrderContractClient.GetVATRateAsync(new Google.Protobuf.WellKnownTypes.Empty()); + return 0.10; // Default 10% } catch { // در صورت خطا، مقادیر پیش‌فرض - return new GetVATRateResponse - { - VatRate = 0.10, - VatPercentage = 10, - IsEnabled = true - }; + return 0.10; } } } \ No newline at end of file diff --git a/src/FrontOffice.Main/Utilities/PackageService.cs b/src/FrontOffice.Main/Utilities/PackageService.cs index c79bc6c..09dfdb9 100644 --- a/src/FrontOffice.Main/Utilities/PackageService.cs +++ b/src/FrontOffice.Main/Utilities/PackageService.cs @@ -1,4 +1,4 @@ -using FrontOffice.BFF.Package.Protobuf.Protos.Package; +using CMSMicroservice.Protobuf.Protos.Package; namespace FrontOffice.Main.Utilities; @@ -31,9 +31,9 @@ public record UserPackageStatusDto( /// public class PackageService { - private readonly PackageContract.PackageContractClient _client; + private readonly CMSMicroservice.Protobuf.Protos.Package.PackageContract.PackageContractClient _client; - public PackageService(PackageContract.PackageContractClient client) + public PackageService(CMSMicroservice.Protobuf.Protos.Package.PackageContract.PackageContractClient client) { _client = client; } @@ -45,16 +45,9 @@ public class PackageService { try { - var request = new GetAllPackageByFilterRequest - { - PaginationState = new PaginationState - { - PageNumber = 1, - PageSize = 100 - } - }; + var request = new GetCustomerPackagesRequest(); - var response = await _client.GetAllPackageByFilterAsync(request, cancellationToken: ct); + var response = await _client.GetCustomerPackagesAsync(request, cancellationToken: ct); return response.Models .Select(m => new PackageDto( @@ -81,8 +74,8 @@ public class PackageService { try { - var response = await _client.GetPackageAsync( - new GetPackageRequest { Id = id }, + var response = await _client.GetCustomerPackageDetailsAsync( + new GetCustomerPackageDetailsRequest { PackageId = id }, cancellationToken: ct); if (response == null) return null; diff --git a/src/FrontOffice.Main/Utilities/ProductService.cs b/src/FrontOffice.Main/Utilities/ProductService.cs index f8a0c1b..d81d183 100644 --- a/src/FrontOffice.Main/Utilities/ProductService.cs +++ b/src/FrontOffice.Main/Utilities/ProductService.cs @@ -3,7 +3,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; -using FrontOffice.BFF.Products.Protobuf.Protos.Products; +using CMSMicroservice.Protobuf.Protos.Products; using Google.Protobuf.WellKnownTypes; namespace FrontOffice.Main.Utilities; @@ -51,9 +51,9 @@ public class ProductService { private readonly ConcurrentDictionary _cache = new(); private static readonly TimeSpan CacheDuration = TimeSpan.FromMinutes(1); - private readonly ProductsContract.ProductsContractClient _client; + private readonly CMSMicroservice.Protobuf.Protos.Products.ProductsContract.ProductsContractClient _client; - public ProductService(ProductsContract.ProductsContractClient client) + public ProductService(CMSMicroservice.Protobuf.Protos.Products.ProductsContract.ProductsContractClient client) { _client = client; } diff --git a/src/FrontOffice.Main/Utilities/VATService.cs b/src/FrontOffice.Main/Utilities/VATService.cs index 84a0253..f36f9ed 100644 --- a/src/FrontOffice.Main/Utilities/VATService.cs +++ b/src/FrontOffice.Main/Utilities/VATService.cs @@ -1,5 +1,5 @@ using Blazored.LocalStorage; -using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; +using CMSMicroservice.Protobuf.Protos.UserOrder; using Microsoft.Extensions.DependencyInjection; namespace FrontOffice.Main.Utilities; @@ -93,7 +93,7 @@ public class VATService { // ایجاد scope برای دریافت client و localStorage using var scope = _serviceProvider.CreateScope(); - var client = scope.ServiceProvider.GetRequiredService(); + var client = scope.ServiceProvider.GetRequiredService(); // var localStorage = scope.ServiceProvider.GetRequiredService(); var response = await client.GetVATRateAsync(new Google.Protobuf.WellKnownTypes.Empty()); diff --git a/src/FrontOffice.Main/Utilities/WalletService.cs b/src/FrontOffice.Main/Utilities/WalletService.cs index 781729b..32b14a9 100644 --- a/src/FrontOffice.Main/Utilities/WalletService.cs +++ b/src/FrontOffice.Main/Utilities/WalletService.cs @@ -1,5 +1,6 @@ using DateTimeConverterCL; -using FrontOffice.BFF.UserWallet.Protobuf.Protos.UserWallet; +using CMSMicroservice.Protobuf.Protos.UserWallet; +using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog; using Google.Protobuf.WellKnownTypes; namespace FrontOffice.Main.Utilities; @@ -16,9 +17,9 @@ public record WithdrawalSettings(long MinWithdrawalAmount); public class WalletService { - private readonly UserWalletContract.UserWalletContractClient _client; + private readonly CMSMicroservice.Protobuf.Protos.UserWallet.UserWalletContract.UserWalletContractClient _client; - public WalletService(UserWalletContract.UserWalletContractClient client) + public WalletService(CMSMicroservice.Protobuf.Protos.UserWallet.UserWalletContract.UserWalletContractClient client) { _client = client; } @@ -27,7 +28,7 @@ public class WalletService { try { - var response = await _client.GetUserWalletAsync(new Empty()); + var response = await _client.GetCustomerWalletAsync(new Empty()); return new WalletBalances(response.Balance, response.DiscountBalance, response.NetworkBalance); } catch @@ -41,7 +42,7 @@ public class WalletService { try { - var request = new GetAllUserWalletChangeLogRequest(); + var request = new GetCustomerWalletChangeLogRequest(); if (referenceId.HasValue) { request.ReferenceId = referenceId.Value; @@ -50,7 +51,7 @@ public class WalletService { request.IsIncrease = isIncrease.Value; } - var response = await _client.GetAllUserWalletChangeLogAsync(request); + var response = await _client.GetCustomerWalletChangeLogAsync(request); return response.Models .Select(t => new WalletTransaction( ResolveTransactionDate(t), @@ -67,7 +68,7 @@ public class WalletService } } - private static string ResolveTransactionDate(GetAllUserWalletChangeLogResponseModel model) + private static string ResolveTransactionDate(CustomerWalletChangeLogModel model) { if (model.CreatedAt is not null) { @@ -84,7 +85,7 @@ public class WalletService return DateTime.Now.MiladiToJalaliWithTime(); } - private static string ResolveDescription(GetAllUserWalletChangeLogResponseModel model) + private static string ResolveDescription(CustomerWalletChangeLogModel model) { if (model.ChangeValue > 0) return "شارژ کیف پول"; if (model.ChangeValue < 0) return "برداشت/خرید"; @@ -93,7 +94,7 @@ public class WalletService public async Task RequestWithdrawalAsync(long payoutId, WithdrawalMethodClient method, string? iban) { - var request = new WithdrawBalanceRequest + var request = new CustomerWithdrawBalanceRequest { PayoutId = payoutId, WithdrawalMethod = (int)method @@ -104,7 +105,7 @@ public class WalletService } try { - await _client.WithdrawBalanceAsync(request); + await _client.CustomerWithdrawBalanceAsync(request); return true; } catch (Grpc.Core.RpcException ex) @@ -117,13 +118,13 @@ public class WalletService { try { - var request = new GetUserWithdrawalsRequest(); + var request = new GetCustomerWithdrawalsRequest(); if (status.HasValue) { request.Status = status.Value; } - var response = await _client.GetUserWithdrawalsAsync(request); + var response = await _client.GetCustomerWithdrawalsAsync(request); return response.Models .Select(m => new WalletWithdrawal( m.Id, @@ -146,7 +147,7 @@ public class WalletService { try { - var response = await _client.GetWithdrawalSettingsAsync(new Empty()); + var response = await _client.GetCustomerWithdrawalSettingsAsync(new Empty()); return new WithdrawalSettings(response.MinWithdrawalAmount); } catch diff --git a/src/FrontOffice.Main/_Imports.razor b/src/FrontOffice.Main/_Imports.razor index 08f16aa..cf41a2c 100644 --- a/src/FrontOffice.Main/_Imports.razor +++ b/src/FrontOffice.Main/_Imports.razor @@ -12,7 +12,7 @@ @using MudBlazor @using FrontOffice.Main.Utilities @using DateTimeConverterCL -@using CityProto = FrontOffice.BFF.City.Protobuf + @inject NavigationManager Navigation @inject IDialogService DialogService diff --git a/src/FrontOffice.Main/appsettings.json b/src/FrontOffice.Main/appsettings.json index 5fa9b96..6517b77 100644 --- a/src/FrontOffice.Main/appsettings.json +++ b/src/FrontOffice.Main/appsettings.json @@ -1,6 +1,6 @@ { // "GwUrl": "https://localhost:34781", - "GwUrl": "https://frontoffice-bff.se.kbs1.ir", + "GwUrl": "https://localhost:32846", "DownloadUrl": "https://dl.afrino.co", "EncryptionSettings": { "Key": "kmcQ3XTmH4mrdh8VHziuscyf8LLYjG//Kyni81nH/0E=",