Added the Tenant Profile API

This commit is contained in:
ashutosh.nehete 2025-08-06 12:41:32 +05:30
parent 6b4e229f6b
commit c210e6e3f2
4 changed files with 32 additions and 10 deletions

View File

@ -1,5 +1,6 @@
using Marco.Pms.Model.Master; using Marco.Pms.Model.Master;
using Marco.Pms.Model.TenantModels.MongoDBModel; using Marco.Pms.Model.TenantModels;
using Marco.Pms.Model.ViewModels.Activities;
namespace Marco.Pms.Model.ViewModels.Tenant namespace Marco.Pms.Model.ViewModels.Tenant
{ {
@ -8,14 +9,14 @@ namespace Marco.Pms.Model.ViewModels.Tenant
public Guid Id { get; set; } public Guid Id { get; set; }
public string? PlanName { get; set; } public string? PlanName { get; set; }
public string? Description { get; set; } public string? Description { get; set; }
public double PriceQuarterly { get; set; } public double Price { get; set; }
public double PriceMonthly { get; set; } public PLAN_FREQUENCY Frequency { get; set; }
public double PriceHalfYearly { get; set; } public DateTime StartDate { get; set; }
public double PriceYearly { get; set; } public DateTime EndDate { get; set; }
public int TrialDays { get; set; } public DateTime CreatedAt { get; set; }
public double MaxUser { get; set; } public DateTime? UpdatedAt { get; set; }
public double MaxStorage { get; set; } public BasicEmployeeVM? CreatedBy { get; set; }
public FeatureDetails? Features { get; set; } public BasicEmployeeVM? updatedBy { get; set; }
public CurrencyMaster? Currency { get; set; } public CurrencyMaster? Currency { get; set; }
} }
} }

View File

@ -33,5 +33,6 @@ namespace Marco.Pms.Model.ViewModels.Tenant
public DateTime? ExpiryDate { get; set; } public DateTime? ExpiryDate { get; set; }
public DateTime? NextBillingDate { get; set; } public DateTime? NextBillingDate { get; set; }
public BasicEmployeeVM? CreatedBy { get; set; } public BasicEmployeeVM? CreatedBy { get; set; }
public List<SubscriptionPlanDetailsVM>? SubscriptionHistery { get; set; }
} }
} }

View File

@ -277,6 +277,9 @@ namespace Marco.Pms.Services.Controllers
{ {
await using var _dbContext = await _dbContextFactory.CreateDbContextAsync(); await using var _dbContext = await _dbContextFactory.CreateDbContextAsync();
return await _dbContext.TenantSubscriptions return await _dbContext.TenantSubscriptions
.Include(sp => sp!.CreatedBy)
.Include(sp => sp!.UpdatedBy)
.Include(sp => sp!.Currency)
.Include(ts => ts.Plan).ThenInclude(sp => sp!.Plan) .Include(ts => ts.Plan).ThenInclude(sp => sp!.Plan)
.AsNoTracking() .AsNoTracking()
.Where(ts => ts.TenantId == tenant.Id && ts.Plan != null) .Where(ts => ts.TenantId == tenant.Id && ts.Plan != null)
@ -317,7 +320,7 @@ namespace Marco.Pms.Services.Controllers
response.ExpiryDate = expiryDate; response.ExpiryDate = expiryDate;
response.NextBillingDate = nextBillingDate; response.NextBillingDate = nextBillingDate;
response.CreatedBy = createdBy; response.CreatedBy = createdBy;
response.SubscriptionHistery = _mapper.Map<List<SubscriptionPlanDetailsVM>>(plans);
return Ok(ApiResponse<object>.SuccessResponse(response, "Tenant profile fetched successfully", 200)); return Ok(ApiResponse<object>.SuccessResponse(response, "Tenant profile fetched successfully", 200));
} }

View File

@ -43,6 +43,23 @@ namespace Marco.Pms.Services.MappingProfiles
dest => dest.Description, dest => dest.Description,
opt => opt.MapFrom(src => src.Plan != null ? src.Plan.Description : "") opt => opt.MapFrom(src => src.Plan != null ? src.Plan.Description : "")
); );
CreateMap<TenantSubscriptions, SubscriptionPlanDetailsVM>()
.ForMember(
dest => dest.PlanName,
opt => opt.MapFrom(src => src.Plan!.Plan != null ? src.Plan.Plan.PlanName : "")
)
.ForMember(
dest => dest.Description,
opt => opt.MapFrom(src => src.Plan!.Plan != null ? src.Plan.Plan.Description : "")
)
.ForMember(
dest => dest.Price,
opt => opt.MapFrom(src => src.Plan != null ? src.Plan.Price : 0)
)
.ForMember(
dest => dest.Frequency,
opt => opt.MapFrom(src => src.Plan != null ? src.Plan.Frequency : PLAN_FREQUENCY.MONTHLY)
);
CreateMap<SubscriptionPlanDetailsDto, SubscriptionPlanDetails>(); CreateMap<SubscriptionPlanDetailsDto, SubscriptionPlanDetails>();
CreateMap<SubscriptionPlanDto, SubscriptionPlan>(); CreateMap<SubscriptionPlanDto, SubscriptionPlan>();