using CMSMicroservice.Protobuf.Protos.Configuration;
namespace FrontOffice.Main.Utilities;
///
/// سرویس تنظیمات باشگاه مشتریان
///
public class ClubConfigurationService
{
private readonly ConfigurationContract.ConfigurationContractClient _client;
public ClubConfigurationService(ConfigurationContract.ConfigurationContractClient client)
{
_client = client;
}
///
/// دریافت تنظیمات باشگاه مشتریان
///
public async Task GetClubConfigurationAsync()
{
var response = await _client.GetClubConfigurationAsync(new Google.Protobuf.WellKnownTypes.Empty());
return new ClubConfigDto
{
ActivationFee = response.ActivationFee,
MembershipGiftValue = response.MembershipGiftValue
};
}
///
/// دریافت لیست فیچرهای باشگاه برای کاربر جاری
///
public async Task> GetClubFeaturesAsync()
{
var response = await _client.GetClubFeaturesAsync(new Google.Protobuf.WellKnownTypes.Empty());
return response.Features.Select(f => new ClubFeatureDto
{
Id = f.Id,
Title = f.Title,
Description = f.Description,
IsEnabled = f.IsEnabled,
DisplayOrder = f.DisplayOrder,
GrantedAt = f.GrantedAt?.ToDateTime(),
CreatedAt = f.CreatedAt?.ToDateTime(),
Notes = f.Notes
}).ToList();
}
}
public class ClubConfigDto
{
public long ActivationFee { get; set; }
public long MembershipGiftValue { get; set; }
}
public class ClubFeatureDto
{
public long Id { get; set; }
public string Title { get; set; } = string.Empty;
public string? Description { get; set; }
public bool IsEnabled { get; set; }
public int DisplayOrder { get; set; }
public DateTime? GrantedAt { get; set; }
public DateTime? CreatedAt { get; set; }
public string? Notes { get; set; }
}