Refactor CustomerPlanService to use FacilityRepository, remove PlaceService, and introduce RfidTagService
- Updated CustomerPlanService to replace references to PlaceRepo with FacilityRepository for managing customer plans and associated facilities. - Removed PlaceService and its related methods, consolidating functionality into FacilityService. - Added RfidTagService for managing RFID tags, including methods for creating, updating, and setting statuses of tags. - Updated TenantDbContext to include new DbSet for RfidTags and CustomerPlanFacilities, and adjusted model configurations accordingly. - Enhanced FacilityService to support new booking modes and validation for facility creation and updates.
This commit is contained in:
@@ -9,7 +9,11 @@ using Fitness_core_BE.Helpers;
|
||||
|
||||
namespace Fitness_core_BE.Services.CustomerPlanService
|
||||
{
|
||||
public class CustomerPlanService : ICustomerPlanService
|
||||
public class CustomerPlanService(
|
||||
ICustomerPlanRepository customerPlanRepository,
|
||||
IFacilityRepository facilityRepository,
|
||||
IUnitOfWork uow,
|
||||
UserRoleHelper userRoleHelper) : ICustomerPlanService
|
||||
{
|
||||
private const string ScopeIndividual = "Individual";
|
||||
private const string ScopeGroup = "Group";
|
||||
@@ -20,22 +24,10 @@ namespace Fitness_core_BE.Services.CustomerPlanService
|
||||
private const string BillingPrepaid = "Prepaid";
|
||||
private const string BillingPostpaid = "Postpaid";
|
||||
|
||||
private readonly ICustomerPlanRepository _customerPlanRepository;
|
||||
private readonly IPlaceRepo _placeRepo;
|
||||
private readonly IUnitOfWork _uow;
|
||||
private readonly UserRoleHelper _userRoleHelper;
|
||||
|
||||
public CustomerPlanService(
|
||||
ICustomerPlanRepository customerPlanRepository,
|
||||
IPlaceRepo placeRepo,
|
||||
IUnitOfWork uow,
|
||||
UserRoleHelper userRoleHelper)
|
||||
{
|
||||
_customerPlanRepository = customerPlanRepository;
|
||||
_placeRepo = placeRepo;
|
||||
_uow = uow;
|
||||
_userRoleHelper = userRoleHelper;
|
||||
}
|
||||
private readonly ICustomerPlanRepository _customerPlanRepository = customerPlanRepository;
|
||||
private readonly IFacilityRepository _facilityRepository = facilityRepository;
|
||||
private readonly IUnitOfWork _uow = uow;
|
||||
private readonly UserRoleHelper _userRoleHelper = userRoleHelper;
|
||||
|
||||
public async Task<object> GetAllCustomerPlans(object payload, HttpContext httpContext)
|
||||
{
|
||||
@@ -58,9 +50,9 @@ namespace Fitness_core_BE.Services.CustomerPlanService
|
||||
|
||||
var plans = await _customerPlanRepository.GetAllCustomerPlans(includeInactive, clientId);
|
||||
|
||||
var placeIdsByPlan = await _placeRepo.GetPlaceIdsByPlanIdsAsync(plans.Select(p => p.CustomerPlanId).ToList());
|
||||
var placeIdsByPlan = await _facilityRepository.GetFacilityIdsByPlanIdsAsync(plans.Select(p => p.CustomerPlanId).ToList());
|
||||
var allPlaceIds = placeIdsByPlan.Values.SelectMany(ids => ids).Distinct().ToList();
|
||||
var placeNames = await _placeRepo.GetPlaceNamesByIdsAsync(allPlaceIds);
|
||||
var placeNames = await _facilityRepository.GetFacilityNamesByIdsAsync(allPlaceIds);
|
||||
|
||||
return plans.Select(p =>
|
||||
{
|
||||
@@ -142,7 +134,7 @@ namespace Fitness_core_BE.Services.CustomerPlanService
|
||||
|
||||
var placeIds = DataExtractor.GetOptionalGuidList(data, "placeIds");
|
||||
if (placeIds != null)
|
||||
await _placeRepo.SetPlanPlacesAsync(result.CustomerPlanId, placeIds);
|
||||
await _facilityRepository.SetPlanFacilitiesAsync(result.CustomerPlanId, placeIds);
|
||||
|
||||
await _uow.CommitAsync();
|
||||
|
||||
@@ -206,7 +198,7 @@ namespace Fitness_core_BE.Services.CustomerPlanService
|
||||
|
||||
var placeIds = DataExtractor.GetOptionalGuidList(data, "placeIds");
|
||||
if (placeIds != null)
|
||||
await _placeRepo.SetPlanPlacesAsync(result.CustomerPlanId, placeIds);
|
||||
await _facilityRepository.SetPlanFacilitiesAsync(result.CustomerPlanId, placeIds);
|
||||
|
||||
await _uow.CommitAsync();
|
||||
|
||||
@@ -400,8 +392,8 @@ namespace Fitness_core_BE.Services.CustomerPlanService
|
||||
|
||||
private async Task<CustomerPlanDto> MapToDtoWithPlacesAsync(Models.CustomerPlan plan, string? clientName)
|
||||
{
|
||||
var placeIds = await _placeRepo.GetPlaceIdsForPlanAsync(plan.CustomerPlanId);
|
||||
var placeNames = await _placeRepo.GetPlaceNamesByIdsAsync(placeIds);
|
||||
var placeIds = await _facilityRepository.GetFacilityIdsForPlanAsync(plan.CustomerPlanId);
|
||||
var placeNames = await _facilityRepository.GetFacilityNamesByIdsAsync(placeIds);
|
||||
return MapToDto(plan, clientName, placeIds, placeNames);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user