2025-09-28 00:45:26 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.OtpToken;
|
|
|
|
|
using CMSMicroservice.Protobuf.Protos.Package;
|
2025-11-17 20:39:31 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.Products;
|
2025-09-28 00:45:26 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.User;
|
|
|
|
|
using CMSMicroservice.Protobuf.Protos.UserAddress;
|
2025-11-20 00:56:58 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.UserCarts;
|
2025-11-16 17:29:30 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.UserContract;
|
2025-09-28 00:45:26 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.UserOrder;
|
2025-11-25 02:46:57 +03:30
|
|
|
using CMSMicroservice.Protobuf.Protos.UserWallet;
|
|
|
|
|
using CMSMicroservice.Protobuf.Protos.UserWalletChangeLog;
|
2025-09-27 10:36:00 +03:30
|
|
|
using FrontOffice.BFF.Application.Common.Interfaces;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2025-10-13 13:00:03 +03:30
|
|
|
using PYMSMicroservice.Protobuf.Protos.Transaction;
|
2025-09-27 10:36:00 +03:30
|
|
|
|
|
|
|
|
namespace FrontOffice.BFF.Infrastructure.Services;
|
|
|
|
|
|
|
|
|
|
public class ApplicationContractContext : IApplicationContractContext
|
|
|
|
|
{
|
|
|
|
|
#region members
|
|
|
|
|
|
2025-09-28 00:45:26 +03:30
|
|
|
private readonly IServiceProvider _serviceProvider;
|
2025-09-27 10:36:00 +03:30
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region utilities
|
|
|
|
|
|
|
|
|
|
private T GetService<T>() where T : Grpc.Core.ClientBase<T>
|
|
|
|
|
{
|
|
|
|
|
return _serviceProvider.GetService<T>() ??
|
|
|
|
|
throw new Exception($"requested service not registered: {typeof(T).FullName}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public ApplicationContractContext(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region FM
|
|
|
|
|
|
|
|
|
|
//public FileLogContract.FileLogContractClient FileManagements => GetService<FileLogContract.FileLogContractClient>();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2025-09-28 00:45:26 +03:30
|
|
|
#region CMS
|
|
|
|
|
public PackageContract.PackageContractClient Package => GetService<PackageContract.PackageContractClient>();
|
2025-11-17 20:39:31 +03:30
|
|
|
public ProductsContract.ProductsContractClient Product => GetService<ProductsContract.ProductsContractClient>();
|
2025-11-20 00:56:58 +03:30
|
|
|
public UserCartsContract.UserCartsContractClient UserCart => GetService<UserCartsContract.UserCartsContractClient>();
|
2025-09-28 00:45:26 +03:30
|
|
|
|
|
|
|
|
public UserContract.UserContractClient User => GetService<UserContract.UserContractClient>();
|
2025-11-16 17:29:30 +03:30
|
|
|
public UserContractContract.UserContractContractClient UserContract => GetService<UserContractContract.UserContractContractClient>();
|
2025-09-28 00:45:26 +03:30
|
|
|
public UserAddressContract.UserAddressContractClient UserAddress => GetService<UserAddressContract.UserAddressContractClient>();
|
|
|
|
|
|
|
|
|
|
public UserOrderContract.UserOrderContractClient UserOrder => GetService<UserOrderContract.UserOrderContractClient>();
|
|
|
|
|
|
|
|
|
|
public OtpTokenContract.OtpTokenContractClient OtpToken => GetService<OtpTokenContract.OtpTokenContractClient>();
|
2025-11-25 02:46:57 +03:30
|
|
|
public UserWalletContract.UserWalletContractClient UserWallet => GetService<UserWalletContract.UserWalletContractClient>();
|
|
|
|
|
public UserWalletChangeLogContract.UserWalletChangeLogContractClient UserWalletChangeLog => GetService<UserWalletChangeLogContract.UserWalletChangeLogContractClient>();
|
2025-09-28 00:45:26 +03:30
|
|
|
#endregion
|
2025-10-13 13:00:03 +03:30
|
|
|
|
|
|
|
|
#region PYMS
|
|
|
|
|
public TransactionContract.TransactionContractClient ZarinTransactions => GetService<TransactionContract.TransactionContractClient>();
|
|
|
|
|
|
|
|
|
|
#endregion
|
2025-09-27 10:36:00 +03:30
|
|
|
}
|