Refactor: Update Protobuf references to CMSMicroservice across multiple components
- Changed Protobuf imports from FrontOffice.BFF to CMSMicroservice in Profile components (EditAddressDialog, Index, PaymentCallback, Personal, Settings). - Updated CheckoutSummary, OrderDetail, OrderTracking, and Orders pages to use new UserOrder Protobuf definitions. - Refactored WalletService, PackageService, and other utility services to align with new Protobuf structure. - Adjusted appsettings.json for local development URL. - Removed unused validators and simplified validation logic in AuthDialog. - Enhanced ClubMembershipContractDialog to utilize new OtpToken service for OTP handling.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Configuration.Protobuf.Protos.AppVersion;
|
||||
using CMSMicroservice.Protobuf.Protos.AppVersion;
|
||||
using Blazored.LocalStorage;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
|
||||
@@ -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<AuthService> _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<AuthService> logger)
|
||||
{
|
||||
_localStorage = localStorage;
|
||||
|
||||
@@ -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<CartItem> _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)
|
||||
{
|
||||
|
||||
@@ -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<CategoryItem>? _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,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Configuration.Protobuf.Protos.Configuration;
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
|
||||
@@ -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<long> 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FrontOffice.BFF.Commission.Protobuf.Protos.Commission;
|
||||
using CMSMicroservice.Protobuf.Protos.Commission;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<GetUserOrderResponse> _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
|
||||
/// <summary>
|
||||
/// دریافت نرخ مالیات بر ارزش افزوده
|
||||
/// </summary>
|
||||
public async Task<GetVATRateResponse> GetVATRateAsync()
|
||||
public async Task<double> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
@@ -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<long, CacheEntry> _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;
|
||||
}
|
||||
|
||||
@@ -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<UserOrderContract.UserOrderContractClient>();
|
||||
var client = scope.ServiceProvider.GetRequiredService<CMSMicroservice.Protobuf.Protos.UserOrder.UserOrderContract.UserOrderContractClient>();
|
||||
// var localStorage = scope.ServiceProvider.GetRequiredService<ILocalStorageService>();
|
||||
|
||||
var response = await client.GetVATRateAsync(new Google.Protobuf.WellKnownTypes.Empty());
|
||||
|
||||
@@ -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<bool> 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
|
||||
|
||||
Reference in New Issue
Block a user